ukhsa-collaboration / pygom

ODE modelling in Python
GNU General Public License v2.0
27 stars 20 forks source link

Typesetting of equations in Jupyter notebook #27

Open hareball90 opened 5 years ago

hareball90 commented 5 years ago

Can you add a function like this to improve viewing of equations within Jupyter notebooks?

def print_ode2(self): ''' Prints the ode in symbolic form onto the screen/console in actual symbols rather than the word of the symbol.

    Based on the PyGOM built-in but adapted for Jupyter
    '''
    A = self.get_ode_eqn()
    B = sympy.zeros(A.rows,2)
    for i in range(A.shape[0]):
        B[i,0] = sympy.symbols('d' + str(self._stateList[i]) + '/dt=')
        B[i,1] = A[i]

    return B
twomagpi commented 5 years ago

We should probably revisit the __str__ and __repr__ functions of the BaseOdeModel object.

__str__ should probably return something like the above while __repr__ should return, close to, Python code to create the object.

I'm not currently sure how these get set but suspect the _get_model_str function is involved