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
Daniel Boeckenhoff
tfields
Commits
a6a4ab23
Commit
a6a4ab23
authored
May 08, 2020
by
dboe
Browse files
container can deal with itself:w
parent
015289f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
tfields/core.py
View file @
a6a4ab23
...
@@ -2520,13 +2520,16 @@ class Container(AbstractNdarray):
...
@@ -2520,13 +2520,16 @@ class Container(AbstractNdarray):
>>> sphere2 = sphere.copy() * 3
>>> sphere2 = sphere.copy() * 3
>>> c = tfields.Container([sphere, sphere2])
>>> c = tfields.Container([sphere, sphere2])
#
>>> c.save("~/tmp/spheres.npz")
>>> c.save("~/tmp/spheres.npz")
#
>>> c1 = tfields.Container.load("~/tmp/spheres.npz")
>>> c1 = tfields.Container.load("~/tmp/spheres.npz")
"""
"""
__slots__
=
[
"items"
,
"labels"
]
__slots__
=
[
"items"
,
"labels"
]
def
__new__
(
cls
,
items
,
**
kwargs
):
def
__new__
(
cls
,
items
,
**
kwargs
):
if
issubclass
(
type
(
items
),
cls
):
items
=
items
.
items
kwargs
.
setdefault
(
items
.
labels
)
kwargs
[
"items"
]
=
items
kwargs
[
"items"
]
=
items
cls
.
_update_slot_kwargs
(
kwargs
)
cls
.
_update_slot_kwargs
(
kwargs
)
...
@@ -2544,6 +2547,13 @@ class Container(AbstractNdarray):
...
@@ -2544,6 +2547,13 @@ class Container(AbstractNdarray):
return
obj
return
obj
class
Maps
(
Container
):
def
__new__
(
cls
,
items
,
**
kwargs
):
if
not
issubclass
(
type
(
items
),
cls
):
print
(
"ASDF"
)
super
().
__new__
(
items
,
**
kwargs
)
if
__name__
==
"__main__"
:
# pragma: no cover
if
__name__
==
"__main__"
:
# pragma: no cover
import
doctest
import
doctest
doctest
.
testmod
()
doctest
.
testmod
()
...
...
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