Draft: patches/python.py: support np longdouble in round
while checking why erp5_wendelin_drone:testWendelinDrones of Wendelin.UnitTest-Master-Py3
fail randomly with
ERROR: test_04_ScoreCalculation (erp5.component.test.erp5_version.testWendelinDrones.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "erp5://portal_components/test.erp5.testWendelinDrones", line 408, in test_04_ScoreCalculation
self.assertAlmostEqual((flight_dataframe["climb_rate_reciprocal"] + flight_dataframe["ground_speed_reciprocal"] + flight_dataframe["ASML_reciprocal"] + flight_dataframe["distance_reciprocal"]).item()/4,
File "/srv/slapgrid/slappart36/t/erq/shared/python3/151096980f1a8d8f1ab76ae85a60fc4e/lib/python3.10/unittest/case.py", line 890, in assertAlmostEqual
if round(diff, places) == 0:
File "/srv/slapgrid/slappart36/t/erq/soft/797f2d68aa0827eaef9d0f37795f7a2d/parts/erp5/product/ERP5Type/patches/python.py", line 210, in round2
d = _decimal.Decimal.from_float(number).quantize(
TypeError: argument must be int or float
i found it happens when there has difference between the first argument and second argument of assertAlmostEqual
in this case, the round
method is called, but since the type of second argument is longdouble
, the difference is also longdouble
but _decimal.Decimal.from_float(number)
doesn't support it, we get the TypeError
above at the end
to reproduce the error, we can simply run it with:
import numpy as np
x = np.longdouble("1.234567890123456789")
return round(x, 13)
which is no more supported in zope4py3
here is the proposition fix, but i have no idea if it's ok, i don't know too much about the context
@jerome what's your opinion ?