Skip to content

Commit 70cffbb

Browse files
committed
tag multiple groups with an axis in one shot
1 parent 7b092b2 commit 70cffbb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

larray/core.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1052,13 +1052,18 @@ def group(self, *args, **kwargs):
10521052
raise ValueError("invalid keyword argument(s): %s"
10531053
% list(kwargs.keys()))
10541054
key = args[0] if len(args) == 1 else args
1055-
if isinstance(key, list):
1055+
if isinstance(key, basestring):
1056+
key = to_keys(key)
1057+
1058+
if isinstance(key, (tuple, list)):
10561059
if any(isinstance(k, Group) for k in key):
1057-
assert all(isinstance(k, Group) for k in key)
10581060
k0 = key[0]
1059-
assert all(isinstance(k, k0.__class__) for k in key)
1060-
assert all(np.isscalar(k.key) for k in key)
1061-
return k0.__class__([k.key for k in key], axis=self)
1061+
assert isinstance(k0, Group)
1062+
cls_ = k0.__class__
1063+
assert all(isinstance(k, cls_) for k in key[1:])
1064+
res = [k.with_axis(self) for k in key]
1065+
res = tuple(res) if isinstance(key, tuple) else res
1066+
return res
10621067

10631068
if isinstance(key, Group):
10641069
name = name if name is not None else key.name

0 commit comments

Comments
 (0)