Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
>>> from pprint import pprint as pp # Pretty printer
|
||||
>>> from itertools import product
|
||||
>>>
|
||||
>>> def dict_as_mdarray(dimensions=(2, 3), init=0.0):
|
||||
... return {indices: init for indices in product(*(range(i) for i in dimensions))}
|
||||
...
|
||||
>>>
|
||||
>>> mdarray = dict_as_mdarray((2, 3, 4, 5))
|
||||
>>> pp(mdarray)
|
||||
{(0, 0, 0, 0): 0.0,
|
||||
(0, 0, 0, 1): 0.0,
|
||||
(0, 0, 0, 2): 0.0,
|
||||
(0, 0, 0, 3): 0.0,
|
||||
(0, 0, 0, 4): 0.0,
|
||||
(0, 0, 1, 0): 0.0,
|
||||
...
|
||||
(1, 2, 3, 0): 0.0,
|
||||
(1, 2, 3, 1): 0.0,
|
||||
(1, 2, 3, 2): 0.0,
|
||||
(1, 2, 3, 3): 0.0,
|
||||
(1, 2, 3, 4): 0.0}
|
||||
>>> mdarray[(0, 1, 2, 3)]
|
||||
0.0
|
||||
>>> mdarray[(0, 1, 2, 3)] = 6.78
|
||||
>>> mdarray[(0, 1, 2, 3)]
|
||||
6.78
|
||||
>>> mdarray[(0, 1, 2, 3)] = 5.4321
|
||||
>>> mdarray[(0, 1, 2, 3)]
|
||||
5.4321
|
||||
>>> pp(mdarray)
|
||||
{(0, 0, 0, 0): 0.0,
|
||||
(0, 0, 0, 1): 0.0,
|
||||
(0, 0, 0, 2): 0.0,
|
||||
...
|
||||
(0, 1, 2, 2): 0.0,
|
||||
(0, 1, 2, 3): 5.4321,
|
||||
(0, 1, 2, 4): 0.0,
|
||||
...
|
||||
(1, 2, 3, 3): 0.0,
|
||||
(1, 2, 3, 4): 0.0}
|
||||
>>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue