[docs]@staticmethoddefis_simple_type(t):"""returns if the type t is string or a number so that it does not use pickle if serialized"""returntinNumpyHelper.SIMPLE_TYPES
[docs]@staticmethoddefget_numpy_representation(obj):"""converts object to representation that can be stored without pickle enables in numpy arrays; if it is an object or a dict, it will be serialized to a json string"""ifobjisNone:return''eliftype(obj)inNumpyHelper.SIMPLE_TYPES:returnobjelifisinstance(obj,Enum):returnobj.nameelifnotisinstance(obj,dict)andnotisinstance(obj,list)andnotisinstance(obj,Enum):representation=vars(obj)else:representation=objreturnjson.dumps(representation,default=lambdax:x.nameifisinstance(x,Enum)elsestr(x))