Commit fca0ac00 authored by J. Fernando Sánchez's avatar J. Fernando Sánchez

Merge branch '38-json-serialization-problem-with-sets'

parents 9a2932b5 24c97256
......@@ -140,7 +140,7 @@ class SenpyMixin(object):
vp = item[kp]
temp[kp] = ser_or_down(vp)
return temp
elif isinstance(item, list):
elif isinstance(item, list) or isinstance(item, set):
return list(ser_or_down(i) for i in item)
else:
return item
......@@ -184,7 +184,7 @@ class SenpyMixin(object):
jsonschema.validate(obj, self.schema)
def __str__(self):
return str(self.to_JSON())
return str(self.serialize())
class BaseModel(SenpyMixin, dict):
......
......@@ -181,6 +181,7 @@ class PluginsTest(TestCase):
"centroids_direction": ["emoml:big6", "emoml:fsre-dimensions"]
}
c = CentroidConversion(info)
print(c.serialize())
es1 = EmotionSet()
e1 = Emotion()
......@@ -189,6 +190,7 @@ class PluginsTest(TestCase):
res = c._forward_conversion(es1)
assert res["X-dimension"] == 0.5
assert res["Y-dimension"] == 0.5
print(res)
e2 = Emotion()
e2.onyx__hasEmotionCategory = "c2"
......@@ -196,12 +198,14 @@ class PluginsTest(TestCase):
res = c._forward_conversion(es1)
assert res["X-dimension"] == 0
assert res["Y-dimension"] == 1
print(res)
e = Emotion()
e["X-dimension"] = -0.2
e["Y-dimension"] = -0.3
res = c._backwards_conversion(e)
assert res["onyx:hasEmotionCategory"] == "c3"
print(res)
e = Emotion()
e["X-dimension"] = -0.2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment