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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
5329d55d
Commit
5329d55d
authored
May 14, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complex numbers tests
parent
8af9a568
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
tests/run/complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+84
-0
No files found.
tests/run/complex_numbers_T305.pyx
0 → 100644
View file @
5329d55d
__doc__
=
u"""
>>> test_object_conversion(2)
(2+0j)
>>> test_object_conversion(2j - 0.5)
(-0.5+2j)
>>> test_arithmetic(2j, 4j)
(6j, -2j, (-8+0j), (0.5+0j))
>>> test_arithmetic(6+12j, 3j)
((6+15j), (6+9j), (-36+18j), (4-2j))
>>> test_arithmetic(5-10j, 3+4j)
((8-6j), (2-14j), (55-10j), (-1-2j))
>>> test_div_by_zero(4j)
-0.25j
>>> test_div_by_zero(0)
Traceback (most recent call last):
...
ZeroDivisionError: float division
>>> test_coercion(1, 1.5, 2.5, 4+1j, 10j)
(1+0j)
(1.5+0j)
(2.5+0j)
(4+1j)
10j
(9+21j)
>>> test_compare(3, 3)
(True, False)
>>> test_compare(3j, 3j)
(True, False)
>>> test_compare(3j, 4j)
(False, True)
>>> test_compare(3, 4)
(False, True)
>>> test_compare_coerce(3, 4)
(False, True)
>>> test_compare_coerce(4+1j, 4)
(False, True)
>>> test_compare_coerce(4, 4)
(True, False)
>>> test_literal()
(5j, (1-2.5j))
"""
#cdef extern from "complex.h":
# pass
cimport
cython
def
test_object_conversion
(
o
):
cdef
float
complex
a
=
o
cdef
double
complex
z
=
o
return
z
def
test_arithmetic
(
double
complex
z
,
double
complex
w
):
return
z
+
w
,
z
-
w
,
z
*
w
,
z
/
w
@
cython
.
cdivision
(
False
)
def
test_div_by_zero
(
double
complex
z
):
return
1
/
z
def
test_coercion
(
int
a
,
float
b
,
double
c
,
float
complex
d
,
double
complex
e
):
cdef
double
complex
z
z
=
a
;
print
z
z
=
b
;
print
z
z
=
c
;
print
z
z
=
d
;
print
z
z
=
e
;
print
z
return
z
+
a
+
b
+
c
+
d
+
e
def
test_compare
(
double
complex
a
,
double
complex
b
):
return
a
==
b
,
a
!=
b
def
test_compare_coerce
(
double
complex
a
,
int
b
):
return
a
==
b
,
a
!=
b
def
test_literal
():
return
5j
,
1
-
2.5j
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