Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • erp5 erp5
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Merge requests 142
    • Merge requests 142
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedinexedi
  • erp5erp5
  • Merge requests
  • !2113

Draft: patches/python.py: support np longdouble in round

  • Review changes

  • Download
  • Patches
  • Plain diff
Closed Xiaowu Zhang requested to merge xiaowu.zhang/erp5:py3 into zope4py3 Jun 03, 2025
  • Overview 2
  • Commits 1
  • Pipelines 0
  • Changes 1

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 ?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: py3
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7