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
b628605f
Commit
b628605f
authored
Jul 25, 2017
by
Theo Steininger
Browse files
Added caching to field.shape
parent
a014e614
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty/field.py
View file @
b628605f
...
...
@@ -112,7 +112,6 @@ class Field(Loggable, Versionable, object):
def
__init__
(
self
,
domain
=
None
,
val
=
None
,
dtype
=
None
,
distribution_strategy
=
None
,
copy
=
False
):
self
.
domain
=
self
.
_parse_domain
(
domain
=
domain
,
val
=
val
)
self
.
domain_axes
=
self
.
_get_axes_tuple
(
self
.
domain
)
...
...
@@ -128,6 +127,7 @@ class Field(Loggable, Versionable, object):
else
:
self
.
set_val
(
new_val
=
val
,
copy
=
copy
)
def
_parse_domain
(
self
,
domain
,
val
=
None
):
if
domain
is
None
:
if
isinstance
(
val
,
Field
):
...
...
@@ -775,14 +775,14 @@ class Field(Loggable, Versionable, object):
dim
"""
shape_tuple
=
tuple
(
sp
.
shape
for
sp
in
self
.
domain
)
try
:
global_shape
=
reduce
(
lambda
x
,
y
:
x
+
y
,
shape_tuple
)
except
TypeError
:
global_shape
=
()
return
global
_shape
if
not
hasattr
(
self
,
'_shape'
):
shape_tuple
=
tuple
(
sp
.
shape
for
sp
in
self
.
domain
)
try
:
global_shape
=
reduce
(
lambda
x
,
y
:
x
+
y
,
shape_tuple
)
except
TypeError
:
global_shape
=
()
self
.
_shape
=
global_shape
return
self
.
_shape
@
property
def
dim
(
self
):
...
...
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