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
75f50648
Commit
75f50648
authored
Jul 06, 2018
by
Martin Reinecke
Browse files
rework imports; tweak domain comparisons
parent
0992e538
Changes
23
Hide whitespace changes
Inline
Side-by-side
nifty5/compat.py
0 → 100644
View file @
75f50648
from
__future__
import
absolute_import
,
division
,
print_function
from
builtins
import
(
ascii
,
bytes
,
chr
,
dict
,
filter
,
hex
,
input
,
map
,
next
,
oct
,
open
,
pow
,
range
,
round
,
super
,
zip
)
from
functools
import
reduce
nifty5/data_objects/distributed_do.py
View file @
75f50648
...
...
@@ -16,9 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
functools
import
reduce
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
numpy
as
np
from
.random
import
Random
from
mpi4py
import
MPI
...
...
nifty5/data_objects/random.py
View file @
75f50648
...
...
@@ -16,7 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
builtins
import
object
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
numpy
as
np
...
...
nifty5/domain_tuple.py
View file @
75f50648
...
...
@@ -16,9 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
functools
import
reduce
from
__future__
import
absolute_import
,
division
,
print_function
from
.compat
import
*
from
.domains.domain
import
Domain
...
...
@@ -138,8 +137,7 @@ class DomainTuple(object):
def
__eq__
(
self
,
x
):
if
self
is
x
:
return
True
x
=
DomainTuple
.
make
(
x
)
return
self
is
x
return
self
is
DomainTuple
.
make
(
x
)
def
__ne__
(
self
,
x
):
return
not
self
.
__eq__
(
x
)
...
...
nifty5/domains/log_rg_space.py
View file @
75f50648
from
functools
import
reduce
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
from
..sugar
import
exp
import
numpy
as
np
from
..
import
dobj
from
..field
import
Field
from
.structured_domain
import
StructuredDomain
...
...
nifty5/domains/rg_space.py
View file @
75f50648
...
...
@@ -16,9 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
division
from
builtins
import
range
from
functools
import
reduce
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
numpy
as
np
from
.structured_domain
import
StructuredDomain
from
..field
import
Field
...
...
nifty5/domains/unstructured_domain.py
View file @
75f50648
...
...
@@ -16,8 +16,9 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
from
.domain
import
Domain
from
functools
import
reduce
class
UnstructuredDomain
(
Domain
):
...
...
nifty5/energies/kl.py
View file @
75f50648
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
from
..minimization.energy
import
Energy
from
..utilities
import
memo
,
my_sum
...
...
nifty5/extra/energy_and_model_tests.py
View file @
75f50648
...
...
@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
numpy
as
np
from
..sugar
import
from_random
from
..minimization.energy
import
Energy
...
...
nifty5/field.py
View file @
75f50648
...
...
@@ -16,12 +16,11 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
.compat
import
*
import
numpy
as
np
from
.
import
utilities
from
.domain_tuple
import
DomainTuple
from
functools
import
reduce
from
.
import
dobj
...
...
@@ -338,7 +337,7 @@ class Field(object):
raise
TypeError
(
"The dot-partner must be an instance of "
+
"the NIFTy field class"
)
if
x
.
_domain
!=
self
.
_domain
:
if
x
.
_domain
is
not
self
.
_domain
:
raise
ValueError
(
"Domain mismatch"
)
ndom
=
len
(
self
.
_domain
)
...
...
@@ -603,7 +602,7 @@ class Field(object):
return
True
if
not
isinstance
(
other
,
Field
):
return
False
if
self
.
_domain
!=
other
.
_domain
:
if
self
.
_domain
is
not
other
.
_domain
:
return
False
return
(
self
.
_val
==
other
.
_val
).
all
()
...
...
@@ -625,7 +624,7 @@ for op in ["__add__", "__radd__",
def
func2
(
self
,
other
):
# if other is a field, make sure that the domains match
if
isinstance
(
other
,
Field
):
if
other
.
_domain
!=
self
.
_domain
:
if
other
.
_domain
is
not
self
.
_domain
:
raise
ValueError
(
"domains are incompatible."
)
tval
=
getattr
(
self
.
val
,
op
)(
other
.
val
)
return
Field
(
self
.
_domain
,
tval
)
...
...
nifty5/logger.py
View file @
75f50648
...
...
@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
.compat
import
*
def
_logger_init
():
...
...
nifty5/minimization/energy_sum.py
View file @
75f50648
...
...
@@ -16,7 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
from
..utilities
import
memo
,
my_lincomb_simple
,
my_lincomb
from
.energy
import
Energy
...
...
nifty5/minimization/iteration_controller.py
View file @
75f50648
...
...
@@ -16,7 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
builtins
import
range
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
abc
from
..utilities
import
NiftyMetaBase
...
...
nifty5/minimization/l_bfgs.py
View file @
75f50648
...
...
@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
from
..logger
import
logger
from
.descent_minimizer
import
DescentMinimizer
from
.line_search_strong_wolfe
import
LineSearchStrongWolfe
...
...
nifty5/minimization/line_search_strong_wolfe.py
View file @
75f50648
...
...
@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
divis
ion
from
builtins
import
range
from
__future__
import
absolute_import
,
division
,
print_funct
ion
from
..compat
import
*
import
numpy
as
np
from
.line_search
import
LineSearch
from
.line_energy
import
LineEnergy
...
...
nifty5/minimization/vl_bfgs.py
View file @
75f50648
...
...
@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
numpy
as
np
from
.descent_minimizer
import
DescentMinimizer
from
.line_search_strong_wolfe
import
LineSearchStrongWolfe
...
...
nifty5/operators/chain_operator.py
View file @
75f50648
...
...
@@ -38,7 +38,7 @@ class ChainOperator(LinearOperator):
from
.diagonal_operator
import
DiagonalOperator
# Step 1: verify domains
for
i
in
range
(
len
(
ops
)
-
1
):
if
ops
[
i
+
1
].
target
!=
ops
[
i
].
domain
:
if
ops
[
i
+
1
].
target
is
not
ops
[
i
].
domain
:
raise
ValueError
(
"domain mismatch"
)
# Step 2: unpack ChainOperators
opsnew
=
[]
...
...
nifty5/operators/diagonal_operator.py
View file @
75f50648
...
...
@@ -16,8 +16,8 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
(
absolute_import
,
division
,
print_function
)
from
builtins
import
*
from
__future__
import
absolute_import
,
division
,
print_function
from
..compat
import
*
import
numpy
as
np
from
..field
import
Field
from
..domain_tuple
import
DomainTuple
...
...
@@ -66,7 +66,7 @@ class DiagonalOperator(EndomorphicOperator):
self
.
_domain
=
DomainTuple
.
make
(
domain
)
if
spaces
is
None
:
self
.
_spaces
=
None
if
diagonal
.
domain
!=
self
.
_domain
:
if
diagonal
.
domain
is
not
self
.
_domain
:
raise
ValueError
(
"domain mismatch"
)
else
:
self
.
_spaces
=
utilities
.
parse_spaces
(
spaces
,
len
(
self
.
_domain
))
...
...
nifty5/operators/fft_operator.py
View file @
75f50648
...
...
@@ -73,7 +73,7 @@ class FFTOperator(LinearOperator):
def
_apply_cartesian
(
self
,
x
,
mode
):
axes
=
x
.
domain
.
axes
[
self
.
_space
]
tdom
=
self
.
_t
arget
if
x
.
domain
==
self
.
_domain
else
self
.
_domain
tdom
=
self
.
_t
gt
(
mode
)
oldax
=
dobj
.
distaxis
(
x
.
val
)
if
oldax
not
in
axes
:
# straightforward, no redistribution needed
ldat
=
x
.
local_data
...
...
nifty5/operators/sht_operator.py
View file @
75f50648
...
...
@@ -121,7 +121,7 @@ class SHTOperator(LinearOperator):
distaxis
=
dobj
.
distaxis
(
tval
)
p2h
=
not
x
.
domain
[
self
.
_space
].
harmonic
tdom
=
self
.
_t
arget
if
x
.
domain
==
self
.
_domain
else
self
.
_domain
tdom
=
self
.
_t
gt
(
mode
)
func
=
self
.
_slice_p2h
if
p2h
else
self
.
_slice_h2p
idat
=
dobj
.
local_data
(
tval
)
odat
=
np
.
empty
(
dobj
.
local_shape
(
tdom
.
shape
,
distaxis
=
distaxis
),
...
...
Prev
1
2
Next
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