Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
67a98fe9
Commit
67a98fe9
authored
Jul 14, 2017
by
Theo Steininger
Browse files
Merge branch 'avoid_exec' into 'master'
avoid exec statements; they cause problems with Python 3 See merge request
!165
parents
dd87b630
ebcc660c
Pipeline
#14889
passed with stages
in 12 minutes and 55 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/field.py
View file @
67a98fe9
...
...
@@ -18,6 +18,7 @@
from
__future__
import
division
import
ast
import
itertools
import
numpy
as
np
...
...
@@ -1519,7 +1520,8 @@ class Field(Loggable, Versionable, object):
temp_domain
.
append
(
repository
.
get
(
's_'
+
str
(
i
),
hdf5_group
))
new_field
.
domain
=
tuple
(
temp_domain
)
exec
(
'new_field.domain_axes = '
+
hdf5_group
.
attrs
[
'domain_axes'
])
new_field
.
domain_axes
=
ast
.
literal_eval
(
hdf5_group
.
attrs
[
'domain_axes'
])
try
:
new_field
.
_val
=
repository
.
get
(
'val'
,
hdf5_group
)
...
...
nifty/spaces/power_space/power_space.py
View file @
67a98fe9
...
...
@@ -16,6 +16,7 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
import
ast
import
numpy
as
np
from
d2o
import
distributed_data_object
...
...
@@ -311,6 +312,6 @@ class PowerSpace(Space):
@
classmethod
def
_from_hdf5
(
cls
,
hdf5_group
,
repository
):
hp
=
repository
.
get
(
'harmonic_partner'
,
hdf5_group
)
exec
(
"bb = "
+
hdf5_group
.
attrs
[
'binbounds'
])
bb
=
ast
.
literal_eval
(
hdf5_group
.
attrs
[
'binbounds'
])
ds
=
hdf5_group
.
attrs
[
'distribution_strategy'
]
return
PowerSpace
(
hp
,
ds
,
binbounds
=
bb
)
test/test_serialization.py
View file @
67a98fe9
...
...
@@ -21,6 +21,7 @@ import unittest
from
numpy.testing
import
assert_equal
from
keepers
import
Repository
from
test.common
import
expand
,
generate_spaces
from
nifty
import
Field
from
nose.plugins.skip
import
SkipTest
import
os
...
...
@@ -33,6 +34,9 @@ class SpaceSerializationTests(unittest.TestCase):
raise
SkipTest
repo
=
Repository
(
'test.h5'
)
repo
.
add
(
space
,
'space'
)
field
=
Field
(
space
,
val
=
42.
)
repo
.
add
(
field
,
'field'
)
repo
.
commit
()
assert_equal
(
space
,
repo
.
get
(
'space'
))
assert_equal
(
field
,
repo
.
get
(
'field'
))
os
.
remove
(
'test.h5'
)
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