Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
d6a40b95
There was a problem fetching the pipeline summary.
Commit
d6a40b95
authored
8 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
put tests in their correct location
parent
2da0de8b
No related branches found
No related tags found
1 merge request
!96
Replace direct smoothing code by pure Python
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test_operators/test_fft_operator.py
+2
-58
2 additions, 58 deletions
test/test_operators/test_fft_operator.py
test/test_operators/test_smoothing_operator.py
+89
-0
89 additions, 0 deletions
test/test_operators/test_smoothing_operator.py
with
91 additions
and
58 deletions
test/test_
misc
.py
→
test/test_
operators/test_fft_operator
.py
+
2
−
58
View file @
d6a40b95
...
@@ -17,24 +17,18 @@
...
@@ -17,24 +17,18 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
numpy.testing
import
assert_equal
,
\
from
numpy.testing
import
assert_equal
,
\
assert_allclose
assert_allclose
from
nifty.config
import
dependency_injector
as
di
from
nifty.config
import
dependency_injector
as
di
from
nifty
import
Field
,
\
from
nifty
import
Field
,
\
RGSpace
,
\
RGSpace
,
\
LMSpace
,
\
LMSpace
,
\
HPSpace
,
\
HPSpace
,
\
GLSpace
,
\
GLSpace
,
\
PowerSpace
,
\
FFTOperator
FFTOperator
,
\
SmoothingOperator
from
itertools
import
product
from
itertools
import
product
from
test.common
import
expand
from
test.common
import
expand
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
...
@@ -54,7 +48,7 @@ def _get_rtol(tp):
...
@@ -54,7 +48,7 @@ def _get_rtol(tp):
return
1e-5
return
1e-5
class
Misc_
Tests
(
unittest
.
TestCase
):
class
FFTOperator
Tests
(
unittest
.
TestCase
):
@expand
(
product
([
10
,
11
],
[
False
,
True
],
[
0.1
,
1
,
3.7
]))
@expand
(
product
([
10
,
11
],
[
False
,
True
],
[
0.1
,
1
,
3.7
]))
def
test_RG_distance_1D
(
self
,
dim1
,
zc1
,
d
):
def
test_RG_distance_1D
(
self
,
dim1
,
zc1
,
d
):
foo
=
RGSpace
([
dim1
],
zerocenter
=
zc1
,
distances
=
d
)
foo
=
RGSpace
([
dim1
],
zerocenter
=
zc1
,
distances
=
d
)
...
@@ -160,53 +154,3 @@ class Misc_Tests(unittest.TestCase):
...
@@ -160,53 +154,3 @@ class Misc_Tests(unittest.TestCase):
v1
=
np
.
sqrt
(
out
.
dot
(
out
))
v1
=
np
.
sqrt
(
out
.
dot
(
out
))
v2
=
np
.
sqrt
(
inp
.
dot
(
fft
.
adjoint_times
(
out
)))
v2
=
np
.
sqrt
(
inp
.
dot
(
fft
.
adjoint_times
(
out
)))
assert_allclose
(
v1
,
v2
,
rtol
=
tol
,
atol
=
tol
)
assert_allclose
(
v1
,
v2
,
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
100
,
200
],
[
1
,
0.4
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_regular1
(
self
,
sz
,
d
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
(
sz
,
harmonic
=
True
,
distances
=
d
)
smo
=
SmoothingOperator
(
sp
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
sp
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
10
,
15
],
[
7
,
10
],
[
1
,
0.4
],
[
2
,
0.3
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_regular2
(
self
,
sz1
,
sz2
,
d1
,
d2
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
([
sz1
,
sz2
],
distances
=
[
d1
,
d2
],
harmonic
=
True
)
smo
=
SmoothingOperator
(
sp
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
sp
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
100
,
200
],
[
False
,
True
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_irregular1
(
self
,
sz
,
log
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
(
sz
,
harmonic
=
True
)
ps
=
PowerSpace
(
sp
,
nbin
=
sz
,
logarithmic
=
log
)
smo
=
SmoothingOperator
(
ps
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
ps
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
10
,
15
],
[
7
,
10
],
[
False
,
True
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_irregular2
(
self
,
sz1
,
sz2
,
log
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
([
sz1
,
sz2
],
harmonic
=
True
)
ps
=
PowerSpace
(
sp
,
logarithmic
=
log
)
smo
=
SmoothingOperator
(
ps
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
ps
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
This diff is collapsed.
Click to expand it.
test/test_operators/test_smoothing_operator.py
0 → 100644
+
89
−
0
View file @
d6a40b95
# NIFTy
# Copyright (C) 2017 Theo Steininger
#
# Author: Theo Steininger
#
# 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/>.
import
unittest
import
numpy
as
np
from
numpy.testing
import
assert_equal
,
\
assert_allclose
from
nifty.config
import
dependency_injector
as
di
from
nifty
import
Field
,
\
RGSpace
,
\
PowerSpace
,
\
SmoothingOperator
from
itertools
import
product
from
test.common
import
expand
def
_get_rtol
(
tp
):
if
(
tp
==
np
.
float64
)
or
(
tp
==
np
.
complex128
):
return
1e-10
else
:
return
1e-5
class
Misc_Tests
(
unittest
.
TestCase
):
@expand
(
product
([
100
,
200
],
[
1
,
0.4
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_regular1
(
self
,
sz
,
d
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
(
sz
,
harmonic
=
True
,
distances
=
d
)
smo
=
SmoothingOperator
(
sp
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
sp
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
10
,
15
],
[
7
,
10
],
[
1
,
0.4
],
[
2
,
0.3
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_regular2
(
self
,
sz1
,
sz2
,
d1
,
d2
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
([
sz1
,
sz2
],
distances
=
[
d1
,
d2
],
harmonic
=
True
)
smo
=
SmoothingOperator
(
sp
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
sp
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
100
,
200
],
[
False
,
True
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_irregular1
(
self
,
sz
,
log
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
(
sz
,
harmonic
=
True
)
ps
=
PowerSpace
(
sp
,
nbin
=
sz
,
logarithmic
=
log
)
smo
=
SmoothingOperator
(
ps
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
ps
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
@expand
(
product
([
10
,
15
],
[
7
,
10
],
[
False
,
True
],
[
0.
,
1.
,
3.7
],
[
np
.
float64
,
np
.
complex128
]))
def
test_smooth_irregular2
(
self
,
sz1
,
sz2
,
log
,
sigma
,
tp
):
tol
=
_get_rtol
(
tp
)
sp
=
RGSpace
([
sz1
,
sz2
],
harmonic
=
True
)
ps
=
PowerSpace
(
sp
,
logarithmic
=
log
)
smo
=
SmoothingOperator
(
ps
,
sigma
=
sigma
)
inp
=
Field
.
from_random
(
domain
=
ps
,
random_type
=
'
normal
'
,
std
=
1
,
mean
=
4
,
dtype
=
tp
)
out
=
smo
(
inp
)
inp
=
inp
.
val
.
get_full_data
()
assert_allclose
(
inp
.
sum
(),
out
.
sum
(),
rtol
=
tol
,
atol
=
tol
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment