You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a numpy function that returns a numpy boolean such as np.all() is used, such as in A3Part3 where isRealEven is calculated and returned, the JSON serialization in submit.py will fail with the error:
Traceback (most recent call last):
File "submitA3.py", line 309, in <module>
submit()
File "submitA3.py", line 56, in submit
rep = submitSolution(email, password, output(partIdx), partIdx)
File "submitA3.py", line 274, in output
outputString += convertNpObjToStr(ans) + '\n'
File "submitA3.py", line 209, in convertNpObjToStr
return json.dumps(obj)
File "/home/.../.pyenv/versions/2.7.13/lib/python2.7/json/__init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "/home/.../.pyenv/versions/2.7.13/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/home/.../.pyenv/versions/2.7.13/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/home/.../.pyenv/versions/2.7.13/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: True is not JSON serializable
One workaround seems to be to convert isRealEven to a Python bool with isRealEven = bool(np.all(...)).
The text was updated successfully, but these errors were encountered:
If a numpy function that returns a numpy boolean such as
np.all()
is used, such as in A3Part3 whereisRealEven
is calculated and returned, the JSON serialization insubmit.py
will fail with the error:One workaround seems to be to convert
isRealEven
to a Python bool withisRealEven = bool(np.all(...))
.The text was updated successfully, but these errors were encountered: