You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Converting numpy float64 of python float to Decimal is not the same (get rounded in numpy case) #1833
I had to convert floats to Decimal but somehow the current Double I got out of Decimal when looking at it using ToDouble would give me only the round part of the double. I figured that my floats were not native python but numpy float64 . This issue happens only with numpy floats..
importclrfromSystemimportDecimalimportnumpyasnpd=45.5assertd==np.array([d])[0] # should be fineassertDecimal(d) ==Decimal(np.array([d])[0]) # assertion error
changed the title [-]Converting numpy float64 of python float to Decimal is rounding it[/-][+]Converting numpy float64 of python float to Decimal is not the same (get rounded in numpy case)[/+]on Jun 24, 2022
Python.NET 2.x permits all sorts of conversions in attempts to match the function arguments, some of which permit data loss. Please, try 3.0 previews of Python.NET. I believe 3.0 will tell you your Decimal(np.float64) call has no matching constructor overloads forcing you to explicitly convert np.float64 to either Python float or to System.Double first.
Also, to save time please add info about investigation from your side. E.g. in the example the equality of two decimals fails. What are their values at the time of comparison? Surely you checked before opening the bug.
Activity
[-]Converting numpy float64 of python float to Decimal is rounding it[/-][+]Converting numpy float64 of python float to Decimal is not the same (get rounded in numpy case)[/+]lostmsu commentedon Jun 24, 2022
Python.NET 2.x permits all sorts of conversions in attempts to match the function arguments, some of which permit data loss. Please, try 3.0 previews of Python.NET. I believe 3.0 will tell you your
Decimal(np.float64)call has no matching constructor overloads forcing you to explicitly convertnp.float64to either Pythonfloator toSystem.Doublefirst.Also, to save time please add info about investigation from your side. E.g. in the example the equality of two decimals fails. What are their values at the time of comparison? Surely you checked before opening the bug.
make sure positions sent to actuators are python float not numpy float
filmor commentedon Sep 20, 2022
This is fixed in rc6.