microecs 0.3.4__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {microecs-0.3.4 → microecs-0.3.7}/PKG-INFO +1 -1
- {microecs-0.3.4 → microecs-0.3.7}/microecs/query_result.py +9 -8
- {microecs-0.3.4 → microecs-0.3.7}/microecs.egg-info/PKG-INFO +1 -1
- {microecs-0.3.4 → microecs-0.3.7}/setup.py +1 -1
- {microecs-0.3.4 → microecs-0.3.7}/LICENSE.TXT +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/README.md +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs/__init__.py +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs/component.py +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs/pool.py +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs/utils.py +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs/world.py +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs.egg-info/SOURCES.txt +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs.egg-info/dependency_links.txt +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs.egg-info/requires.txt +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/microecs.egg-info/top_level.txt +0 -0
- {microecs-0.3.4 → microecs-0.3.7}/setup.cfg +0 -0
|
@@ -11,11 +11,12 @@ class _Field(np.lib.mixins.NDArrayOperatorsMixin):
|
|
|
11
11
|
self._lens = [len(p) for p in self.parts]
|
|
12
12
|
self.len = sum(self._lens)
|
|
13
13
|
self.shape: Shape = (len(self), *self.parts[0].shape[1:])
|
|
14
|
+
self.dtype = self.parts[0].dtype
|
|
14
15
|
self._bounds = np.cumsum([0, *self._lens])
|
|
15
16
|
|
|
16
17
|
def numpy(self) -> np.ndarray:
|
|
17
|
-
"""Creates a numpy array from the underlying pool parts"""
|
|
18
|
-
return np.concatenate(self.parts)
|
|
18
|
+
"""Creates a numpy array from the underlying pool parts. For len==1, we return the same object!"""
|
|
19
|
+
return np.concatenate(self.parts) if len(self.parts) != 1 else self.parts[0]
|
|
19
20
|
|
|
20
21
|
def _chunk(self, x: T, i: int) -> T:
|
|
21
22
|
if isinstance(x, _Field):
|
|
@@ -58,7 +59,7 @@ class _Field(np.lib.mixins.NDArrayOperatorsMixin):
|
|
|
58
59
|
def __setitem__(self, key, value):
|
|
59
60
|
if (not (isinstance(key, slice) and key == slice(None)) and
|
|
60
61
|
not (isinstance(key, tuple) and key and key[0] == slice(None))):
|
|
61
|
-
raise TypeError("entity-axis assignment crosses pools; use [:] or [:, k]")
|
|
62
|
+
raise TypeError("entity-axis assignment crosses pools; use [:] or [:, k] or [i][...]")
|
|
62
63
|
|
|
63
64
|
if isinstance(value, _Field):
|
|
64
65
|
for i, part in enumerate(self.parts):
|
|
@@ -78,11 +79,11 @@ class _Field(np.lib.mixins.NDArrayOperatorsMixin):
|
|
|
78
79
|
pool_ix = int(np.searchsorted(self._bounds, key, side="right")) - 1
|
|
79
80
|
return self.parts[pool_ix][key - self._bounds[pool_ix]]
|
|
80
81
|
|
|
81
|
-
if
|
|
82
|
-
|
|
83
|
-
". For fancy indexing qr[i, 0:3, k], use qr[i][0:3, k].")
|
|
82
|
+
if key is Ellipsis or (isinstance(key, tuple) and key and (key[0] is Ellipsis or key[0] == slice(None))):
|
|
83
|
+
return _Field([part[key] for part in self.parts])
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
raise TypeError("Unsupported indexing. Use .numpy() for a proper array. To set items, use qr.attr[:, k]=xxx. "
|
|
86
|
+
"For fancy indexing qr[i, 0:3, k], use qr[i][0:3, k].")
|
|
86
87
|
|
|
87
88
|
def __iter__(self):
|
|
88
89
|
for part in self.parts:
|
|
@@ -110,7 +111,7 @@ class QueryResult:
|
|
|
110
111
|
if (data := self.__dict__.get("_data")) is not None and name in data:
|
|
111
112
|
# the 'or' part is in case no pools match the query and we want qr.position[:] += 1 still to work (noop)
|
|
112
113
|
return _Field(data[name] or [np.empty((0, *self._field_shapes[name]), self._field_dtypes[name])])
|
|
113
|
-
raise AttributeError(name)
|
|
114
|
+
raise AttributeError(f"'{name}' not part of {self._fields}")
|
|
114
115
|
|
|
115
116
|
def __setattr__(self, name, value):
|
|
116
117
|
if (data := self.__dict__.get("_data")) is not None and name in data:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|