Skip to content
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

gh-69639: add mixed-mode rules for complex arithmetic (C-like) #124829

Merged
merged 29 commits into from
Nov 26, 2024
Merged
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3980363
gh-69639: add mixed-mode rules for complex arithmetic (C-like)
skirpichev Apr 23, 2024
46521c3
address review:
skirpichev Oct 2, 2024
1323f4d
Update Objects/complexobject.c
skirpichev Oct 2, 2024
5021a9b
address review: -> real_to_double
skirpichev Oct 2, 2024
c7308ef
Add _Py_cd_* and _Py_dc_* functions
skirpichev Oct 2, 2024
ee1aa01
+ what's new
skirpichev Oct 2, 2024
da566dd
+ trying to document new coersion rules in the reference
skirpichev Oct 2, 2024
714b731
address review: expressions.rst
skirpichev Oct 3, 2024
7a04eb0
address review: reword what's new
skirpichev Oct 3, 2024
1d42c10
cleanup: just one macro
skirpichev Oct 4, 2024
d6e9d14
renamed c-api helpers: _dc_ -> _rc_ and _cd_ -> _cr_
skirpichev Oct 6, 2024
2db0072
1d42c10202 +1
skirpichev Oct 6, 2024
46bed69
+ tests for semi-private C-API
skirpichev Oct 6, 2024
d6e4504
Merge branch 'master' into complex-float-arith-69639
skirpichev Oct 6, 2024
cc298e5
Apply suggestions from code review
skirpichev Oct 8, 2024
ee22926
Apply suggestions from code review
skirpichev Oct 13, 2024
220c551
Apply suggestions from code review
skirpichev Oct 14, 2024
f068384
Apply suggestions from code review
skirpichev Oct 14, 2024
8cdd514
Merge branch 'main' into complex-float-arith-69639
skirpichev Oct 30, 2024
7fb1be1
+ move news
skirpichev Oct 30, 2024
badf492
address review:
skirpichev Oct 31, 2024
3ef5287
Merge branch 'master' into complex-float-arith-69639
skirpichev Oct 31, 2024
38762b3
address review: rename symbols in commentary to avoid clash with macro
skirpichev Oct 31, 2024
e685bd9
Update Objects/complexobject.c
skirpichev Oct 31, 2024
76bad15
Merge branch 'main' into complex-float-arith-69639
skirpichev Nov 19, 2024
de5f353
Merge branch 'master' into complex-float-arith-69639
skirpichev Nov 26, 2024
2b46a96
added sum() test
skirpichev Nov 26, 2024
759a6d0
Update Lib/test/test_builtin.py
serhiy-storchaka Nov 26, 2024
ed67dc2
I'LL NEVER USE WEB-EDITOR... I'LL NEVER USE WEB-EDITOR... I'LL NEVER …
skirpichev Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from test.support.import_helper import import_module
from test.support.os_helper import (EnvironmentVarGuard, TESTFN, unlink)
from test.support.script_helper import assert_python_ok
from test.support.testcase import ComplexesAreIdenticalMixin
from test.support.warnings_helper import check_warnings
from test.support import requires_IEEE_754
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -151,7 +152,7 @@ def map_char(arg):
def pack(*args):
return args

class BuiltinTest(unittest.TestCase):
class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
# Helper to check picklability
def check_iter_pickle(self, it, seq, proto):
itorg = it
Expand Down Expand Up @@ -1902,6 +1903,13 @@ def __getitem__(self, index):
self.assertEqual(sum(xs), complex(sum(z.real for z in xs),
sum(z.imag for z in xs)))

# test that sum() of complex and real numbers doesn't
# smash sign of imaginary 0
self.assertComplexesAreIdentical(sum([complex(1, -0.0), 1]),
serhiy-storchaka marked this conversation as resolved.
Show resolved Hide resolved
complex(2, -0.0))
self.assertComplexesAreIdentical(sum([complex(1, -0.0), 1.0]),
complex(2, -0.0))
serhiy-storchaka marked this conversation as resolved.
Show resolved Hide resolved

@requires_IEEE_754
@unittest.skipIf(HAVE_DOUBLE_ROUNDING,
"sum accuracy not guaranteed on machines with double rounding")
Expand Down
Loading