-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pow ^
does not compile when using unchained
#7
Comments
Speaking of power operator, I think there should also be this version proc `**`*[T: FloatLike](m: FloatLike, p: Measurement[T]): Measurement[T] =` |
actually, it doesn't work even without units import unchained
import measuremancer
let
u = 2.1 ± 0.5
z = 1.2 ± 0.3
echo u**z measuremancer.nim(315, 31) Error: type mismatch: got <float>
but expected one of:
func log[T: SomeFloat](x, base: T): T
first type mismatch at position: 2
missing parameter: base math.log wants second |
I need to add that the more I read the code (to hopefully grasp how to create a PR) the more I understand the complexity of |
I've been following the white rabbit until I've decided to properly turn it into tests |
I'm trying some fixes in my fork a5f0689#diff-c3e2bf281e6b65db974cf236911d68cb47f1f0a14bb0029e5354e573fc2da0eb I fixed power & exponentials when not using unchained (comparing results with vs python Python Pint handles them at runtime using strings from pint import UnitRegistry
ureg = UnitRegistry()
distance = 24.0 * ureg.meter
print(repr(distance ** 12.5))
print(repr(distance ** distance)) Unchained hates this to live at compile life <Quantity(1.78912433e+17, 'meter ** 12.5')>
Traceback (most recent call last):
pint.errors.DimensionalityError: Cannot convert from 'meter' to 'dimensionless' import unchained
echo pow(5.m, 4.2) Error: type mismatch: got <Meter, float64>
but expected one of:
func pow(x, y: float32): float32
first type mismatch at position: 1
required type for x: float32
but expression 'm(5)' is of type: Meter
func pow(x, y: float64): float64
first type mismatch at position: 1
required type for x: float64
but expression 'm(5)' is of type: Meter
expression: pow(m(5), 4.2) should I consider units as base or exponent of power/exponential a compile error? |
Float based exponents simply don't make sense with units attached! What's a 5.kg^{2.3} ? The same is true for trigonometric functions. Their argument must be Haven't had time to properly look yet, sorry. |
No need to be sorry, you wrapped up an amazing system. I just need some time to wrap my head around all of this |
Closing this, as it should be addressed in version |
The text was updated successfully, but these errors were encountered: