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
b719e4ae
Commit
b719e4ae
authored
Aug 02, 2018
by
Martin Reinecke
Browse files
small optimizations
parent
85b3b288
Changes
5
Hide whitespace changes
Inline
Side-by-side
demos/bernoulli_demo.py
View file @
b719e4ae
...
...
@@ -33,7 +33,7 @@ if __name__ == '__main__':
# Two-dimensional regular grid with inhomogeneous exposure
position_space
=
ift
.
RGSpace
([
512
,
512
])
#
#
Sphere with
with
uniform exposure
# Sphere with uniform exposure
# position_space = ift.HPSpace(128)
# exposure = ift.Field.full(position_space, 1.)
...
...
demos/getting_started_2.py
View file @
b719e4ae
...
...
@@ -49,7 +49,7 @@ if __name__ == '__main__':
position_space
=
ift
.
RGSpace
([
512
,
512
])
exposure
=
get_2D_exposure
()
#
#
Sphere with
with
uniform exposure
# Sphere with uniform exposure
# position_space = ift.HPSpace(128)
# exposure = ift.Field.full(position_space, 1.)
...
...
@@ -70,7 +70,7 @@ if __name__ == '__main__':
A
=
pd
(
a
)
# Set up a sky model
sky
=
HT
.
chain
(
ift
.
makeOp
(
A
))
.
exp
(
)
sky
=
ift
.
exp
(
HT
.
chain
(
ift
.
makeOp
(
A
)))
M
=
ift
.
DiagonalOperator
(
exposure
)
GR
=
ift
.
GeometryRemover
(
position_space
)
...
...
@@ -99,7 +99,6 @@ if __name__ == '__main__':
H
,
convergence
=
minimizer
(
H
)
# Plot results
result_sky
=
sky
(
H
.
position
)
ift
.
plot
(
result_sky
)
ift
.
plot
(
sky
(
H
.
position
))
ift
.
plot_finish
()
# FIXME PLOTTING
nifty5/minimization/energy.py
View file @
b719e4ae
...
...
@@ -25,8 +25,8 @@ from ..utilities import NiftyMetaBase, memo
class
Energy
(
NiftyMetaBase
()):
""" Provides the functional used by minimization schemes.
The Energy object is an implementation of a scalar function including its
gradient and metric at some position.
The Energy object is an implementation of a scalar function including its
gradient and metric at some position.
Parameters
----------
...
...
nifty5/multi/multi_field.py
View file @
b719e4ae
...
...
@@ -221,17 +221,16 @@ class MultiField(object):
return
MultiField
.
from_dict
({
key
:
self
[
key
]
for
key
in
subset
})
def
unite
(
self
,
other
):
if
self
.
_domain
is
other
.
_domain
:
return
self
+
other
return
self
.
combine
((
self
,
other
))
@
staticmethod
def
combine
(
fields
):
res
=
{}
for
f
in
fields
:
for
key
in
f
.
keys
():
if
key
in
res
:
res
[
key
]
=
res
[
key
]
+
f
[
key
]
else
:
res
[
key
]
=
f
[
key
]
for
key
,
val
in
f
.
items
():
res
[
key
]
=
res
[
key
]
+
val
if
key
in
res
else
val
return
MultiField
.
from_dict
(
res
)
...
...
nifty5/sugar.py
View file @
b719e4ae
...
...
@@ -261,7 +261,8 @@ for f in ["sqrt", "exp", "log", "tanh", "positive_tanh", "conjugate"]:
def
func
(
f
):
def
func2
(
x
):
from
.linearization
import
Linearization
if
isinstance
(
x
,
(
Field
,
MultiField
,
Linearization
)):
from
.operators.operator
import
Operator
if
isinstance
(
x
,
(
Field
,
MultiField
,
Linearization
,
Operator
)):
return
getattr
(
x
,
f
)()
else
:
return
getattr
(
np
,
f
)(
x
)
...
...
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