environmentalscience / essm

This package contains helpers to deal with physical variables and units.
https://environmentalscience.github.io/essm/
GNU General Public License v2.0
12 stars 5 forks source link

Bug: Not possible to import only single variable or equation #81

Open schymans opened 4 years ago

schymans commented 4 years ago

For some reason, from essm.variables.physics.thermodynamics import lambda_E not only imports lambda_E but also all other variables in that module. This looks like a bug.

schymans commented 3 years ago

Actually, from essm.variables.physics.thermodynamics import lambda_E only imports lambda_E, but all other variables in the same module are added to Variable.__registry__, and then show up when using generate_metadata_table (see #97). Example:

from essm.variables import Variable
from essm.variables.utils import generate_metadata_table
class var1(Variable):
    """Test variable"""
print(Variable.__registry__)
from essm.variables.physics.thermodynamics import lambda_E
print(Variable.__registry__)

The first print command correctly only returns var1, but the second returns all variables from the thermodynamics module. @jirikuncar, do you know how to fix this?