Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
ab0acc7a
Commit
ab0acc7a
authored
Oct 31, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix complex zero division testing.
parent
7dd76b30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-0
tests/run/complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+11
-15
No files found.
Cython/Compiler/ExprNodes.py
View file @
ab0acc7a
...
...
@@ -5536,6 +5536,7 @@ class CoercionNode(ExprNode):
# arg ExprNode node being coerced
subexprs
=
[
'arg'
]
constant_result
=
not_a_constant
def
__init__
(
self
,
arg
):
self
.
pos
=
arg
.
pos
...
...
tests/run/complex_numbers_T305.pyx
View file @
ab0acc7a
#cdef extern from "complex.h":
# pass
cimport
cython
def
test_object_conversion
(
o
):
...
...
@@ -23,21 +20,20 @@ def test_arithmetic(double complex z, double complex w):
((6+12j), (-6-12j), (6+15j), (6+9j), (-36+18j), (4-2j))
>>> test_arithmetic(5-10j, 3+4j)
((5-10j), (-5+10j), (8-6j), (2-14j), (55-10j), (-1-2j))
## XXX this is not working
## >>> test_div_by_zero(4j)
## -0.25j
## >>> test_div_by_zero(0)
## Traceback (most recent call last):
## ...
## ZeroDivisionError: float division
"""
return
+
z
,
-
z
,
z
+
w
,
z
-
w
,
z
*
w
,
z
/
w
## XXX this is not working
## @cython.cdivision(False)
## def test_div_by_zero(double complex z):
## return 1/z
@
cython
.
cdivision
(
False
)
def
test_div_by_zero
(
double
complex
z
):
"""
>>> test_div_by_zero(4j)
-0.25j
>>> test_div_by_zero(0)
Traceback (most recent call last):
...
ZeroDivisionError: float division
"""
return
1
/
z
def
test_coercion
(
int
a
,
float
b
,
double
c
,
float
complex
d
,
double
complex
e
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment