Closed rbyh closed 3 months ago
Unexpected behavior for results.shuffle():
Unexpected behavior for results.sample(n):
Shuffle method changes results unexpectedly:
results.shuffle()
Error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File [~/edsl/.venv/lib/python3.11/site-packages/IPython/core/formatters.py:344](http://localhost:8888/lab/tree/~/edsl/.venv/lib/python3.11/site-packages/IPython/core/formatters.py#line=343), in BaseFormatter.__call__(self, obj)
342 method = get_real_method(obj, self.print_method)
343 if method is not None:
--> 344 return method()
345 return None
346 else:
File [~/edsl/edsl/results/Dataset.py:44](http://localhost:8888/lab/tree/~/edsl/edsl/results/Dataset.py#line=43), in Dataset._repr_html_(self)
41 """Return an HTML representation of the dataset."""
42 from edsl.utilities.utilities import data_to_html
---> 44 return data_to_html(self.data)
File [~/edsl/edsl/utilities/utilities.py:23](http://localhost:8888/lab/tree/~/edsl/edsl/utilities/utilities.py#line=22), in data_to_html(data, replace_new_lines)
22 def data_to_html(data, replace_new_lines=False):
---> 23 json_str = json.dumps(data, indent=4)
24 formatted_json = highlight(
25 json_str,
26 JsonLexer(),
27 HtmlFormatter(style="default", full=False, noclasses=False),
28 )
29 if replace_new_lines:
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/__init__.py:238](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/__init__.py#line=237), in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
232 if cls is None:
233 cls = JSONEncoder
234 return cls(
235 skipkeys=skipkeys, ensure_ascii=ensure_ascii,
236 check_circular=check_circular, allow_nan=allow_nan, indent=indent,
237 separators=separators, default=default, sort_keys=sort_keys,
--> 238 **kw).encode(obj)
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:202](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=201), in JSONEncoder.encode(self, o)
200 chunks = self.iterencode(o, _one_shot=True)
201 if not isinstance(chunks, (list, tuple)):
--> 202 chunks = list(chunks)
203 return ''.join(chunks)
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:430](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=429), in _make_iterencode.<locals>._iterencode(o, _current_indent_level)
428 yield _floatstr(o)
429 elif isinstance(o, (list, tuple)):
--> 430 yield from _iterencode_list(o, _current_indent_level)
431 elif isinstance(o, dict):
432 yield from _iterencode_dict(o, _current_indent_level)
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:326](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=325), in _make_iterencode.<locals>._iterencode_list(lst, _current_indent_level)
324 else:
325 chunks = _iterencode(value, _current_indent_level)
--> 326 yield from chunks
327 if newline_indent is not None:
328 _current_indent_level -= 1
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:406](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=405), in _make_iterencode.<locals>._iterencode_dict(dct, _current_indent_level)
404 else:
405 chunks = _iterencode(value, _current_indent_level)
--> 406 yield from chunks
407 if newline_indent is not None:
408 _current_indent_level -= 1
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:326](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=325), in _make_iterencode.<locals>._iterencode_list(lst, _current_indent_level)
324 else:
325 chunks = _iterencode(value, _current_indent_level)
--> 326 yield from chunks
327 if newline_indent is not None:
328 _current_indent_level -= 1
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:439](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=438), in _make_iterencode.<locals>._iterencode(o, _current_indent_level)
437 raise ValueError("Circular reference detected")
438 markers[markerid] = o
--> 439 o = _default(o)
440 yield from _iterencode(o, _current_indent_level)
441 if markers is not None:
File [~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:180](http://localhost:8888/lab/tree/~/.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py#line=179), in JSONEncoder.default(self, o)
161 def default(self, o):
162 """Implement this method in a subclass such that it returns
163 a serializable object for ``o``, or calls the base implementation
164 (to raise a ``TypeError``).
(...)
178
179 """
--> 180 raise TypeError(f'Object of type {o.__class__.__name__} '
181 f'is not JSON serializable')
TypeError: Object of type Prompt is not JSON serializable
Latest commits should fix this.
All models w/o
None
were runnable