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
5a2e38b6
Commit
5a2e38b6
authored
4 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Implement proper constant support 8/n
parent
e3328be0
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!545
Proper constants
Pipeline
#77011
passed
4 years ago
Stage: build_docker
Stage: test
Stage: demo_runs
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/operators/chain_operator.py
+11
-1
11 additions, 1 deletion
src/operators/chain_operator.py
test/test_energy_gradients.py
+1
-1
1 addition, 1 deletion
test/test_energy_gradients.py
with
12 additions
and
2 deletions
src/operators/chain_operator.py
+
11
−
1
View file @
5a2e38b6
...
@@ -58,7 +58,14 @@ class ChainOperator(LinearOperator):
...
@@ -58,7 +58,14 @@ class ChainOperator(LinearOperator):
fct
=
1.
fct
=
1.
opsnew
=
[]
opsnew
=
[]
lastdom
=
ops
[
-
1
].
domain
lastdom
=
ops
[
-
1
].
domain
dtype
=
None
for
op
in
ops
:
for
op
in
ops
:
from
.sampling_enabler
import
SamplingDtypeSetter
if
isinstance
(
op
,
SamplingDtypeSetter
)
and
isinstance
(
op
.
_op
,
ScalingOperator
):
if
dtype
is
not
None
:
raise
NotImplementedError
dtype
=
op
.
_dtype
op
=
op
.
_op
if
(
isinstance
(
op
,
ScalingOperator
)
and
op
.
_factor
.
imag
==
0
):
if
(
isinstance
(
op
,
ScalingOperator
)
and
op
.
_factor
.
imag
==
0
):
fct
*=
op
.
_factor
.
real
fct
*=
op
.
_factor
.
real
else
:
else
:
...
@@ -72,7 +79,10 @@ class ChainOperator(LinearOperator):
...
@@ -72,7 +79,10 @@ class ChainOperator(LinearOperator):
break
break
if
fct
!=
1
or
len
(
opsnew
)
==
0
:
if
fct
!=
1
or
len
(
opsnew
)
==
0
:
# have to add the scaling operator at the end
# have to add the scaling operator at the end
opsnew
.
append
(
ScalingOperator
(
lastdom
,
fct
))
op
=
ScalingOperator
(
lastdom
,
fct
)
if
dtype
is
not
None
:
op
=
SamplingDtypeSetter
(
op
,
dtype
)
opsnew
.
append
(
op
)
ops
=
opsnew
ops
=
opsnew
# combine DiagonalOperators where possible
# combine DiagonalOperators where possible
opsnew
=
[]
opsnew
=
[]
...
...
This diff is collapsed.
Click to expand it.
test/test_energy_gradients.py
+
1
−
1
View file @
5a2e38b6
...
@@ -35,7 +35,6 @@ def test_gaussian(field):
...
@@ -35,7 +35,6 @@ def test_gaussian(field):
ift
.
extra
.
check_operator
(
energy
,
field
)
ift
.
extra
.
check_operator
(
energy
,
field
)
@pytest.mark.skip
()
def
test_ScaledEnergy
(
field
):
def
test_ScaledEnergy
(
field
):
icov
=
ift
.
ScalingOperator
(
field
.
domain
,
1.2
)
icov
=
ift
.
ScalingOperator
(
field
.
domain
,
1.2
)
energy
=
ift
.
GaussianEnergy
(
inverse_covariance
=
icov
,
sampling_dtype
=
np
.
float64
)
energy
=
ift
.
GaussianEnergy
(
inverse_covariance
=
icov
,
sampling_dtype
=
np
.
float64
)
...
@@ -48,6 +47,7 @@ def test_ScaledEnergy(field):
...
@@ -48,6 +47,7 @@ def test_ScaledEnergy(field):
res2
=
met2
(
field
)
/
0.3
res2
=
met2
(
field
)
/
0.3
ift
.
extra
.
assert_allclose
(
res1
,
res2
,
0
,
1e-12
)
ift
.
extra
.
assert_allclose
(
res1
,
res2
,
0
,
1e-12
)
met1
.
draw_sample
()
met1
.
draw_sample
()
print
(
met2
)
met2
.
draw_sample
()
met2
.
draw_sample
()
...
...
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