Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
77d9d3e0
Commit
77d9d3e0
authored
Apr 12, 2021
by
Martin Reinecke
Browse files
Merge branch 'pa' into 'NIFTy_7'
Treat scaling correctly See merge request
!616
parents
4dca30b7
5beafe79
Pipeline
#98215
passed with stages
in 24 minutes and 52 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/library/special_distributions.py
View file @
77d9d3e0
...
...
@@ -23,6 +23,7 @@ from .. import random
from
..domain_tuple
import
DomainTuple
from
..domains.unstructured_domain
import
UnstructuredDomain
from
..field
import
Field
from
..operators.adder
import
Adder
from
..operators.operator
import
Operator
from
..sugar
import
makeOp
...
...
@@ -133,9 +134,8 @@ def LogInverseGammaOperator(domain, alpha, q, delta=1e-2):
"""
op
=
_InterpolationOperator
(
domain
,
lambda
x
:
np
.
log
(
invgamma
.
ppf
(
norm
.
_cdf
(
x
),
float
(
alpha
))),
-
8.2
,
8.2
,
delta
)
if
np
.
isscalar
(
q
):
return
op
.
scale
(
q
)
return
makeOp
(
q
)
@
op
q
=
np
.
log
(
q
)
if
np
.
isscalar
(
q
)
else
q
.
log
()
return
Adder
(
q
,
domain
=
op
.
target
)
@
op
class
UniformOperator
(
Operator
):
...
...
src/sugar.py
View file @
77d9d3e0
...
...
@@ -479,7 +479,7 @@ def exec_time(obj, want_metric=True):
res
=
obj
(
lin
)
logger
.
info
(
'Operator call with linearization: {}'
.
format
(
time
()
-
t0
))
if
isinstance
(
obj
,
EnergyOperator
):
if
obj
.
target
is
DomainTuple
.
scalar_domain
(
):
t0
=
time
()
res
.
gradient
logger
.
info
(
'Gradient evaluation: {}'
.
format
(
time
()
-
t0
))
...
...
test/test_operators/test_interpolated.py
View file @
77d9d3e0
...
...
@@ -11,7 +11,7 @@
# 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) 2013-201
9
Max-Planck-Society
# Copyright(C) 2013-20
2
1 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
...
...
@@ -41,6 +41,9 @@ def testInterpolationAccuracy(space, seed):
if
not
np
.
isscalar
(
q
):
qfld
=
ift
.
makeField
(
space
,
q
)
op
=
ift
.
InverseGammaOperator
(
space
,
alpha
,
qfld
)
op1
=
ift
.
LogInverseGammaOperator
(
space
,
alpha
,
qfld
).
exp
()
arr1
=
op
(
pos
).
val
arr2
=
op1
(
pos
).
val
arr0
=
invgamma
.
ppf
(
norm
.
cdf
(
pos
.
val
),
alpha
,
scale
=
q
)
assert_allclose
(
arr0
,
arr1
)
assert_allclose
(
arr0
,
arr2
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment