-
Notifications
You must be signed in to change notification settings - Fork 5
Import Value, input_float, input_value from core #3
Conversation
blmath/util/json.py
Outdated
super(BlmathJSONDecoder, self).__init__() | ||
self.register(self.decode_supported_types) | ||
|
||
def decode_supported_types(self, dct): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied over from core
bodylabs.serialization.json
and I believe can be deleted from core
as part of the removal of measurements
since the only SUPPORTED_TYPE
is Value
, which is now part of blmath
.
blmath/util/json.py
Outdated
@@ -0,0 +1,46 @@ | |||
''' | |||
If an object defines for_json(), it will be serialized as what that returns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment probably makes most sense in Haiti-serialization.
blmath/util/json.py
Outdated
super(BlmathJSONDecoder, self).__init__() | ||
self.register(self.decode_supported_types) | ||
|
||
def decode_supported_types(self, dct): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's clean this up some, since it's just Value
:
from blmath.value import Value
def decode_value(self, dct):
if "__value__" in dct.keys():
return Value.from_json(dct)
We can leave it as is in core, so we have the example for the future and so that bodylabs.serialization.json
continues to handle values as advertised. But here in measurements, let's be nice and simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done -- also removed a test for an error that the simplified decoder doesn't worry about.
blmath/test_value.py
Outdated
x_str = json.dumps({'__value__': {'value': 25.0, 'units': 'cm'}, 'foo': 'bar'}) | ||
with self.assertRaises(TypeError): | ||
json.loads(x_str) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed test because we no longer raise this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
35228e5
to
a0e4b0b
Compare
Initially moved here to support extracting
measurements
fromcore
, although the dependent code will likely be removed frommeasurements
.If we still want these moved into
blmath
we can merge this -- otherwise we could just leave them in core.