Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VariableWriter does not import functions used in expr #99

Open
schymans opened this issue Jun 18, 2021 · 0 comments
Open

VariableWriter does not import functions used in expr #99

schymans opened this issue Jun 18, 2021 · 0 comments

Comments

@schymans
Copy link
Collaborator

If I define an expression in a variable definition, VariableWriter does not import it automatically and it has to be added manually as supplementary_imports. In https://github.com/environmentalscience/essm/blob/master/docs/examples/api_features.ipynb, In[14], the following definition was made:

class Delta_Pwa(Variable):
    """Slope of saturated vapour pressure, $\partial P_{wa} / \partial T_g$"""
    expr = Derivative(P_wa,T_g)
    latex_name = r'\Delta'

However, Derivative is not imported when executing:

writer_var = VariableWriter(docstring='Test of VariableWriter.')
writer_var.var(Delta_Pwa)

This is because extract_functions() in https://github.com/environmentalscience/essm/blob/master/essm/_generator.py is only used in EquationWriter but not in VariableWriter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant