forallpeople icon indicating copy to clipboard operation
forallpeople copied to clipboard

Using sqrt with units and .prefix() causes problems

Open cream68 opened this issue 4 months ago • 0 comments

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!

cream68 avatar Oct 18 '24 08:10 cream68