Commit e87afa0f authored by dboe's avatar dboe
Browse files

dicts work

parent 763bdac3
......@@ -2129,8 +2129,15 @@ class Maps(sortedcontainers.SortedDict, AbstractObject):
Indexing by dimension
"""
def __init__(self, *args, **kwargs):
if args and args[0] is None:
# None key passed e.g. by copy. We do not change keys here.
args = args[1:]
# convert all possible input arguments to only
if len(args) == 1 and isinstance(args[0], list):
if len(args) == 1 and isinstance(args[0],
sortedcontainers.SortedItemsView):
args = tuple([v for k, v in args[0]])
elif len(args) == 1 and isinstance(args[0], list):
if len(args[0]) > 0 and not issubclass(type(args[0][0]), tuple):
# Maps([mp, mp2])- not Maps([]) and not Maps([(key, value)])
args = tuple(args[0])
......@@ -2145,8 +2152,7 @@ class Maps(sortedcontainers.SortedDict, AbstractObject):
# By now everything must have been converted to flat args
# Maps(tfields.TensorFields([], dim=3), [[1,2,3]])
arg_tuple_list = []
print(args)
for arg in args:
for i, arg in enumerate(args):
if not isinstance(type(arg), tuple):
dimension = dim(arg)
mp = arg
......@@ -2383,9 +2389,11 @@ class TensorMaps(TensorFields):
dim_maps_dict = {} # {dim: {i: mp}
for i, obj in enumerate(objects):
for dimension, mp in obj.maps:
for dimension, mp in obj.maps.items():
mp = mp + cum_tensor_lengths[i]
dim_maps_dict[mp.dim][i] = mp
if dimension not in dim_maps_dict:
dim_maps_dict[dimension] = []
dim_maps_dict[dimension].append(mp)
maps = []
template_maps_list = [[] for i in range(len(objects))]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment