Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok, so I'm doing fine with pint with one exception: When I define a symbolic expression and then try to evaluate that expression using variables that have units. For example, I define a symbolic expression:

Vres(Vref,RES)=2*Vref/2^RES

And I try to evaluate it using a pint variable (with units I defined):

Vres(5*u.V, 20)

I get a type error:

TypeError: no canonical coercion from <class 'pint.quantity.build_quantity_class.<locals>.Quantity'> to Callable function ring with arguments (Vref, RES)

I guess this makes sense because how would the symbolic expression class know what to do with a pint type variable? Which brings me back to the built-in units with SageMath. With built-in "units" class, symbolic expressions are fine, but I can't add my own custom units so I'm stuck... I desperately need units like V, nV, uV, mV, and nV/sqrt(Hz).