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
11
Merge Requests
11
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
850b5070
Commit
850b5070
authored
Sep 12, 2017
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweaks to random
parent
7834aff5
Pipeline
#18149
passed with stage
in 5 minutes and 34 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
40 deletions
+22
-40
nifty2go/energies/energy.py
nifty2go/energies/energy.py
+1
-1
nifty2go/field.py
nifty2go/field.py
+3
-3
nifty2go/operators/fft_operator/fft_operator_support.py
nifty2go/operators/fft_operator/fft_operator_support.py
+0
-2
nifty2go/random.py
nifty2go/random.py
+18
-34
No files found.
nifty2go/energies/energy.py
View file @
850b5070
...
...
@@ -58,7 +58,7 @@ class Energy(with_metaclass(NiftyMeta, type('NewBase', (object,), {}))):
Memorizing the evaluations of some quantities (using the memo decorator)
minimizes the computational effort for multiple calls.
See
a
lso
See
A
lso
--------
memo
...
...
nifty2go/field.py
View file @
850b5070
...
...
@@ -141,7 +141,7 @@ class Field(object):
# ---Factory methods---
@
classmethod
def
from_random
(
cls
,
random_type
,
domain
,
dtype
=
None
,
**
kwargs
):
def
from_random
(
cls
,
random_type
,
domain
,
dtype
=
np
.
float64
,
**
kwargs
):
""" Draws a random field with the given parameters.
Parameters
...
...
@@ -170,7 +170,7 @@ class Field(object):
generator_function
=
getattr
(
Random
,
random_type
)
return
Field
(
domain
=
domain
,
val
=
generator_function
(
dtype
=
np
.
dtype
(
dtype
)
,
val
=
generator_function
(
dtype
=
dtype
,
shape
=
utilities
.
domains2shape
(
domain
),
**
kwargs
))
# ---Powerspectral methods---
...
...
@@ -319,7 +319,7 @@ class Field(object):
return
result_obj
def
power_synthesize
(
self
,
spaces
=
None
,
real_power
=
True
,
real_signal
=
True
,
mean
=
None
,
std
=
None
):
mean
=
0.
,
std
=
1.
):
""" Yields a sampled field with `self`**2 as its power spectrum.
This method draws a Gaussian random field in the harmonic partner
...
...
nifty2go/operators/fft_operator/fft_operator_support.py
View file @
850b5070
...
...
@@ -157,7 +157,6 @@ class HPLMTransformation(SlicingTransformation):
ri
=
map2alm
(
inp
.
imag
,
lmax
,
mmax
)
ri
=
buildIdx
(
ri
,
lmax
=
lmax
)
return
rr
+
1j
*
ri
else
:
rr
=
map2alm
(
inp
,
lmax
,
mmax
)
return
buildIdx
(
rr
,
lmax
=
lmax
)
...
...
@@ -181,7 +180,6 @@ class LMHPTransformation(SlicingTransformation):
rr
=
alm2map
(
rr
,
lmax
,
mmax
,
nside
)
ri
=
alm2map
(
ri
,
lmax
,
mmax
,
nside
)
return
rr
+
1j
*
ri
else
:
rr
=
buildLm
(
inp
,
lmax
=
lmax
)
return
alm2map
(
rr
,
lmax
,
mmax
,
nside
)
...
...
nifty2go/random.py
View file @
850b5070
...
...
@@ -18,58 +18,42 @@
from
builtins
import
object
import
numpy
as
np
from
functools
import
reduce
class
Random
(
object
):
@
staticmethod
def
pm1
(
dtype
=
np
.
dtype
(
'int'
),
shape
=
1
):
size
=
int
(
reduce
(
lambda
x
,
y
:
x
*
y
,
shape
))
if
issubclass
(
dtype
.
type
,
np
.
complexfloating
):
def
pm1
(
dtype
,
shape
):
if
issubclass
(
dtype
,
(
complex
,
np
.
complexfloating
)):
x
=
np
.
array
([
1
+
0j
,
0
+
1j
,
-
1
+
0j
,
0
-
1j
],
dtype
=
dtype
)
x
=
x
[
np
.
random
.
randint
(
4
,
high
=
None
,
size
=
siz
e
)]
x
=
x
[
np
.
random
.
randint
(
4
,
size
=
shap
e
)]
else
:
x
=
2
*
np
.
random
.
randint
(
2
,
high
=
None
,
size
=
siz
e
)
-
1
x
=
2
*
np
.
random
.
randint
(
2
,
size
=
shap
e
)
-
1
return
x
.
astype
(
dtype
)
.
reshape
(
shape
)
return
x
.
astype
(
dtype
)
@
staticmethod
def
normal
(
dtype
=
np
.
dtype
(
'float64'
),
shape
=
(
1
,),
mean
=
None
,
std
=
None
):
size
=
int
(
reduce
(
lambda
x
,
y
:
x
*
y
,
shape
))
if
issubclass
(
dtype
.
type
,
np
.
complexfloating
):
x
=
np
.
empty
(
size
,
dtype
=
dtype
)
x
.
real
=
np
.
random
.
normal
(
loc
=
0
,
scale
=
np
.
sqrt
(
0.5
),
size
=
size
)
x
.
imag
=
np
.
random
.
normal
(
loc
=
0
,
scale
=
np
.
sqrt
(
0.5
),
size
=
size
)
def
normal
(
dtype
,
shape
,
mean
=
0.
,
std
=
1.
):
if
issubclass
(
dtype
,
(
complex
,
np
.
complexfloating
)):
x
=
np
.
empty
(
shape
,
dtype
=
dtype
)
x
.
real
=
np
.
random
.
normal
(
mean
,
std
*
np
.
sqrt
(
0.5
),
shape
)
x
.
imag
=
np
.
random
.
normal
(
mean
,
std
*
np
.
sqrt
(
0.5
),
shape
)
else
:
x
=
np
.
random
.
normal
(
loc
=
0
,
scale
=
1
,
size
=
siz
e
)
x
=
np
.
random
.
normal
(
mean
,
std
,
shap
e
)
x
=
x
.
astype
(
dtype
,
copy
=
False
)
x
=
x
.
reshape
(
shape
)
if
std
is
not
None
:
x
*=
dtype
.
type
(
std
)
if
mean
is
not
None
:
x
+=
dtype
.
type
(
mean
)
return
x
@
staticmethod
def
uniform
(
dtype
=
np
.
dtype
(
'float64'
),
shape
=
1
,
low
=
0
,
high
=
1
):
size
=
int
(
reduce
(
lambda
x
,
y
:
x
*
y
,
shape
))
if
issubclass
(
dtype
.
type
,
np
.
complexfloating
):
def
uniform
(
dtype
,
shape
,
low
=
0.
,
high
=
1.
):
if
issubclass
(
dtype
,
(
complex
,
np
.
complexfloating
)):
x
=
np
.
empty
(
size
,
dtype
=
dtype
)
x
.
real
=
(
high
-
low
)
*
np
.
random
.
random
(
s
ize
=
siz
e
)
+
low
x
.
imag
=
(
high
-
low
)
*
np
.
random
.
random
(
s
ize
=
siz
e
)
+
low
x
.
real
=
(
high
-
low
)
*
np
.
random
.
random
(
s
hap
e
)
+
low
x
.
imag
=
(
high
-
low
)
*
np
.
random
.
random
(
s
hap
e
)
+
low
elif
dtype
in
[
np
.
dtype
(
'int8'
),
np
.
dtype
(
'int16'
),
np
.
dtype
(
'int32'
),
np
.
dtype
(
'int64'
)]:
x
=
np
.
random
.
random_integers
(
min
(
low
,
high
),
high
=
max
(
low
,
high
),
size
=
s
iz
e
)
size
=
s
hap
e
)
else
:
x
=
(
high
-
low
)
*
np
.
random
.
random
(
s
ize
=
siz
e
)
+
low
x
=
(
high
-
low
)
*
np
.
random
.
random
(
s
hap
e
)
+
low
return
x
.
astype
(
dtype
,
copy
=
False
)
.
reshape
(
shape
)
return
x
.
astype
(
dtype
,
copy
=
False
)
Write
Preview
Markdown
is supported
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