BiomedSciAI / fuse-med-ml

A python framework accelerating ML based discovery in the medical field by encouraging code reuse. Batteries included :)
Apache License 2.0
134 stars 34 forks source link

NDict API change - missing pre-existing features #273

Closed avihu111 closed 1 year ago

avihu111 commented 1 year ago

NDict API has changed: NDict.keys() now returns leaf, not children. Same change goes for .items() and .values()

Can you add the "top_level" functionality for .items() and .values()?

Thanks!

avihu111 commented 1 year ago

suggested code - without tests/examples/type-hinting:

    def top_level_items(self):
        return {k: self[k] for k in self.top_level_keys()}

    def top_level_values(self):
        return [self[k] for k in self.top_level_keys()]
avihu111 commented 1 year ago

Actually, you can just use:

NDict.flatten()

and then use:

NDict.values()
NDict.items()