Skip to content

Commit 5f3ada6

Browse files
committed
Run clang-format on files
1 parent 6c2534f commit 5f3ada6

4 files changed

Lines changed: 93 additions & 69 deletions

File tree

pythran/pythonic/include/numpy/fft/irfft.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace numpy
1111
namespace fft
1212
{
1313

14-
template <class T, class pS, typename U, typename V, typename W >
14+
template <class T, class pS, typename U, typename V, typename W>
1515
types::ndarray<double, types::array<long, std::tuple_size<pS>::value>>
1616
irfft(types::ndarray<T, pS> const &, U NFFT, V axis, W renorm);
1717

pythran/pythonic/include/numpy/fft/rfft.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace numpy
1717
types::array<long, std::tuple_size<pS>::value>>
1818
rfft(types::ndarray<T, pS> const &input, U NFFT, V axis, W renorm);
1919

20-
NUMPY_EXPR_TO_NDARRAY0_DECL(rfft);
20+
NUMPY_EXPR_TO_NDARRAY0_DECL(rfft);
2121
DEFINE_FUNCTOR(pythonic::numpy::fft, rfft);
2222
}
2323
}

pythran/pythonic/numpy/fft/irfft.hpp

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -86,45 +86,56 @@ namespace numpy
8686
return out_array;
8787
}
8888

89-
// These functions help handle None inputs for default values without relying on the C++ default mechanism.
90-
bool testNorm(types::none_type param) { return false; }
91-
bool testNorm(types::str param) {
92-
if (param == "ortho") return 1;
93-
else {
94-
throw types::ValueError("norm should be None or \"ortho\"");
95-
return 0;
96-
}
89+
// These functions help handle None inputs for default values without
90+
// relying on the C++ default mechanism.
91+
bool testNorm(types::none_type param)
92+
{
93+
return false;
94+
}
95+
bool testNorm(types::str param)
96+
{
97+
if (param == "ortho")
98+
return 1;
99+
else {
100+
throw types::ValueError("norm should be None or \"ortho\"");
101+
return 0;
97102
}
98-
99-
long testLong(types::none_type param, long def_val) { return def_val;}
100-
long testLong(long N, long def_val) { return N;}
103+
}
101104

102-
103-
template <class T, class pS, typename U, typename V, typename W >
104-
types::ndarray<double, types::array<long, std::tuple_size<pS>::value>>
105-
irfft(types::ndarray<T, pS> const & in_array, U _NFFT, V _axis, W renorm)
105+
long testLong(types::none_type param, long def_val)
106+
{
107+
return def_val;
108+
}
109+
long testLong(long N, long def_val)
110+
{
111+
return N;
112+
}
113+
114+
template <class T, class pS, typename U, typename V, typename W>
115+
types::ndarray<double, types::array<long, std::tuple_size<pS>::value>>
116+
irfft(types::ndarray<T, pS> const &in_array, U _NFFT, V _axis, W renorm)
106117
{
107-
auto constexpr N = std::tuple_size<pS>::value;
108-
bool norm = testNorm(renorm);
109-
// Handle None for axis input.
110-
long axis = testLong(_axis,-1);
111-
long LN = (long) N;
112-
if (axis >= LN) throw types::ValueError("axis out of bounds1");
113-
if (axis <= -LN-1) throw types::ValueError("axis out of bounds");
114-
// Handle None for NFFT. Map -1 -> N-1 etc...
115-
axis = (axis+N)%N;
116-
long def_val = 2*(sutils::array(in_array.shape())[axis] - 1);
117-
long NFFT = testLong(_NFFT,def_val);
118-
if (axis != N - 1) {
119-
// Swap axis if the FFT must be computed on an axis that's not the last
120-
// one.
121-
auto swapped_array = swapaxes(in_array, axis, N - 1);
122-
return swapaxes(_irfft(swapped_array, NFFT, norm), axis, N - 1);
123-
}
124-
else {
125-
return _irfft(in_array, NFFT, norm);
126-
127-
}
118+
auto constexpr N = std::tuple_size<pS>::value;
119+
bool norm = testNorm(renorm);
120+
// Handle None for axis input.
121+
long axis = testLong(_axis, -1);
122+
long LN = (long)N;
123+
if (axis >= LN)
124+
throw types::ValueError("axis out of bounds1");
125+
if (axis <= -LN - 1)
126+
throw types::ValueError("axis out of bounds");
127+
// Handle None for NFFT. Map -1 -> N-1 etc...
128+
axis = (axis + N) % N;
129+
long def_val = 2 * (sutils::array(in_array.shape())[axis] - 1);
130+
long NFFT = testLong(_NFFT, def_val);
131+
if (axis != N - 1) {
132+
// Swap axis if the FFT must be computed on an axis that's not the last
133+
// one.
134+
auto swapped_array = swapaxes(in_array, axis, N - 1);
135+
return swapaxes(_irfft(swapped_array, NFFT, norm), axis, N - 1);
136+
} else {
137+
return _irfft(in_array, NFFT, norm);
138+
}
128139
}
129140

130141
NUMPY_EXPR_TO_NDARRAY0_IMPL(irfft);

pythran/pythonic/numpy/fft/rfft.hpp

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,44 +90,57 @@ namespace numpy
9090
return out_array;
9191
}
9292

93-
// These functions help handle None inputs for default values without relying on the C++ default mechanism.
94-
bool testNorm(types::none_type param) { return false; }
95-
bool testNorm(types::str param) {
96-
if (param == "ortho") return 1;
97-
else {
98-
throw types::ValueError("norm should be None or \"ortho\"");
99-
return 0;
100-
}
93+
// These functions help handle None inputs for default values without
94+
// relying on the C++ default mechanism.
95+
bool testNorm(types::none_type param)
96+
{
97+
return false;
98+
}
99+
bool testNorm(types::str param)
100+
{
101+
if (param == "ortho")
102+
return 1;
103+
else {
104+
throw types::ValueError("norm should be None or \"ortho\"");
105+
return 0;
106+
}
107+
}
108+
109+
long testLong(types::none_type param, long def_val)
110+
{
111+
return def_val;
112+
}
113+
long testLong(long N, long def_val)
114+
{
115+
return N;
101116
}
102-
103-
long testLong(types::none_type param, long def_val) { return def_val;}
104-
long testLong(long N, long def_val) { return N;}
105117

106118
template <class T, class pS, typename U, typename V, typename W>
107119
types::ndarray<std::complex<typename std::common_type<T, double>::type>,
108120
types::array<long, std::tuple_size<pS>::value>>
109121
rfft(types::ndarray<T, pS> const &in_array, U _NFFT, V _axis, W normalize)
110122
{
111-
bool norm = testNorm(normalize);
112-
auto constexpr N = std::tuple_size<pS>::value;
113-
// Handle None for axis input.
114-
long axis = testLong(_axis,-1);
115-
// Handle None for NFFT. Map -1 -> N-1 etc...
116-
long LN = (long) N;
117-
if (axis >= LN) throw types::ValueError("axis out of bounds1");
118-
if (axis <= -LN-1) throw types::ValueError("axis out of bounds");
119-
axis = (axis+LN)%LN;
120-
long def_val = sutils::array(in_array.shape())[axis];
121-
long NFFT = testLong(_NFFT,def_val);
122-
if (axis != LN - 1) {
123-
// Swap axis if the FFT must be computed on an axis that's not the last
124-
// one.
125-
auto swapped_array = swapaxes(in_array, axis, N - 1);
126-
return swapaxes(_rfft(swapped_array, NFFT, norm), axis, N - 1);
127-
}
128-
else {
129-
return _rfft(in_array, NFFT, norm);
130-
}
123+
bool norm = testNorm(normalize);
124+
auto constexpr N = std::tuple_size<pS>::value;
125+
// Handle None for axis input.
126+
long axis = testLong(_axis, -1);
127+
// Handle None for NFFT. Map -1 -> N-1 etc...
128+
long LN = (long)N;
129+
if (axis >= LN)
130+
throw types::ValueError("axis out of bounds1");
131+
if (axis <= -LN - 1)
132+
throw types::ValueError("axis out of bounds");
133+
axis = (axis + LN) % LN;
134+
long def_val = sutils::array(in_array.shape())[axis];
135+
long NFFT = testLong(_NFFT, def_val);
136+
if (axis != LN - 1) {
137+
// Swap axis if the FFT must be computed on an axis that's not the last
138+
// one.
139+
auto swapped_array = swapaxes(in_array, axis, N - 1);
140+
return swapaxes(_rfft(swapped_array, NFFT, norm), axis, N - 1);
141+
} else {
142+
return _rfft(in_array, NFFT, norm);
143+
}
131144
}
132145

133146
NUMPY_EXPR_TO_NDARRAY0_IMPL(rfft);

0 commit comments

Comments
 (0)