Skip to content

VariableWriter does not import functions used in expr #99

Description

@schymans

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions