Skip to content
GitLab
Menu
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
63da827d
Commit
63da827d
authored
Jun 02, 2017
by
Martin Reinecke
Browse files
replace ** with clearer operators where possible
parent
4af562db
Pipeline
#13245
passed with stage
in 5 minutes and 17 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
nifty/field.py
View file @
63da827d
...
...
@@ -409,7 +409,7 @@ class Field(Loggable, Versionable, object):
def
_calculate_power_spectrum
(
self
,
x
,
pindex
,
rho
,
axes
=
None
):
fieldabs
=
abs
(
x
)
fieldabs
*
*=
2
fieldabs
*=
fieldabs
if
axes
is
not
None
:
pindex
=
self
.
_shape_up_pindex
(
...
...
@@ -425,7 +425,7 @@ class Field(Loggable, Versionable, object):
rho
=
rho
.
reshape
(
new_rho_shape
)
power_spectrum
/=
rho
power_spectrum
**=
0.5
power_spectrum
=
sqrt
(
power_spectrum
)
return
power_spectrum
def
_shape_up_pindex
(
self
,
pindex
,
target_shape
,
target_strategy
,
axes
):
...
...
nifty/minimization/line_searching/line_search_strong_wolfe.py
View file @
63da827d
...
...
@@ -65,7 +65,6 @@ class LineSearchStrongWolfe(LineSearch):
max_step_size
=
50
,
max_iterations
=
10
,
max_zoom_iterations
=
10
):
super
(
LineSearchStrongWolfe
,
self
).
__init__
()
self
.
c1
=
np
.
float
(
c1
)
...
...
@@ -308,7 +307,8 @@ class LineSearchStrongWolfe(LineSearch):
"""Estimating the minimum with cubic interpolation.
Finds the minimizer for a cubic polynomial that goes through the
points ( a,f(a) ), ( b,f(b) ), and ( c,f(c) ) with derivative at point a of fpa.
points ( a,f(a) ), ( b,f(b) ), and ( c,f(c) ) with derivative at point
a of fpa.
f(x) = A *(x-a)^3 + B*(x-a)^2 + C*(x-a) + D
If no minimizer can be found return None
...
...
@@ -341,12 +341,12 @@ class LineSearchStrongWolfe(LineSearch):
C
=
fpa
db
=
b
-
a
dc
=
c
-
a
denom
=
(
db
*
dc
)
**
2
*
(
db
-
dc
)
denom
=
db
*
db
*
dc
*
dc
*
(
db
-
dc
)
d1
=
np
.
empty
((
2
,
2
))
d1
[
0
,
0
]
=
dc
*
*
2
d1
[
0
,
1
]
=
-
db
**
2
d1
[
1
,
0
]
=
-
dc
**
3
d1
[
1
,
1
]
=
db
**
3
d1
[
0
,
0
]
=
dc
*
dc
d1
[
0
,
1
]
=
-
(
db
*
db
)
d1
[
1
,
0
]
=
-
(
dc
*
dc
*
dc
)
d1
[
1
,
1
]
=
db
*
db
*
db
[
A
,
B
]
=
np
.
dot
(
d1
,
np
.
asarray
([
fb
-
fa
-
C
*
db
,
fc
-
fa
-
C
*
dc
]).
flatten
())
A
/=
denom
...
...
nifty/operators/fft_operator/transformations/rgrgtransformation.py
View file @
63da827d
...
...
@@ -118,7 +118,7 @@ class RGRGTransformation(Transformation):
np
.
absolute
(
np
.
array
(
domain
.
shape
)
*
np
.
array
(
domain
.
distances
)
*
np
.
array
(
codomain
.
distances
)
-
1
)
<
1
0
**
-
7
):
1
e
-7
):
raise
AttributeError
(
"The grid-distances of domain and codomain "
"do not match."
)
...
...
nifty/spaces/hp_space/hp_space.py
View file @
63da827d
...
...
@@ -93,11 +93,11 @@ class HPSpace(Space):
@
property
def
shape
(
self
):
return
(
np
.
int
(
12
*
self
.
nside
*
*
2
),)
return
(
np
.
int
(
12
*
self
.
nside
*
self
.
nside
),)
@
property
def
dim
(
self
):
return
np
.
int
(
12
*
self
.
nside
*
*
2
)
return
np
.
int
(
12
*
self
.
nside
*
self
.
nside
)
@
property
def
total_volume
(
self
):
...
...
@@ -108,7 +108,7 @@ class HPSpace(Space):
def
weight
(
self
,
x
,
power
=
1
,
axes
=
None
,
inplace
=
False
):
weight
=
((
4
*
np
.
pi
)
/
(
12
*
self
.
nside
*
*
2
))
**
np
.
float
(
power
)
weight
=
((
4
*
np
.
pi
)
/
(
12
*
self
.
nside
*
self
.
nside
))
**
np
.
float
(
power
)
if
inplace
:
x
*=
weight
...
...
nifty/spaces/lm_space/lm_space.py
View file @
63da827d
...
...
@@ -130,7 +130,7 @@ class LMSpace(Space):
# dim = (((2*(l+1)-1)+1)**2/4 - 2 * (l-m)(l-m+1)/2
# dim = np.int((l+1)**2 - (l-m)*(l-m+1.))
# We fix l == m
return
np
.
int
((
l
+
1
)
*
*
2
)
return
np
.
int
((
l
+
1
)
*
(
l
+
1
)
)
@
property
def
total_volume
(
self
):
...
...
@@ -166,7 +166,7 @@ class LMSpace(Space):
def
get_fft_smoothing_kernel_function
(
self
,
sigma
):
# FIXME why x(x+1) ? add reference to paper!
return
lambda
x
:
np
.
exp
(
-
0.5
*
x
*
(
x
+
1
)
*
sigma
*
*
2
)
return
lambda
x
:
np
.
exp
(
-
0.5
*
x
*
(
x
+
1
)
*
sigma
*
sigma
)
# ---Added properties and methods---
...
...
nifty/spaces/rg_space/rg_space.py
View file @
63da827d
...
...
@@ -267,14 +267,16 @@ class RGSpace(Space):
cords
=
np
.
ogrid
[
inds
]
dists
=
((
cords
[
0
]
-
shape
[
0
]
//
2
)
*
dk
[
0
])
**
2
dists
=
(
cords
[
0
]
-
shape
[
0
]
//
2
)
*
dk
[
0
]
dists
*=
dists
# apply zerocenterQ shift
if
not
self
.
zerocenter
[
0
]:
dists
=
np
.
fft
.
ifftshift
(
dists
)
# only save the individual slice
dists
=
dists
[
slice_of_first_dimension
]
for
ii
in
range
(
1
,
len
(
shape
)):
temp
=
((
cords
[
ii
]
-
shape
[
ii
]
//
2
)
*
dk
[
ii
])
**
2
temp
=
(
cords
[
ii
]
-
shape
[
ii
]
//
2
)
*
dk
[
ii
]
temp
*=
temp
if
not
self
.
zerocenter
[
ii
]:
temp
=
np
.
fft
.
ifftshift
(
temp
)
dists
=
dists
+
temp
...
...
@@ -282,7 +284,7 @@ class RGSpace(Space):
return
dists
def
get_fft_smoothing_kernel_function
(
self
,
sigma
):
return
lambda
x
:
np
.
exp
(
-
0.5
*
np
.
pi
*
*
2
*
x
*
*
2
*
sigma
*
*
2
)
return
lambda
x
:
np
.
exp
(
-
0.5
*
np
.
pi
*
np
.
pi
*
x
*
x
*
sigma
*
sigma
)
# ---Added properties and methods---
...
...
nifty/sugar.py
View file @
63da827d
...
...
@@ -54,7 +54,7 @@ def create_power_operator(domain, power_spectrum, dtype=None,
distribution_strategy
=
distribution_strategy
)
fp
=
Field
(
power_domain
,
val
=
power_spectrum
,
dtype
=
dtype
,
distribution_strategy
=
distribution_strategy
)
fp
*
*=
2
fp
*=
fp
f
=
fp
.
power_synthesize
(
mean
=
1
,
std
=
0
,
real_signal
=
False
)
return
DiagonalOperator
(
domain
,
diagonal
=
f
,
bare
=
True
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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