Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
fd736c11
Commit
fd736c11
authored
Apr 09, 2019
by
Philipp Arras
Browse files
Add test
parent
8ec6d1f7
Pipeline
#46602
failed with stages
in 5 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Sidebyside
Showing
2 changed files
with
92 additions
and
0 deletions
+92
0
nifty5/library/gridder.py
nifty5/library/gridder.py
+17
0
test/test_operators/test_nft.py
test/test_operators/test_nft.py
+75
0
No files found.
nifty5/library/gridder.py
View file @
fd736c11
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2019 MaxPlanckSociety
#
# NIFTy is being developed at the MaxPlanckInstitut fuer Astrophysik.
import
numpy
as
np
from
..domain_tuple
import
DomainTuple
...
...
test/test_operators/test_nft.py
0 → 100644
View file @
fd736c11
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2019 MaxPlanckSociety
#
# NIFTy is being developed at the MaxPlanckInstitut fuer Astrophysik.
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_allclose
import
nifty5
as
ift
np
.
random
.
seed
(
40
)
pmp
=
pytest
.
mark
.
parametrize
@
pmp
(
'nu'
,
[
12
,
128
])
@
pmp
(
'nv'
,
[
4
,
12
,
128
])
@
pmp
(
'N'
,
[
1
,
10
,
100
])
def
test_gridding
(
nu
,
nv
,
N
):
uv
=
np
.
random
.
rand
(
N
,
2
)

0.5
vis
=
np
.
random
.
randn
(
N
)
+
1j
*
np
.
random
.
randn
(
N
)
# Nifty
GM
=
ift
.
GridderMaker
(
ift
.
RGSpace
((
nu
,
nv
)))
# reorder for performance
idx
=
GM
.
getReordering
(
uv
)
uv
,
vis
=
uv
[
idx
],
vis
[
idx
]
vis
=
ift
.
from_global_data
(
ift
.
UnstructuredDomain
(
vis
.
shape
),
vis
)
Op
=
GM
.
getFull
(
uv
)
pynu
=
Op
(
vis
).
to_global_data
()
# DFT
x
,
y
=
np
.
meshgrid
(
*
[

ss
/
2
+
np
.
arange
(
ss
)
for
ss
in
[
nu
,
nv
]],
indexing
=
'ij'
)
dft
=
pynu
*
0.
for
i
in
range
(
N
):
dft
+=
vis
.
val
[
i
]
*
np
.
exp
(
2j
*
np
.
pi
*
(
x
*
uv
[
i
,
0
]
+
y
*
uv
[
i
,
1
]))
assert_allclose
(
dft
,
pynu
)
@
pmp
(
'eps'
,
[
1e2
,
1e6
,
1e15
])
@
pmp
(
'nu'
,
[
12
,
128
])
@
pmp
(
'nv'
,
[
4
,
12
,
128
])
@
pmp
(
'N'
,
[
1
,
10
,
100
])
def
test_build
(
nu
,
nv
,
N
,
eps
):
dom
=
ift
.
RGSpace
([
nu
,
nv
])
uv
=
np
.
random
.
rand
(
N
,
2
)

0.5
GM
=
ift
.
GridderMaker
(
dom
)
# reorder for performance
idx
=
GM
.
getReordering
(
uv
)
uv
=
uv
[
idx
]
R0
=
GM
.
getGridder
(
uv
)
R1
=
GM
.
getRest
()
R
=
R1
@
R0
RF
=
GM
.
getFull
(
uv
)
# Consistency checks
dt
=
np
.
complex
ift
.
extra
.
consistency_check
(
R0
,
domain_dtype
=
dt
,
target_dtype
=
dt
)
ift
.
extra
.
consistency_check
(
R1
,
domain_dtype
=
dt
,
target_dtype
=
dt
)
ift
.
extra
.
consistency_check
(
R
,
domain_dtype
=
dt
,
target_dtype
=
dt
)
ift
.
extra
.
consistency_check
(
RF
,
domain_dtype
=
dt
,
target_dtype
=
dt
)
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