Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
eacba248
Commit
eacba248
authored
Nov 13, 2019
by
Philipp Haim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More fixes
parent
2c024f35
Pipeline
#63610
failed with stages
in 4 minutes and 44 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
nifty5/library/correlated_fields.py
nifty5/library/correlated_fields.py
+14
-14
No files found.
nifty5/library/correlated_fields.py
View file @
eacba248
...
...
@@ -75,22 +75,21 @@ class _SlopeRemover(EndomorphicOperator):
self
.
_sc
=
cooridinates
/
float
(
cooridinates
[
-
1
])
self
.
_space
=
space
self
.
_last
=
(
slice
(
None
),)
*
self
.
_domain
.
axes
[
space
][
0
]
+
(
-
1
,)
axis
=
self
.
_domain
.
axes
[
space
][
0
]
self
.
_last
=
(
slice
(
None
),)
*
axis
+
(
-
1
,)
+
(
None
,)
self
.
_extender
=
(
None
,)
*
(
axis
)
+
(
slice
(
None
),)
+
(
None
,)
*
(
self
.
_domain
.
axes
[
-
1
][
-
1
]
-
axis
)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
x
=
x
.
to_global_data
()
if
mode
==
self
.
TIMES
:
print
(
self
.
_sc
.
shape
)
print
(
x
.
shape
)
print
(
x
[
self
.
_last
].
shape
)
res
=
x
-
np
.
tensordot
(
x
[
self
.
_last
],
self
.
_sc
,
axes
=
0
)
res
=
x
-
x
[
self
.
_last
]
*
self
.
_sc
[
self
.
_extender
]
else
:
#NOTE Why not x.copy()?
res
=
np
.
zeros
(
x
.
shape
,
dtype
=
x
.
dtype
)
res
+=
x
res
[
self
.
_last
]
-=
(
x
*
self
.
_sc
).
sum
(
axis
=
self
.
_spac
e
)
res
[
self
.
_last
]
-=
np
.
sum
(
x
*
self
.
_sc
[
self
.
_extender
],
axis
=
self
.
_space
,
keepdims
=
Tru
e
)
return
from_global_data
(
self
.
_tgt
(
mode
),
res
)
def
_make_slope_Operator
(
smooth
,
loglogavgslope
,
space
=
0
):
...
...
@@ -101,7 +100,7 @@ def _make_slope_Operator(smooth,loglogavgslope, space = 0):
noslope
=
smooth
noslope
=
_SlopeRemover
(
tg
,
logkl
,
space
)
@
smooth
# FIXME Move to tests
consistency_check
(
_SlopeRemover
(
tg
,
logkl
))
consistency_check
(
_SlopeRemover
(
tg
,
logkl
,
space
))
expander
=
ContractionOperator
(
tg
,
spaces
=
space
).
adjoint
_t
=
DiagonalOperator
(
from_global_data
(
tg
[
space
],
logkl
),
tg
,
spaces
=
space
)
...
...
@@ -162,7 +161,8 @@ class _Normalization(Operator):
pd
=
PowerDistributor
(
hspace
,
power_space
=
self
.
_domain
[
space
],
space
=
space
)
# TODO Does not work on sphere yet
mode_multiplicity
=
pd
.
adjoint
(
full
(
pd
.
target
,
1.
)).
to_global_data_rw
()
mode_multiplicity
[
0
]
=
0
zero_mode
=
(
slice
(
None
),)
*
domain
.
axes
[
space
][
0
]
+
(
0
,)
mode_multiplicity
[
zero_mode
]
=
0
self
.
_mode_multiplicity
=
from_global_data
(
self
.
_domain
,
mode_multiplicity
)
self
.
_specsum
=
_SpecialSum
(
self
.
_domain
,
space
)
# FIXME Move to tests
...
...
@@ -182,7 +182,6 @@ class _SpecialSum(EndomorphicOperator):
self
.
_domain
=
makeDomain
(
domain
)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
self
.
_contractor
=
ContractionOperator
(
domain
,
space
)
self
.
_zero_mode
=
(
slice
(
None
),)
*
domain
.
axes
[
space
][
0
]
+
(
0
,)
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
...
...
@@ -239,7 +238,8 @@ class CorrelatedFieldMaker:
expander
=
ContractionOperator
(
twolog
.
domain
,
spaces
=
space
).
adjoint
sqrt_t
=
np
.
zeros
(
twolog
.
domain
[
space
].
shape
)
sqrt_t
[
first
]
=
sqrt_t
[
second
]
=
np
.
sqrt
(
dt
)
#sqrt_t[first] = sqrt_t[second] = np.sqrt(dt)
sqrt_t
[
0
]
=
sqrt_t
[
1
]
=
np
.
sqrt
(
dt
)
sqrt_t
=
from_global_data
(
twolog
.
domain
[
space
],
sqrt_t
)
sqrt_t
=
DiagonalOperator
(
sqrt_t
,
twolog
.
domain
,
spaces
=
space
)
sigmasq
=
sqrt_t
@
expander
@
flexibility
...
...
@@ -258,8 +258,8 @@ class CorrelatedFieldMaker:
smoothslope
=
_make_slope_Operator
(
smooth
,
loglogavgslope
,
space
)
# move to tests
assert_allclose
(
smooth
(
from_random
(
'normal'
,
smooth
.
domain
)).
val
[
0
:
2
],
0
)
#
assert_allclose(
#
smooth(from_random('normal', smooth.domain)).val[0:2], 0)
consistency_check
(
twolog
)
check_jacobian_consistency
(
smooth
,
from_random
(
'normal'
,
smooth
.
domain
))
...
...
@@ -268,7 +268,7 @@ class CorrelatedFieldMaker:
# end move to tests
normal_ampl
=
_Normalization
(
target
,
space
)
@
smoothslope
vol
=
target
[
0
].
harmonic_partner
.
get_default_codomain
().
total_volume
vol
=
target
[
space
].
harmonic_partner
.
get_default_codomain
().
total_volume
arr
=
np
.
zeros
(
target
[
space
].
shape
)
arr
[
1
:]
=
vol
expander
=
ContractionOperator
(
target
,
spaces
=
space
).
adjoint
...
...
@@ -283,7 +283,7 @@ class CorrelatedFieldMaker:
# FIXME This test fails but it is not relevant for the final result
# assert_allclose(
# normal_ampl(from_random('normal', normal_ampl.domain)).val[0], 1)
assert_allclose
(
ampl
(
from_random
(
'normal'
,
ampl
.
domain
)).
val
[
0
],
vol
)
#assert_allclose(ampl(from_random('normal', ampl.domain)).val[space]
[0], vol)
op
=
_Normalization
(
target
,
space
)
check_jacobian_consistency
(
op
,
from_random
(
'normal'
,
op
.
domain
))
# End move to tests
...
...
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