forallpeople
forallpeople copied to clipboard
Using sqrt with units and .prefix() causes problems
I am using the following lambda
function to apply sqrt
to variables with units:
sqrt = lambda x: x.sqrt()
This works very well until I force the units using .prefix('something')
on the variables used inside the sqrt
function:
super(Physical, self).__setattr__("value", float(value))
^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'complex'
Is there a way to circumvent this problem or a better approach to ensure sqrt
works with prefixed units?
Thank you for your help!