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
f0d60728
Commit
f0d60728
authored
Dec 31, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up and simplify some code
parent
2700e637
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
34 deletions
+22
-34
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+22
-34
No files found.
Cython/Compiler/MemoryView.py
View file @
f0d60728
...
@@ -296,12 +296,7 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
...
@@ -296,12 +296,7 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
name
,
"MemoryView_C.c"
,
context
=
context_dict
)
name
,
"MemoryView_C.c"
,
context
=
context_dict
)
return
impl
return
impl
all_dimensions_direct
=
True
all_dimensions_direct
=
all
(
access
==
'direct'
for
access
,
packing
in
self
.
type
.
axes
)
for
access
,
packing
in
self
.
type
.
axes
:
if
access
!=
'direct'
:
all_dimensions_direct
=
False
break
no_suboffset_dim
=
all_dimensions_direct
and
not
have_slices
no_suboffset_dim
=
all_dimensions_direct
and
not
have_slices
if
not
no_suboffset_dim
:
if
not
no_suboffset_dim
:
suboffset_dim
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
manage_ref
=
False
)
suboffset_dim
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
manage_ref
=
False
)
...
@@ -313,10 +308,17 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
...
@@ -313,10 +308,17 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
dim
=
-
1
dim
=
-
1
for
index
in
indices
:
for
index
in
indices
:
error_goto
=
code
.
error_goto
(
index
.
pos
)
if
index
.
is_none
:
if
not
index
.
is_none
:
# newaxis
for
attrib
,
value
in
[(
'shape'
,
1
),
(
'strides'
,
0
),
(
'suboffsets'
,
-
1
)]:
code
.
putln
(
"%s.%s[%d] = %d;"
%
(
dst
,
attrib
,
new_ndim
,
value
))
new_ndim
+=
1
continue
dim
+=
1
dim
+=
1
access
,
packing
=
self
.
type
.
axes
[
dim
]
access
,
packing
=
self
.
type
.
axes
[
dim
]
error_goto
=
code
.
error_goto
(
index
.
pos
)
if
isinstance
(
index
,
ExprNodes
.
SliceNode
):
if
isinstance
(
index
,
ExprNodes
.
SliceNode
):
# slice, unspecified dimension, or part of ellipsis
# slice, unspecified dimension, or part of ellipsis
...
@@ -324,14 +326,9 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
...
@@ -324,14 +326,9 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
for
s
in
"start stop step"
.
split
():
for
s
in
"start stop step"
.
split
():
idx
=
getattr
(
index
,
s
)
idx
=
getattr
(
index
,
s
)
have_idx
=
d
[
'have_'
+
s
]
=
not
idx
.
is_none
have_idx
=
d
[
'have_'
+
s
]
=
not
idx
.
is_none
if
have_idx
:
d
[
s
]
=
idx
.
result
()
if
have_idx
else
"0"
d
[
s
]
=
idx
.
result
()
else
:
d
[
s
]
=
"0"
if
(
not
d
[
'have_start'
]
and
if
not
(
d
[
'have_start'
]
or
d
[
'have_stop'
]
or
d
[
'have_step'
]):
not
d
[
'have_stop'
]
and
not
d
[
'have_step'
]):
# full slice (:), simply copy over the extent, stride
# full slice (:), simply copy over the extent, stride
# and suboffset. Also update suboffset_dim if needed
# and suboffset. Also update suboffset_dim if needed
d
[
'access'
]
=
access
d
[
'access'
]
=
access
...
@@ -340,32 +337,23 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
...
@@ -340,32 +337,23 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
code
.
put
(
load_slice_util
(
"ToughSlice"
,
d
))
code
.
put
(
load_slice_util
(
"ToughSlice"
,
d
))
new_ndim
+=
1
new_ndim
+=
1
elif
index
.
is_none
:
# newaxis
attribs
=
[(
'shape'
,
1
),
(
'strides'
,
0
),
(
'suboffsets'
,
-
1
)]
for
attrib
,
value
in
attribs
:
code
.
putln
(
"%s.%s[%d] = %d;"
%
(
dst
,
attrib
,
new_ndim
,
value
))
new_ndim
+=
1
else
:
else
:
# normal index
# normal index
idx
=
index
.
result
()
idx
=
index
.
result
()
if
access
==
'direct'
:
indirect
=
access
!=
'direct'
indirect
=
False
if
indirect
:
else
:
generic
=
access
==
'full'
indirect
=
True
generic
=
(
access
==
'full'
)
if
new_ndim
!=
0
:
if
new_ndim
!=
0
:
return
error
(
index
.
pos
,
return
error
(
index
.
pos
,
"All preceding dimensions must be "
"All preceding dimensions must be "
"indexed and not sliced"
)
"indexed and not sliced"
)
wraparound
=
int
(
directives
[
'wraparound'
])
d
=
dict
(
boundscheck
=
int
(
directives
[
'boundscheck'
])
locals
(),
d
=
locals
()
wraparound
=
int
(
directives
[
'wraparound'
]),
boundscheck
=
int
(
directives
[
'boundscheck'
])
)
code
.
put
(
load_slice_util
(
"SliceIndex"
,
d
))
code
.
put
(
load_slice_util
(
"SliceIndex"
,
d
))
if
not
no_suboffset_dim
:
if
not
no_suboffset_dim
:
...
...
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