Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def root_to_numpy(base_object, field_name, attributes):
- """Convert objects stored in base_object.field_name to numpy array
- Will query attributes for each of the objects in base_object.field_name
- No, root_numpy does not do this for you, that's for trees...
- """
- objects_to_convert = getattr(base_object, field_name)
- if not len(objects_to_convert):
- return None
- return np.array([tuple([getattr(p, pa) for pa in attributes]) for p in objects_to_convert])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement