Emigon / fitkit

Python classes for terse signal processing algorithm development and testing
MIT License
0 stars 0 forks source link

Sympy and Pint compatability #1

Open Emigon opened 4 years ago

Emigon commented 4 years ago

This is not an issue with fitkit persay but it is something that we will need to deal with. Consider the following snippet:

import sympy as sp
t = sp.symbols('t')
y = t*ureg('1/s')

Now y has type Quantity as defined by pint. When we substitute values for t into ywe want t to have units of s so as to cancel with the constant of 1 with units of 1/s. However, if we do something like:

y.subs("t", ureg('s'))

we get

t

FitKit should allow users to specify expressions containing units (arising from constants) that will correctly cancel with substitution of parameters or free variables.

Emigon commented 4 years ago

Further, if we attempt to raise y to a power (say alpha) we get an error because pint doesn't know how to exponentiate units with sympy objects.