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
def__get_dtype(typespec):
'''Get the dtype associated with a jsonschema type definition Parameters ---------- typespec : dict The schema definition Returns ------- dtype : numpy.dtype The associated dtype '''if'type'intypespec:
ifisinstance(typespec['type'], (list, tuple)):
# get dtype for each type in listtypes= [__TYPE_MAP__.get(t, np.object_) fortintypespec['type']]
# If they're not all equal, return objectifall([t==types[0] fortintypes]):
returntypes[0]
returnnp.object_else:
return__TYPE_MAP__.get(typespec['type'], np.object_)
elif'enum'intypespec:
# Enums map to objectsreturnnp.object_elif'oneOf'intypespec:
# Recursetypes= [__get_dtype(v) forvintypespec['oneOf']]
# If they're not all equal, return objectifall([t==types[0] fortintypes]):
returntypes[0]
returnnp.object_
The text was updated successfully, but these errors were encountered:
beasteers
changed the title
schema.__get_dtype fails when isinstance("type", list)
__get_dtype fails when type is list
Sep 4, 2019
This is relevant for scaper's schema e.g.:
It should be handled similar to
oneOf
:The text was updated successfully, but these errors were encountered: