<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Errors when I save the isssus parameters of my optimization in the json file]]></title><description><![CDATA[<p dir="auto">Hello everyone,</p>
<p dir="auto">I get errors when I save the isssus parameters of my optimization in the json file</p>
<p dir="auto">I've created a program that takes two parameters param1 and param2. I have otpimized them and I would like to save the parameters in a json file.</p>
<p dir="auto">here's a snippet of the command used :</p>
<p dir="auto">#DEBUG#</p>
<h1>evaluator will remove cells with such marks before evaluation</h1>
<p dir="auto">result_long = qno.optimize_strategy(<br />
data,<br />
strategy_long,<br />
qno.full_range_args_generator(param1=np.arange(10, 20, 1, dtype=int),param2=np.arange(1, 20, 2, dtype=int),<br />
asset=data.asset.values.tolist()),<br />
workers=10 # you can set more workers on your local PC to speed up<br />
)</p>
<p dir="auto">config = find_best_parameters(result=result_long, asset_count=15, parameter_set_count=3)</p>
<h1>If you change the asset_count and/or parameters_count, you will get a new strategy.</h1>
<p dir="auto">json.dump(config, open('config.json', 'w'), indent=2)</p>
<p dir="auto">display(config)</p>
<h1>I get the following errors</h1>
<hr />
<p dir="auto">TypeError                                 Traceback (most recent call last)<br />
Cell In[10], line 30<br />
27 config = find_best_parameters(result=result_long, asset_count=15, parameter_set_count=3)<br />
28 # If you change the asset_count and/or parameters_count, you will get a new strategy.<br />
---&gt; 30 json.dump(config, open('config.json', 'w'), indent=2)<br />
32 display(config)</p>
<p dir="auto">File /usr/local/lib/python3.10/json/<strong>init</strong>.py:179, in dump(obj, fp, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)<br />
173     iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii,<br />
174         check_circular=check_circular, allow_nan=allow_nan, indent=indent,<br />
175         separators=separators,<br />
176         default=default, sort_keys=sort_keys, **kw).iterencode(obj)<br />
177 # could accelerate with writelines in some versions of Python, at<br />
178 # a debuggability cost<br />
--&gt; 179 for chunk in iterable:<br />
180     fp.write(chunk)</p>
<p dir="auto">File /usr/local/lib/python3.10/json/encoder.py:429, in _make_iterencode.&lt;locals&gt;._iterencode(o, _current_indent_level)<br />
427     yield _floatstr(o)<br />
428 elif isinstance(o, (list, tuple)):<br />
--&gt; 429     yield from _iterencode_list(o, _current_indent_level)<br />
430 elif isinstance(o, dict):<br />
431     yield from _iterencode_dict(o, _current_indent_level)</p>
<p dir="auto">File /usr/local/lib/python3.10/json/encoder.py:325, in _make_iterencode.&lt;locals&gt;._iterencode_list(lst, _current_indent_level)<br />
323         else:<br />
324             chunks = _iterencode(value, _current_indent_level)<br />
--&gt; 325         yield from chunks<br />
326 if newline_indent is not None:<br />
327     _current_indent_level -= 1</p>
<p dir="auto">File /usr/local/lib/python3.10/json/encoder.py:405, in _make_iterencode.&lt;locals&gt;._iterencode_dict(dct, _current_indent_level)<br />
403         else:<br />
404             chunks = _iterencode(value, _current_indent_level)<br />
--&gt; 405         yield from chunks<br />
406 if newline_indent is not None:<br />
407     _current_indent_level -= 1</p>
<p dir="auto">File /usr/local/lib/python3.10/json/encoder.py:438, in _make_iterencode.&lt;locals&gt;._iterencode(o, _current_indent_level)<br />
436         raise ValueError("Circular reference detected")<br />
437     markers[markerid] = o<br />
--&gt; 438 o = _default(o)<br />
439 yield from _iterencode(o, _current_indent_level)<br />
440 if markers is not None:</p>
<p dir="auto">File /usr/local/lib/python3.10/json/encoder.py:179, in JSONEncoder.default(self, o)<br />
160 def default(self, o):<br />
161     """Implement this method in a subclass such that it returns<br />
162     a serializable object for <code>o</code>, or calls the base implementation<br />
163     (to raise a <code>TypeError</code>).<br />
(...)<br />
177<br />
178     """<br />
--&gt; 179     raise TypeError(f'Object of type {o.<strong>class</strong>.<strong>name</strong>} '<br />
180                     f'is not JSON serializable')</p>
<p dir="auto">TypeError: Object of type int64 is not JSON serializable</p>
<h1>thank you in advance for your help</h1>
]]></description><link>http://quantiacs.com/community/topic/523/errors-when-i-save-the-isssus-parameters-of-my-optimization-in-the-json-file</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Mar 2026 11:07:53 GMT</lastBuildDate><atom:link href="http://quantiacs.com/community/topic/523.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Feb 2024 07:18:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Errors when I save the isssus parameters of my optimization in the json file on Thu, 22 Feb 2024 05:40:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://quantiacs.com/community/uid/12">@support</a> Thank you for your advise, it's ok</p>
]]></description><link>http://quantiacs.com/community/post/1423</link><guid isPermaLink="true">http://quantiacs.com/community/post/1423</guid><dc:creator><![CDATA[dark.pidgeot]]></dc:creator><pubDate>Thu, 22 Feb 2024 05:40:02 GMT</pubDate></item><item><title><![CDATA[Reply to Errors when I save the isssus parameters of my optimization in the json file on Wed, 21 Feb 2024 07:53:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://quantiacs.com/community/uid/868">@dark-pidgeot</a> Hello, it seems json doesn't accept numpy data types, replacing <code>np.arange(10, 20, 1, dtype=int)</code> with <code>range(10,20,1)</code> in full_range_args_generator function input, should fix it.</p>
<p dir="auto">Regards,</p>
]]></description><link>http://quantiacs.com/community/post/1421</link><guid isPermaLink="true">http://quantiacs.com/community/post/1421</guid><dc:creator><![CDATA[support]]></dc:creator><pubDate>Wed, 21 Feb 2024 07:53:21 GMT</pubDate></item></channel></rss>