connorferster / forallpeople

Python SI units library: your 'daily driver' for calculations.
Apache License 2.0
272 stars 38 forks source link

Multiply between physical and numpy array gives truth value error #89

Open joshstructure opened 10 months ago

joshstructure commented 10 months ago

I get an error when I multiply a value with units with a numpy array. So say (4ft) Width where width is a numpy array. I get the error "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()" What's weird is that if I reverse the expression I do not get the error -- Width (4ft). I've tested it out a bit and you can cast the physical to a numpy array and it works or as long as the array comes before the physical in any multiplication statement it works. This is not ideal though because I dont want to clutter up my math equations with a bunch of np.array()'s nor do I want people I give my calcs to to get errors if they adjust the equations and didn't know about the "put the array first" quirk. Is there a quick fix for this?