Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
fbd95e94
Commit
fbd95e94
authored
May 18, 2016
by
Jait Dixit
Browse files
Fix docstring
parent
df910a75
Pipeline
#3174
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty_utilities.py
View file @
fbd95e94
...
@@ -7,23 +7,38 @@ from itertools import product
...
@@ -7,23 +7,38 @@ from itertools import product
def
get_slice_list
(
shape
,
axes
):
def
get_slice_list
(
shape
,
axes
):
"""
"""
Yields a slice list which can be passed directly to d2o object or
Helper function which generate slice list(s) to traverse over all
numpy.ndarray to extract that slice of data.
combinations of axes, other than the selected axes. This is used in
conjunction with outer-product spaces. The generated slice list can
:shape: Tuple
passed to the target outer-product space to extract the selected
Shape of the target d2o object or numpy.ndarray
data. The target outer-product space can be either a d2o object or
:axes: Tuple
a numpy.ndarray.
Axes which are to be extracted
:returns: List
Parameters
List of indices and/or slice objects
----------
shape: tuple
Shape of the target d2o object or numpy.ndarray.
axes: tuple
Axes along which data needs to be extracted.
Yields
-------
list
The next list of indices and/or slice objects for each dimension.
Raises
------
ValueError
If shape is empty.
ValueError
If axes(axis) does not match shape.
"""
"""
if
not
shape
:
if
not
shape
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: shape cannot be None."
))
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: shape cannot be None."
))
if
not
all
(
axis
<
len
(
shape
)
for
axis
in
axes
):
if
not
all
(
axis
<
len
(
shape
)
for
axis
in
axes
):
raise
ValueError
(
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: axes(axis) do not match shape."
)
about
.
_errors
.
cstring
(
"ERROR: axes(axis) do
es
not match shape."
)
)
)
axes_select
=
[
0
if
x
in
axes
else
1
for
x
,
y
in
enumerate
(
shape
)]
axes_select
=
[
0
if
x
in
axes
else
1
for
x
,
y
in
enumerate
(
shape
)]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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