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
b702b864
Commit
b702b864
authored
Nov 01, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not depend on dict serialisation order in doctest
parent
43bf890e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
8 deletions
+30
-8
tests/run/carray_coercion.pyx
tests/run/carray_coercion.pyx
+30
-8
No files found.
tests/run/carray_coercion.pyx
View file @
b702b864
...
...
@@ -266,16 +266,27 @@ cdef struct StructWithArray:
def
to_struct_with_array
(
x
):
"""
>>> to_struct_with_array([
>>>
x, y =
to_struct_with_array([
... {'a': 11, 'b': [{'x': 12, 'y': 13}, {'x': 14, 'y': 15}]},
... {'a': 21, 'b': [{'x': 22, 'y': 23}, {'x': 24, 'y': 25}]},
... ])
[{'a': 11, 'b': [{'y': 13.0, 'x': 12}, {'y': 15.0, 'x': 14}]}, {'a': 21, 'b': [{'y': 23.0, 'x': 22}, {'y': 25.0, 'x': 24}]}]
>>> to_struct_with_array(iter([
>>> x['a'], y['a']
(11, 21)
>>> sorted(v.items() for v in x['b'])
[[('y', 13.0), ('x', 12)], [('y', 15.0), ('x', 14)]]
>>> sorted(v.items() for v in y['b'])
[[('y', 23.0), ('x', 22)], [('y', 25.0), ('x', 24)]]
>>> x, y = to_struct_with_array(iter([
... {'a': 11, 'b': iter([{'x': 12, 'y': 13}, {'x': 14, 'y': 15}])},
... {'a': 21, 'b': iter([{'x': 22, 'y': 23}, {'x': 24, 'y': 25}])},
... ]))
[{'a': 11, 'b': [{'y': 13.0, 'x': 12}, {'y': 15.0, 'x': 14}]}, {'a': 21, 'b': [{'y': 23.0, 'x': 22}, {'y': 25.0, 'x': 24}]}]
>>> x['a'], y['a']
(11, 21)
>>> sorted(v.items() for v in x['b'])
[[('y', 13.0), ('x', 12)], [('y', 15.0), ('x', 14)]]
>>> sorted(v.items() for v in y['b'])
[[('y', 23.0), ('x', 22)], [('y', 25.0), ('x', 24)]]
"""
cdef
StructWithArray
[
2
]
v
v
=
x
...
...
@@ -284,16 +295,27 @@ def to_struct_with_array(x):
def
to_struct_with_array_slice
(
x
):
"""
>>> to_struct_with_array_slice([
>>>
x, y =
to_struct_with_array_slice([
... {'a': 11, 'b': [{'x': 12, 'y': 13}, {'x': 14, 'y': 15}]},
... {'a': 21, 'b': [{'x': 22, 'y': 23}, {'x': 24, 'y': 25}]},
... ])
[{'a': 11, 'b': [{'y': 13.0, 'x': 12}, {'y': 15.0, 'x': 14}]}, {'a': 21, 'b': [{'y': 23.0, 'x': 22}, {'y': 25.0, 'x': 24}]}]
>>> to_struct_with_array_slice(iter([
>>> x['a'], y['a']
(11, 21)
>>> sorted(v.items() for v in x['b'])
[[('y', 13.0), ('x', 12)], [('y', 15.0), ('x', 14)]]
>>> sorted(v.items() for v in y['b'])
[[('y', 23.0), ('x', 22)], [('y', 25.0), ('x', 24)]]
>>> x, y = to_struct_with_array_slice(iter([
... {'a': 11, 'b': iter([{'x': 12, 'y': 13}, {'x': 14, 'y': 15}])},
... {'a': 21, 'b': iter([{'x': 22, 'y': 23}, {'x': 24, 'y': 25}])},
... ]))
[{'a': 11, 'b': [{'y': 13.0, 'x': 12}, {'y': 15.0, 'x': 14}]}, {'a': 21, 'b': [{'y': 23.0, 'x': 22}, {'y': 25.0, 'x': 24}]}]
>>> x['a'], y['a']
(11, 21)
>>> sorted(v.items() for v in x['b'])
[[('y', 13.0), ('x', 12)], [('y', 15.0), ('x', 14)]]
>>> sorted(v.items() for v in y['b'])
[[('y', 23.0), ('x', 22)], [('y', 25.0), ('x', 24)]]
"""
cdef
StructWithArray
[
2
]
v
v
[:]
=
x
...
...
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