Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 141
    • Merge requests 141
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !2113

Open
Created Jun 03, 2025 by Xiaowu Zhang@xiaowu.zhangDeveloper
  • Report abuse
Report abuse

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

  • Overview 2
  • Commits 1
  • 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
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: py3
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7