generic Transform(json=) instantiation
Closed this issue · 1 comments
djkapner commented
It would be nice to be able to load a transform from a dict without knowing its exact class ahead of time. But, not all the methods come through. Needs something fancier for it to become the correct object:
> r = renderapi.transform.AffineModel()
> np.array([name for name in dir(r) if callable(getattr(r, name))])
array(['__class__', '__delattr__', '__dir__', '__eq__', '__format__',
'__ge__', '__getattribute__', '__gt__', '__hash__', '__init__',
'__init_subclass__', '__le__', '__lt__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', '_process_dataString',
'calc_properties', 'concatenate', 'convert_points_vector_to_array',
'convert_to_point_vector', 'estimate', 'fit', 'from_dict',
'inverse_tform', 'invert', 'load_M', 'tform', 'to_dict'],
dtype='<U30')
but:
> f = renderapi.transform.Transform(json=r.to_dict())
> np.array([name for name in dir(f) if callable(getattr(f, name))])
array(['__class__', '__delattr__', '__dir__', '__eq__', '__format__',
'__ge__', '__getattribute__', '__gt__', '__hash__', '__init__',
'__init_subclass__', '__le__', '__lt__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', '_process_dataString',
'from_dict', 'to_dict'], dtype='<U19')
djkapner commented
I see renderapi.transform.load_transform_json()
does this