Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
7c69cf19
There was a problem fetching the pipeline summary.
Commit
7c69cf19
authored
7 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
more fixes
parent
2bc45272
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nifty/data_objects/random.py
+7
-4
7 additions, 4 deletions
nifty/data_objects/random.py
with
7 additions
and
4 deletions
nifty/data_objects/random.py
+
7
−
4
View file @
7c69cf19
...
@@ -32,12 +32,15 @@ class Random(object):
...
@@ -32,12 +32,15 @@ class Random(object):
@staticmethod
@staticmethod
def
normal
(
dtype
,
shape
,
mean
=
0.
,
std
=
1.
):
def
normal
(
dtype
,
shape
,
mean
=
0.
,
std
=
1.
):
if
not
(
np
.
issubdtype
(
dtype
,
np
.
floating
)
or
np
.
issubdtype
(
dtype
,
np
.
complexfloating
)):
raise
TypeError
(
"
dtype must be float or complex
"
)
if
not
np
.
isscalar
(
mean
)
or
not
np
.
isscalar
(
std
):
if
not
np
.
isscalar
(
mean
)
or
not
np
.
isscalar
(
std
):
raise
TypeError
(
"
mean and std must be scalars
"
)
raise
TypeError
(
"
mean and std must be scalars
"
)
if
np
.
issubdtype
(
type
(
std
),
np
.
complexfloating
):
if
np
.
issubdtype
(
type
(
std
),
np
.
complexfloating
):
raise
TypeError
(
"
std must not be complex
"
)
raise
TypeError
(
"
std must not be complex
"
)
if
((
not
np
.
issubdtype
(
dtype
,
np
.
complexfloating
))
and
if
((
not
np
.
issubdtype
(
dtype
,
np
.
complexfloating
))
and
np
.
issubdtype
(
type
(
mean
),
np
.
complexfloating
)):
np
.
issubdtype
(
type
(
mean
),
np
.
complexfloating
)):
raise
TypeError
(
"
mean must not be complex for a real result field
"
)
raise
TypeError
(
"
mean must not be complex for a real result field
"
)
if
np
.
issubdtype
(
dtype
,
np
.
complexfloating
):
if
np
.
issubdtype
(
dtype
,
np
.
complexfloating
):
x
=
np
.
empty
(
shape
,
dtype
=
dtype
)
x
=
np
.
empty
(
shape
,
dtype
=
dtype
)
...
@@ -51,7 +54,7 @@ class Random(object):
...
@@ -51,7 +54,7 @@ class Random(object):
def
uniform
(
dtype
,
shape
,
low
=
0.
,
high
=
1.
):
def
uniform
(
dtype
,
shape
,
low
=
0.
,
high
=
1.
):
if
not
np
.
isscalar
(
low
)
or
not
np
.
isscalar
(
high
):
if
not
np
.
isscalar
(
low
)
or
not
np
.
isscalar
(
high
):
raise
TypeError
(
"
low and high must be scalars
"
)
raise
TypeError
(
"
low and high must be scalars
"
)
if
(
np
.
issubdtype
(
type
(
low
),
np
.
complexfloating
)
or
if
(
np
.
issubdtype
(
type
(
low
),
np
.
complexfloating
)
or
np
.
issubdtype
(
type
(
high
),
np
.
complexfloating
)):
np
.
issubdtype
(
type
(
high
),
np
.
complexfloating
)):
raise
TypeError
(
"
low and high must not be complex
"
)
raise
TypeError
(
"
low and high must not be complex
"
)
if
np
.
issubdtype
(
dtype
,
np
.
complexfloating
):
if
np
.
issubdtype
(
dtype
,
np
.
complexfloating
):
...
@@ -59,7 +62,7 @@ class Random(object):
...
@@ -59,7 +62,7 @@ class Random(object):
x
.
real
=
np
.
random
.
uniform
(
low
,
high
,
shape
)
x
.
real
=
np
.
random
.
uniform
(
low
,
high
,
shape
)
x
.
imag
=
np
.
random
.
uniform
(
low
,
high
,
shape
)
x
.
imag
=
np
.
random
.
uniform
(
low
,
high
,
shape
)
elif
np
.
issubdtype
(
dtype
,
np
.
integer
):
elif
np
.
issubdtype
(
dtype
,
np
.
integer
):
if
not
(
np
.
issubdtype
(
type
(
low
),
np
.
integer
)
and
if
not
(
np
.
issubdtype
(
type
(
low
),
np
.
integer
)
and
np
.
issubdtype
(
type
(
high
),
np
.
integer
)):
np
.
issubdtype
(
type
(
high
),
np
.
integer
)):
raise
TypeError
(
"
low and high must be integer
"
)
raise
TypeError
(
"
low and high must be integer
"
)
x
=
np
.
random
.
randint
(
low
,
high
+
1
,
shape
)
x
=
np
.
random
.
randint
(
low
,
high
+
1
,
shape
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment