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

I got “NameError: name 'NDict' is not defined” from ndict.py, how can I fix it #322

Closed Betty-J closed 1 year ago

Betty-J commented 1 year ago
截屏2023-06-16 下午3 52 08
SagiPolaczek commented 1 year ago

Hey 👋 Thanks for reaching out!

Did you install the package in editable mode (pip install -e .)? You can view the installation section here I wasn't able to reproduce it locally using VSCode, even with a blank conda env & uninstalled package..

Generally speaking, it can be solved using forward passing. For this example the following should work:

class NDict(dict):
    """
    (Lazy) N(ested)Dict - wraps a python dict, and allows to access "nested" elements via '.' separated key desc ...
    """

    def __init__(
        self, dict_like: Union[dict, tuple, types.GeneratorType, 'NDict', None] = None, already_flat: bool = False
    ):
mosheraboh commented 1 year ago

@weiddyaqhhya , any chance you are using python version < 3.7?

Betty-J commented 1 year ago

@weiddyaqhhya , any chance you are using python version < 3.7?

Hi,you are right, the python version I am using is 3.6.13

Hey 👋 Thanks for reaching out!

Did you install the package in editable mode (pip install -e .)? You can view the installation section here I wasn't able to reproduce it locally using VSCode, even with a blank conda env & uninstalled package..

Generally speaking, it can be solved using forward passing. For this example the following should work:

class NDict(dict):
    """
    (Lazy) N(ested)Dict - wraps a python dict, and allows to access "nested" elements via '.' separated key desc ...
    """

    def __init__(
        self, dict_like: Union[dict, tuple, types.GeneratorType, 'NDict', None] = None, already_flat: bool = False
    ):

hi, I installed using pypi pip install fuse-med-ml[all], I will try your solution, thanks

SagiPolaczek commented 1 year ago

@weiddyaqhhya There's no need for the fix I've mentioned. Update your python version to 3.9 (we don't support <3.7) and try again. See here

@mosheraboh nice catch!! :)