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
14
Merge Requests
14
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
e7fd7bd1
Commit
e7fd7bd1
authored
Jul 02, 2016
by
theos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed field to Field; removed space; point_space is now called Space.
parent
25d4a36c
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
136 additions
and
886 deletions
+136
-886
__init__.py
__init__.py
+7
-5
demos/demo_excaliwir.py
demos/demo_excaliwir.py
+4
-4
demos/demo_wf1.py
demos/demo_wf1.py
+4
-4
demos/demo_wf2.py
demos/demo_wf2.py
+3
-3
demos/demo_wf3.py
demos/demo_wf3.py
+1
-1
field.py
field.py
+21
-19
lm/nifty_lm.py
lm/nifty_lm.py
+11
-11
lm/nifty_power_conversion_lm.py
lm/nifty_power_conversion_lm.py
+3
-3
nifty_paradict.py
nifty_paradict.py
+0
-178
nifty_simple_math.py
nifty_simple_math.py
+1
-1
nifty_utilities.py
nifty_utilities.py
+1
-0
operators/nifty_minimization.py
operators/nifty_minimization.py
+3
-3
operators/nifty_operators.py
operators/nifty_operators.py
+30
-28
operators/nifty_probing.py
operators/nifty_probing.py
+10
-15
rg/nifty_power_conversion_rg.py
rg/nifty_power_conversion_rg.py
+3
-3
rg/nifty_rg.py
rg/nifty_rg.py
+8
-8
setup.py
setup.py
+1
-1
space.py
space.py
+9
-586
test/test_nifty_field.py
test/test_nifty_field.py
+14
-11
test/test_nifty_spaces.py
test/test_nifty_spaces.py
+2
-2
No files found.
__init__.py
View file @
e7fd7bd1
...
...
@@ -38,17 +38,19 @@ from config import about,\
from
d2o
import
distributed_data_object
,
d2o_librarian
from
nifty_cmaps
import
ncmap
from
nifty_field
import
field
from
nifty_core
import
space
,
\
point_space
from
field
import
Field
from
space
import
Space
# this line exists for compatibility reasons
# TODO: Remove this once the transition to field types is done.
from
space
import
Space
as
point_space
from
nifty_random
import
random
from
nifty_simple_math
import
*
from
nifty_utilities
import
*
from
nifty_paradict
import
space_paradict
,
\
point_space_paradict
,
\
nested_space_paradict
nested_space_paradict
from
field_types
import
FieldType
,
\
FieldArray
...
...
demos/demo_excaliwir.py
View file @
e7fd7bd1
...
...
@@ -112,7 +112,7 @@ class problem(object):
Parameters
----------
newspace : {scalar, list, array,
f
ield, function}, *optional*
newspace : {scalar, list, array,
F
ield, function}, *optional*
Assumed power spectrum (default: k ** -2).
"""
...
...
@@ -135,7 +135,7 @@ class problem(object):
Parameters
----------
newspace : {scalar, list, array,
f
ield, function}, *optional*
newspace : {scalar, list, array,
F
ield, function}, *optional*
Initial power spectrum (default: k ** -2).
q : {scalar, list, array}, *optional*
Spectral scale parameter of the assumed inverse-Gamme prior
...
...
@@ -210,7 +210,7 @@ class problem(object):
self
.
s
.
plot
(
title
=
"signal"
,
save
=
"img/signal.png"
)
try
:
d_
=
f
ield
(
self
.
z
,
val
=
self
.
d
.
val
,
target
=
self
.
k
)
d_
=
F
ield
(
self
.
z
,
val
=
self
.
d
.
val
,
target
=
self
.
k
)
d_
.
plot
(
title
=
"data"
,
vmin
=
self
.
s
.
min
(),
vmax
=
self
.
s
.
max
(),
save
=
"img/data.png"
)
except
:
...
...
@@ -240,7 +240,7 @@ class problem(object):
self
.
s
.
plot
(
title
=
"signal"
)
## plot data
try
:
d_
=
f
ield
(
self
.
z
,
val
=
self
.
d
.
val
,
target
=
self
.
k
)
d_
=
F
ield
(
self
.
z
,
val
=
self
.
d
.
val
,
target
=
self
.
k
)
d_
.
plot
(
title
=
"data"
,
vmin
=
self
.
s
.
min
(),
vmax
=
self
.
s
.
max
())
except
:
pass
...
...
demos/demo_wf1.py
View file @
e7fd7bd1
...
...
@@ -72,7 +72,7 @@ if __name__ == "__main__":
# some noise variance; e.g., signal-to-noise ratio of 1
N
=
diagonal_operator
(
d_space
,
diag
=
s
.
var
(),
bare
=
True
)
# define noise covariance
n
=
N
.
get_random_
f
ield
(
domain
=
d_space
)
# generate noise
n
=
N
.
get_random_
F
ield
(
domain
=
d_space
)
# generate noise
d
=
R
(
s
)
+
n
# compute data
...
...
@@ -84,7 +84,7 @@ if __name__ == "__main__":
#m = D(j, tol=1E-8, limii=20, note=True, force=True)
ident
=
identity
(
x_space
)
#xi =
f
ield(x_space, random='gau', target=k_space)
#xi =
F
ield(x_space, random='gau', target=k_space)
m
=
D
(
j
,
W
=
S
,
tol
=
1E-8
,
limii
=
100
,
note
=
True
)
...
...
@@ -101,11 +101,11 @@ if __name__ == "__main__":
mono
=
False
,
save
=
'power_plot_s.png'
,
nbin
=
1000
,
log
=
True
,
vmax
=
100
,
vmin
=
10e-7
)
d_
=
f
ield
(
x_space
,
val
=
d
.
val
,
target
=
k_space
)
d_
=
F
ield
(
x_space
,
val
=
d
.
val
,
target
=
k_space
)
d_
.
plot
(
title
=
"data"
,
vmin
=
s
.
min
(),
vmax
=
s
.
max
(),
save
=
'plot_d.png'
)
n_
=
f
ield
(
x_space
,
val
=
n
.
val
,
target
=
k_space
)
n_
=
F
ield
(
x_space
,
val
=
n
.
val
,
target
=
k_space
)
n_
.
plot
(
title
=
"data"
,
vmin
=
s
.
min
(),
vmax
=
s
.
max
(),
save
=
'plot_n.png'
)
...
...
demos/demo_wf2.py
View file @
e7fd7bd1
...
...
@@ -103,15 +103,15 @@ if __name__ == "__main__":
return
energy
(
x
),
gradient
(
x
)
m
=
f
ield
(
x_space
,
codomain
=
k_space
)
# reconstruct map
m
=
F
ield
(
x_space
,
codomain
=
k_space
)
# reconstruct map
#with PyCallGraph(output=graphviz, config=config):
m
,
convergence
=
steepest_descent
(
eggs
=
eggs
,
note
=
True
)(
m
,
tol
=
1E-3
,
clevel
=
3
)
m
=
f
ield
(
x_space
,
codomain
=
k_space
)
m
=
F
ield
(
x_space
,
codomain
=
k_space
)
m
,
convergence
=
steepest_descent_new
(
energy
,
gradient
,
note
=
True
)(
m
,
tol
=
1E-3
,
clevel
=
3
)
#s.plot(title="signal") # plot signal
#d_ =
f
ield(x_space, val=d.val, target=k_space)
#d_ =
F
ield(x_space, val=d.val, target=k_space)
#d_.plot(title="data", vmin=s.min(), vmax=s.max()) # plot data
#m.plot(title="reconstructed map", vmin=s.min(), vmax=s.max()) # plot map
demos/demo_wf3.py
View file @
e7fd7bd1
...
...
@@ -79,7 +79,7 @@ if __name__ == "__main__":
vminmax
=
{
"vmin"
:
1.5
*
s
.
val
.
min
(),
"vmax"
:
1.5
*
s
.
val
.
max
()}
s
.
plot
(
title
=
"signal"
,
**
vminmax
)
# plot signal
d_
=
f
ield
(
x_space
,
val
=
d
.
val
,
target
=
k_space
)
d_
=
F
ield
(
x_space
,
val
=
d
.
val
,
target
=
k_space
)
d_
.
plot
(
title
=
"data"
,
**
vminmax
)
# plot data
m
.
plot
(
title
=
"reconstructed map"
,
error
=
D
.
diag
(
bare
=
True
),
**
vminmax
)
# plot map
D
.
plot
(
title
=
"information propagator"
,
bare
=
True
)
# plot information propagator
...
...
nifty_
field.py
→
field.py
View file @
e7fd7bd1
...
...
@@ -9,10 +9,10 @@ from nifty.config import about, \
nifty_configuration
as
gc
,
\
dependency_injector
as
gdi
from
nifty.field_types
import
Field
_t
ype
,
\
Field
_a
rray
from
nifty.field_types
import
Field
T
ype
,
\
Field
A
rray
from
nifty.
nifty_core
import
s
pace
from
nifty.
space
import
S
pace
import
nifty.nifty_utilities
as
utilities
from
nifty_random
import
random
...
...
@@ -20,7 +20,7 @@ from nifty_random import random
POINT_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
f
ield
(
object
):
class
F
ield
(
object
):
"""
.. ____ __ __ __
.. / _/ /__/ / / / /
...
...
@@ -133,7 +133,7 @@ class field(object):
"""
# If the given val was a field, try to cast it accordingly to the given
# domain and codomain, etc...
if
isinstance
(
val
,
f
ield
):
if
isinstance
(
val
,
F
ield
):
self
.
_init_from_field
(
f
=
val
,
domain
=
domain
,
codomain
=
codomain
,
...
...
@@ -273,7 +273,7 @@ class field(object):
elif
not
isinstance
(
domain
,
tuple
):
domain
=
(
domain
,)
for
d
in
domain
:
if
not
isinstance
(
d
,
s
pace
):
if
not
isinstance
(
d
,
S
pace
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: Given domain contains something that is not a "
"nifty.space."
))
...
...
@@ -286,7 +286,7 @@ class field(object):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: domain and codomain do not have the same length."
))
for
(
cd
,
d
)
in
zip
(
codomain
,
domain
):
if
not
isinstance
(
cd
,
s
pace
):
if
not
isinstance
(
cd
,
S
pace
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: Given codomain contains something that is not a"
"nifty.space."
))
...
...
@@ -302,9 +302,9 @@ class field(object):
elif
not
isinstance
(
field_type
,
tuple
):
field_type
=
(
field_type
,)
for
ft
in
field_type
:
if
not
isinstance
(
ft
,
Field
_t
ype
):
if
not
isinstance
(
ft
,
Field
T
ype
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: Given object is not a nifty.Field
_t
ype."
))
"ERROR: Given object is not a nifty.Field
T
ype."
))
return
field_type
def
_build_codomain
(
self
,
domain
):
...
...
@@ -417,7 +417,7 @@ class field(object):
kwargs
==
{}):
new_field
=
self
.
_fast_copy_empty
()
else
:
new_field
=
f
ield
(
domain
=
domain
,
codomain
=
codomain
,
dtype
=
dtype
,
new_field
=
F
ield
(
domain
=
domain
,
codomain
=
codomain
,
dtype
=
dtype
,
comm
=
comm
,
datamodel
=
datamodel
,
field_type
=
field_type
,
**
kwargs
)
return
new_field
...
...
@@ -543,7 +543,7 @@ class field(object):
Whether the method should raise a warning if information is
lost during casting (default: False).
"""
if
isinstance
(
x
,
f
ield
):
if
isinstance
(
x
,
F
ield
):
x
=
x
.
get_val
()
if
dtype
is
None
:
...
...
@@ -695,7 +695,7 @@ class field(object):
return
None
# Case 2: x is a field
elif
isinstance
(
x
,
f
ield
):
elif
isinstance
(
x
,
F
ield
):
for
ind
,
sp
in
enumerate
(
self
.
domain
):
assert
sp
==
x
.
domain
[
ind
]
...
...
@@ -1281,8 +1281,8 @@ class field(object):
def
_binary_helper
(
self
,
other
,
op
=
'None'
,
inplace
=
False
):
# if other is a field, make sure that the domains match
if
isinstance
(
other
,
f
ield
):
other
=
f
ield
(
domain
=
self
.
domain
,
if
isinstance
(
other
,
F
ield
):
other
=
F
ield
(
domain
=
self
.
domain
,
val
=
other
,
codomain
=
self
.
codomain
,
copy
=
False
)
...
...
@@ -1326,11 +1326,13 @@ class field(object):
'mean'
:
lambda
y
:
getattr
(
y
,
'mean'
)(
axis
=
axis
),
'std'
:
lambda
y
:
getattr
(
y
,
'std'
)(
axis
=
axis
),
'var'
:
lambda
y
:
getattr
(
y
,
'var'
)(
axis
=
axis
),
'argmin_nonflat'
:
lambda
y
:
getattr
(
y
,
'argmin_nonflat'
)(
axis
=
axis
),
'argmin_nonflat'
:
lambda
y
:
getattr
(
y
,
'argmin_nonflat'
)(
axis
=
axis
),
'argmin'
:
lambda
y
:
getattr
(
y
,
'argmin'
)(
axis
=
axis
),
'argmax_nonflat'
:
lambda
y
:
getattr
(
y
,
'argmax_nonflat'
)(
axis
=
axis
),
'argmax_nonflat'
:
lambda
y
:
getattr
(
y
,
'argmax_nonflat'
)(
axis
=
axis
),
'argmax'
:
lambda
y
:
getattr
(
y
,
'argmax'
)(
axis
=
axis
),
'conjugate'
:
lambda
y
:
getattr
(
y
,
'conjugate'
)(),
'sum'
:
lambda
y
:
getattr
(
y
,
'sum'
)(
axis
=
axis
),
...
...
@@ -1451,6 +1453,6 @@ class field(object):
return
self
.
_binary_helper
(
other
,
op
=
'gt'
)
class
EmptyField
(
f
ield
):
class
EmptyField
(
F
ield
):
def
__init__
(
self
):
pass
lm/nifty_lm.py
View file @
e7fd7bd1
...
...
@@ -41,10 +41,9 @@ from matplotlib.ticker import LogFormatter as lf
from
d2o
import
STRATEGIES
as
DISTRIBUTION_STRATEGIES
from
nifty.nifty_core
import
space
,
\
point_space
from
nifty.nifty_core
import
Space
from
nifty.
nifty_field
import
f
ield
from
nifty.
field
import
F
ield
from
nifty.config
import
about
,
\
nifty_configuration
as
gc
,
\
...
...
@@ -63,7 +62,7 @@ GL_DISTRIBUTION_STRATEGIES = DISTRIBUTION_STRATEGIES['global']
HP_DISTRIBUTION_STRATEGIES
=
DISTRIBUTION_STRATEGIES
[
'global'
]
class
lm_space
(
point_s
pace
):
class
lm_space
(
S
pace
):
"""
.. __
.. / /
...
...
@@ -277,7 +276,7 @@ class lm_space(point_space):
mol
[
self
.
paradict
[
'lmax'
]
+
1
:]
=
2
# redundant: (l,m) and (l,-m)
return
mol
def
_
complement_cast
(
self
,
x
,
axis
=
None
,
**
kwargs
):
def
complement_cast
(
self
,
x
,
axis
=
None
,
**
kwargs
):
if
axis
is
None
:
lmax
=
self
.
paradict
[
'lmax'
]
complexity_mask
=
x
[:
lmax
+
1
].
iscomplex
()
...
...
@@ -912,7 +911,7 @@ class lm_space(point_space):
return
l
,
m
class
gl_space
(
point_s
pace
):
class
gl_space
(
S
pace
):
"""
.. __
.. / /
...
...
@@ -1256,12 +1255,13 @@ class gl_space(point_space):
p
=
np
.
float32
(
power
),
nlat
=
nlat
,
nlon
=
nlon
,
overwrite
=
False
)
return
self
.
cast
(
np_result
)
# return self.cast(np_result)
return
np_result
def
get_weight
(
self
,
power
=
1
):
# TODO: Check if this function is compatible to the rest of nifty
# TODO: Can this be done more efficiently?
dummy
=
self
.
dtype
(
1
)
dummy
=
self
.
dtype
.
type
(
1
)
weighted_dummy
=
self
.
calc_weight
(
dummy
,
power
=
power
)
return
weighted_dummy
/
dummy
...
...
@@ -1571,7 +1571,7 @@ class gl_space(point_space):
fig
.
canvas
.
draw
()
class
hp_space
(
point_s
pace
):
class
hp_space
(
S
pace
):
"""
.. __
.. / /
...
...
@@ -2082,11 +2082,11 @@ class hp_space(point_space):
if
(
isinstance
(
other
,
tuple
)):
other
=
list
(
other
)
for
ii
in
xrange
(
len
(
other
)):
if
(
isinstance
(
other
[
ii
],
f
ield
)):
if
(
isinstance
(
other
[
ii
],
F
ield
)):
other
[
ii
]
=
other
[
ii
].
power
(
**
kwargs
)
else
:
other
[
ii
]
=
self
.
enforce_power
(
other
[
ii
])
elif
(
isinstance
(
other
,
f
ield
)):
elif
(
isinstance
(
other
,
F
ield
)):
other
=
[
other
.
power
(
**
kwargs
)]
else
:
other
=
[
self
.
enforce_power
(
other
)]
...
...
lm/nifty_power_conversion_lm.py
View file @
e7fd7bd1
...
...
@@ -23,7 +23,7 @@
import
numpy
as
np
from
numpy
import
pi
from
nifty.config
import
about
from
nifty.
nifty_field
import
f
ield
from
nifty.
field
import
F
ield
from
nifty.nifty_simple_math
import
sqrt
,
exp
,
log
...
...
@@ -71,7 +71,7 @@ def power_backward_conversion_lm(k_space,p,mean=None):
p
[
0
]
=
4
*
pi
*
mean
**
2
klen
=
k_space
.
get_power_indices
()[
0
]
C_0_Omega
=
f
ield
(
k_space
,
val
=
0
)
C_0_Omega
=
F
ield
(
k_space
,
val
=
0
)
C_0_Omega
.
val
[:
len
(
klen
)]
=
p
*
sqrt
(
2
*
klen
+
1
)
/
sqrt
(
4
*
pi
)
C_0_Omega
=
C_0_Omega
.
transform
()
...
...
@@ -130,7 +130,7 @@ def power_forward_conversion_lm(k_space,p,mean=0):
"""
m
=
mean
klen
=
k_space
.
get_power_indices
()[
0
]
C_0_Omega
=
f
ield
(
k_space
,
val
=
0
)
C_0_Omega
=
F
ield
(
k_space
,
val
=
0
)
C_0_Omega
.
val
[:
len
(
klen
)]
=
p
*
sqrt
(
2
*
klen
+
1
)
/
sqrt
(
4
*
pi
)
C_0_Omega
=
C_0_Omega
.
transform
()
...
...
nifty_paradict.py
View file @
e7fd7bd1
...
...
@@ -48,22 +48,6 @@ class space_paradict(object):
return
result_hash
class
point_space_paradict
(
space_paradict
):
def
__setitem__
(
self
,
key
,
arg
):
if
key
is
not
'num'
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: Unsupported point_space parameter"
))
if
not
np
.
isscalar
(
arg
):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: 'num' parameter must be scalar. Got: "
+
str
(
arg
)))
if
abs
(
arg
)
!=
arg
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: 'num' parameter must be positive. Got: "
+
str
(
arg
)))
temp
=
np
.
int
(
arg
)
self
.
parameters
.
__setitem__
(
key
,
temp
)
class
rg_space_paradict
(
space_paradict
):
def
__init__
(
self
,
shape
,
complexity
,
zerocenter
):
...
...
@@ -218,165 +202,3 @@ class hp_space_paradict(space_paradict):
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: invalid parameter ( nside <> 2**n )."
))
self
.
parameters
.
__setitem__
(
key
,
temp
)
###################
#
#
# class _space(object):
# def __init__(self):
# self.paradict = space_paradict(default=123)
# #self.para = [1,2,3]
#
# @property
# def para(self):
# return self.paradict['default']
# #return self.distributed_val
#
# @para.setter
# def para(self, x):
# self.paradict['default'] = x
#
###################
###################
#
#
#
# class _point_space(object):
# def __init__(self):
# self.paradict = point_space_paradict()
# self.para = [10]
#
# @property
# def para(self):
# temp = np.array([self.paradict['num']], dtype=int)
# return temp
# #return self.distributed_val
#
# @para.setter
# def para(self, x):
# self.paradict['num'] = x
#
###################
###################
#
#
# class _rg_space(object):
# def __init__(self):
# self.paradict = rg_space_paradict(num=[10,100,200])
#
# @property
# def para(self):
# temp = np.array(self.paradict['num'] + \
# [self.paradict['hermitian']] + \
# self.paradict['zerocenter'], dtype=int)
# return temp
#
#
# @para.setter
# def para(self, x):
# self.paradict['num'] = x[:(np.size(x)-1)//2]
# self.paradict['zerocenter'] = x[(np.size(x)+1)//2:]
# self.paradict['complexity'] = x[(np.size(x)-1)//2]
#
###################
###################
#
# class _nested_space(object):
# def __init__(self):
# self.paradict = nested_space_paradict(ndim=10)
# for i in range(10):
# self.paradict[i] = [1+i, 2+i, 3+i]
#
# @property
# def para(self):
# temp = []
# for i in range(self.paradict.ndim):
# temp = np.append(temp, self.paradict[i])
# return temp
#
# @para.setter
# def para(self, x):
# dict_iter = 0
# x_iter = 0
# while dict_iter < self.paradict.ndim:
# temp = x[x_iter:x_iter+len(self.paradict[dict_iter])]
# self.paradict[dict_iter] = temp
# x_iter = x_iter+len(self.paradict[dict_iter])
# dict_iter += 1
#
###################
###################
#
# class _lm_space(object):
# def __init__(self):
# self.paradict = lm_space_paradict(lmax = 10)
#
# @property
# def para(self):
# temp = np.array([self.paradict['lmax'],
# self.paradict['mmax']], dtype=int)
# return temp
#
#
# @para.setter
# def para(self, x):
# self.paradict['lmax'] = x[0]
# self.paradict['mmax'] = x[1]
#
#
###################
###################
#
# class _gl_space(object):
# def __init__(self):
# self.paradict = gl_space_paradict(nlat = 10)
#
# @property
# def para(self):
# temp = np.array([self.paradict['nlat'],
# self.paradict['nlon']], dtype=int)
# return temp
#
#
# @para.setter
# def para(self, x):
# self.paradict['nlat'] = x[0]
# self.paradict['nlon'] = x[1]
#
#
###################
###################
#
#
# class _hp_space(object):
# def __init__(self):
# self.paradict = hp_space_paradict(nside=16)
#
# @property
# def para(self):
# temp = np.array([self.paradict['nside']], dtype=int)
# return temp
#
#
# @para.setter
# def para(self, x):
# self.paradict['nside'] = x[0]
#
#
#
###################
###################
#
#
#
# if __name__ == '__main__':
# myspace = _space()
# print myspace.para
# print myspace.paradict.parameters.items()
# myspace.para = [4,5,6]
# print myspace.para
# print myspace.paradict.parameters.items()
#
# myspace.paradict.parameters['default'] = [1,4,7]
# print myspace.para
# print myspace.paradict.parameters.items()
nifty_simple_math.py
View file @
e7fd7bd1
...
...
@@ -22,7 +22,7 @@
##-----------------------------------------------------------------------------
import
numpy
as
np
#from nifty.
nifty_core import f
ield
#from nifty.
field import F
ield
from
nifty.config
import
about
...
...
nifty_utilities.py
View file @
e7fd7bd1
...
...
@@ -5,6 +5,7 @@ from itertools import product
from
nifty.config
import
about
def
get_slice_list
(
shape
,
axes
):
"""
Helper function which generates slice list(s) to traverse over all
...
...
operators/nifty_minimization.py
View file @
e7fd7bd1
...
...
@@ -40,7 +40,7 @@ from __future__ import division
#from nifty_core import *
import
numpy
as
np
from
nifty.config
import
notification
,
about
from
nifty.
nifty_field
import
f
ield
from
nifty.
field
import
F
ield
from
nifty.nifty_simple_math
import
vdot
...
...
@@ -555,7 +555,7 @@ class steepest_descent(object):
has converged or not.
"""
if
(
not
isinstance
(
x0
,
f
ield
)):
if
(
not
isinstance
(
x0
,
F
ield
)):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: invalid input."
))
self
.
x
=
x0
...
...
@@ -844,7 +844,7 @@ class quasi_newton_minimizer(object):
has converged or not.
"""
if
not
isinstance
(
x0
,
f
ield
):
if
not
isinstance
(
x0
,
F
ield
):
raise
TypeError
(
about
.
_errors
.
cstring
(
"ERROR: invalid input."
))
self
.
x
=
x0
...
...
operators/nifty_operators.py
View file @
e7fd7bd1
...
...
@@ -22,9 +22,9 @@
from
__future__
import
division
import
numpy
as
np
from
nifty.config
import
about
from
nifty.
nifty_field
import
f
ield
from
nifty.
nifty_core
import
space
,
\
point_space
from
nifty.
field
import
F
ield
from
nifty.
space
import
Space
from
nifty_minimization
import
conjugate_gradient
from
nifty_probing
import
trace_prober
,
\
inverse_trace_prober
,
\
...
...
@@ -227,7 +227,7 @@ class operator(object):
def
_briefing
(
self
,
x
,
domain
,
codomain
,
inverse
):
# make sure, that the result_field of the briefing lives in the
# given domain and codomain
result_field
=
f
ield
(
domain
=
domain
,
val
=
x
,
codomain
=
codomain
,
result_field
=
F
ield
(
domain
=
domain
,
val
=
x
,
codomain
=
codomain
,
copy
=
False
)
# weight if necessary
...
...
@@ -238,7 +238,7 @@ class operator(object):
def
_debriefing
(
self
,
x
,
y
,
target
,
cotarget
,
inverse
):
# The debriefing takes care that the result field lives in the same
# fourier-type domain as the input field
assert
(
isinstance
(
y
,
f
ield
))
assert
(
isinstance
(
y
,
F
ield
))
# weight if necessary
if
(
not
self
.
imp
)
and
(
not
target
.
discrete
)
and
inverse
:
...
...
@@ -1402,7 +1402,7 @@ class diagonal_operator(operator):
diag_val
=
self
.
domain
.
calc_weight
(
self
.
val
,
power
=-
1
)
else
:
diag_val
=
self
.
val
diag
=
f
ield
(
self
.
domain
,
codomain
=
self
.
codomain
,
val
=
diag_val
)
diag
=
F
ield
(
self
.
domain
,
codomain
=
self
.
codomain
,
val
=
diag_val
)
else
:
diag
=
super
(
diagonal_operator
,
self
).
diag
(
bare
=
bare
,
domain
=
domain
,
...
...
@@ -1490,7 +1490,7 @@ class diagonal_operator(operator):
power
=-
1
)
else
:
inverse_diag_val
=
inverse_val
inverse_diag
=
f
ield
(
self
.
domain
,
codomain
=
self
.
codomain
,
inverse_diag
=
F
ield
(
self
.
domain
,
codomain
=
self
.
codomain
,
val
=
inverse_diag_val
)
else
:
...
...
@@ -1578,7 +1578,7 @@ class diagonal_operator(operator):
Random field.
"""
temp_field
=
f
ield
(
domain
=
self
.
domain
,
temp_field
=
F
ield
(
domain
=
self
.
domain
,
codomain
=
self
.
codomain
,
random
=
'gau'
,
std
=
nifty_simple_math
.
sqrt
(
...
...
@@ -1592,7 +1592,7 @@ class diagonal_operator(operator):
else
:
codomain
=
domain
.
get_codomain
()
return
f
ield
(
domain
=
domain
,
val
=
temp_field
,
codomain
=
codomain
)
return
F
ield
(
domain
=
domain
,
val
=
temp_field
,
codomain
=
codomain
)
# if domain.harmonic != self.domain.harmonic:
# temp_field = temp_field.transform(new_domain=domain)
...
...
@@ -1802,7 +1802,7 @@ class power_operator(diagonal_operator):
"""
# Set the domain