Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Reinecke
pypocketfft
Commits
84f57346
Commit
84f57346
authored
Jun 18, 2019
by
Peter Bell
Browse files
Support python-style negative indices in axes arguments
parent
89d506fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
pypocketfft.cc
View file @
84f57346
...
...
@@ -63,13 +63,18 @@ shape_t makeaxes(const py::array &in, py::object axes)
res
[
i
]
=
i
;
return
res
;
}
auto
tmp
=
axes
.
cast
<
shape_t
>
();
if
((
tmp
.
size
()
>
size_t
(
in
.
ndim
()))
||
(
tmp
.
size
()
==
0
))
auto
tmp
=
axes
.
cast
<
std
::
vector
<
ptrdiff_t
>>
();
auto
ndim
=
in
.
ndim
();
if
((
tmp
.
size
()
>
size_t
(
ndim
))
||
(
tmp
.
size
()
==
0
))
throw
runtime_error
(
"bad axes argument"
);
for
(
auto
sz
:
tmp
)
if
(
sz
>=
size_t
(
in
.
ndim
()))
throw
runtime_error
(
"invalid axis number"
);
return
tmp
;
for
(
auto
&
sz
:
tmp
)
{
if
(
sz
<
0
)
sz
+=
ndim
;
if
((
sz
>=
ndim
)
||
(
sz
<
0
))
throw
invalid_argument
(
"axes exceeds dimensionality of output"
);
}
return
shape_t
(
tmp
.
begin
(),
tmp
.
end
());
}
#define DISPATCH(arr, T1, T2, T3, func, args) \
...
...
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