Skip to content

Commit

Permalink
inheritance of ints
Browse files Browse the repository at this point in the history
  • Loading branch information
prismofeverything committed Aug 20, 2024
1 parent 20a1321 commit c09ed2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions bigraph_schema/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,9 +1351,14 @@ def find(self, schema):
key: self.access(branch)
for key, branch in schema.items()}

elif isinstance(schema, (tuple, int)):
if isinstance(schema, int):
schema = tuple([schema])
elif isinstance(schema, int):
return schema

elif isinstance(schema, tuple):
# import ipdb; ipdb.set_trace()

# if isinstance(schema, int):
# schema = tuple([schema])

tuple_schema = {
'_type': 'tuple',
Expand Down
12 changes: 10 additions & 2 deletions bigraph_schema/type_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,13 @@ def inherits_from(self, descendant, ancestor):
if descendant is None:
return ancestor is None

if '_type' in ancestor and ancestor['_type'] == 'any':
if isinstance(ancestor, int):
if isinstance(descendant, int):
return ancestor == descendant
else:
return False

elif '_type' in ancestor and ancestor['_type'] == 'any':
return True

elif '_type' in descendant:
Expand Down Expand Up @@ -2112,7 +2118,7 @@ def serialize_map(schema, value, core=None):
return {
key: core.serialize(
value_type,
subvalue)
subvalue) if not is_schema_key(key) else subvalue
for key, subvalue in value.items()}


Expand Down Expand Up @@ -2349,6 +2355,8 @@ def serialize_array(schema, value, core):

if isinstance(value, dict):
return value
elif isinstance(value, str):
import ipdb; ipdb.set_trace()
else:
array_data = 'string'
dtype = value.dtype.name
Expand Down

0 comments on commit c09ed2d

Please sign in to comment.