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
Ive been using Munch and i love it, but i am missing a Munch numpy implementation.
what i have been doing recently is checking recursively all munches related to possible lists. When it finds a list it gets converted to numpy.
This is quite helpful for me, idk if is there a method that i have missed, but it is something that could be useful to the repo as a flag, such as lists2numpy when creating the munch.
def convert_YAML2Struct(self, yaml):
data = DefaultMunch.fromDict(yaml)
for name in dir(data):
current_key = getattr(data, name)
setattr(data, name, self.check_munch_key(current_key))
setattr(self, name, getattr(data, name))
def check_munch_key(self, current_key):
for i in dir(current_key):
if isinstance(getattr(current_key, i), list):
setattr(current_key, i, np.array(getattr(current_key, i)))
elif isinstance(getattr(current_key, i), munch.DefaultMunch):
setattr(current_key, i, self.check_munch_key(getattr(current_key, i)))
return current_key
Best Regards,
Yuri
The text was updated successfully, but these errors were encountered:
Hi,
Ive been using Munch and i love it, but i am missing a Munch numpy implementation.
what i have been doing recently is checking recursively all munches related to possible lists. When it finds a list it gets converted to numpy.
This is quite helpful for me, idk if is there a method that i have missed, but it is something that could be useful to the repo as a flag, such as lists2numpy when creating the munch.
Best Regards,
Yuri
The text was updated successfully, but these errors were encountered: