Hosted by CoCalc
Download
Kernel: SageMath 9.8
f = hypergeometric((3/2,), (5/2, 3), -1/4*3^2)
f
hypergeometric((3/2,), (5/2, 3), -9/4)
parent(f)
Symbolic Ring
# this does work, but this sort of thing hardly works for anything # in sage, by design. But luckily here it does: sage_eval(str(f)) == f
hypergeometric((3/2,), (5/2, 3), -9/4) == hypergeometric((3/2,), (5/2, 3), -9/4)
# loads and dumps uses pickle to do the map (sage thing) --dumps--> string --loads--> (sage thing) loads(dumps(f)) == f
hypergeometric((3/2,), (5/2, 3), -9/4) == hypergeometric((3/2,), (5/2, 3), -9/4)
# this uses pickle, a binary format, this big and ugly though: dumps(f)
b'x\x9cm\x8fAO\xc2@\x10\x85\x87\x16\n\xac\xa8\xf1\xc8\xc9\x83\x17%\xb1$ \x07\xd2p@\x83\x10\x10\x12AC%1MY\xd6Rl\xb7\xdd\xee\x16\xe8M\x0f\xea_\xf4\xe7\xd8*hH<\xcd\xcc\x977\xf3\xde\xbcH\x98\x9b\x16Q\xb9\x08B,\xc2\x80\xa8\xb3\x88\x9a\xae\x8d\r\xec\x98\x9c\xa3\xdd\x89\xc1\xa9~\x0c\x00\xad\xb5\x1f\x10\xcem\x8f\x1a+[\xcc\x8d\xad\xca%b\xee\xcd8Km\x8eF\xee\xd4sl\xac\x92_=\xfa[ELzc26\x8cih;\xc2\xa6\x86\x81,"L!\x02\xc4\xd2?\x07\x9eB\x8aE,\xe5\xea<\xf2I`\x11/v\x08l\x8c:\xbb#\xcb\xe8GI\xac\xa5\xe9\x84f\xb2\xd0\xdf\x04Q\xdeYv\xc8r\x83\x81`\xf9!Cg\xafl\xaf\x07\x8f\xac\xa0\x7f\xc6\xf2vsx%\x1fn=\xe0\xfbEH\xa2r\xc2\xe0\x0e\xaa\xe5\n\x8c\x80\x86.\x89- a\xb5\x98T\xe1\xbc^\xbe\x00?\x8a\r(X\xcd\xee\x02W\xae\xe9dTsg\xe3\xdab\xd6v\x96S\xda\x0f\xcd\x8e\xb3\x9a\xe8]:\x19\xd7\xc5D\x1fF\xe6\xb8\xdf\x1b\xfd\xc3\xf0m\xd3\xbf\xa7\xad\xcb\x1b\xab\xd1\x00\xdf\xc6\xcf\x0e\x81\xe4s\x83\xac!u\xa0d\xe5b\xba\x94F\x8a\x84$\r\x92>\x87\x14\xb9\x98*\xe5\xe3\x12#I\x93\x13\x88\x90\xa2 \xd0RZZ\xcb<\x9c,\nl\xff\x83\x1dL\xd5/,\x93\x93d'
# I wish we had a similar conversion to and from JSON in general, but we don't. import json json.dumps(f)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In [16], line 3 1 # I wish we had a similar conversion to and from JSON in general, but we don't. 2 import json ----> 3 json.dumps(f)
File /ext/sage/9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/json/__init__.py:231, in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw) 226 # cached encoder 227 if (not skipkeys and ensure_ascii and 228 check_circular and allow_nan and 229 cls is None and indent is None and separators is None and 230 default is None and not sort_keys and not kw): --> 231 return _default_encoder.encode(obj) 232 if cls is None: 233 cls = JSONEncoder
File /ext/sage/9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/json/encoder.py:200, in JSONEncoder.encode(self, o) 196 return encode_basestring(o) 197 # This doesn't pass the iterator directly to ''.join() because the 198 # exceptions aren't as detailed. The list call should be roughly 199 # equivalent to the PySequence_Fast that ''.join() would do. --> 200 chunks = self.iterencode(o, _one_shot=True) 201 if not isinstance(chunks, (list, tuple)): 202 chunks = list(chunks)
File /ext/sage/9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/json/encoder.py:258, in JSONEncoder.iterencode(self, o, _one_shot) 253 else: 254 _iterencode = _make_iterencode( 255 markers, self.default, _encoder, self.indent, floatstr, 256 self.key_separator, self.item_separator, self.sort_keys, 257 self.skipkeys, _one_shot) --> 258 return _iterencode(o, 0)
File /ext/sage/9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/json/encoder.py:180, 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 Expression_with_dynamic_methods is not JSON serializable