microecs 0.3.7__tar.gz → 0.3.9__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.7 → microecs-0.3.9}/PKG-INFO +1 -1
- {microecs-0.3.7 → microecs-0.3.9}/microecs/__init__.py +5 -4
- {microecs-0.3.7 → microecs-0.3.9}/microecs/query_result.py +4 -4
- {microecs-0.3.7 → microecs-0.3.9}/microecs.egg-info/PKG-INFO +1 -1
- {microecs-0.3.7 → microecs-0.3.9}/setup.py +1 -1
- {microecs-0.3.7 → microecs-0.3.9}/LICENSE.TXT +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/README.md +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs/component.py +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs/pool.py +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs/utils.py +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs/world.py +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs.egg-info/SOURCES.txt +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs.egg-info/dependency_links.txt +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs.egg-info/requires.txt +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/microecs.egg-info/top_level.txt +0 -0
- {microecs-0.3.7 → microecs-0.3.9}/setup.cfg +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"""init file"""
|
|
2
2
|
|
|
3
|
-
from .component import Component
|
|
4
|
-
from .pool import Pool
|
|
5
|
-
from .query_result import QueryResult
|
|
6
3
|
from .world import World
|
|
4
|
+
from .query_result import QueryResult
|
|
5
|
+
from .pool import Pool
|
|
6
|
+
from .component import Component
|
|
7
|
+
from .utils import EntityData, EntityId
|
|
7
8
|
|
|
8
|
-
__all__ = ["
|
|
9
|
+
__all__ = ["World", "QueryResult", "Pool", "Component", "EntityData", "EntityId"]
|
|
@@ -96,14 +96,14 @@ class _Field(np.lib.mixins.NDArrayOperatorsMixin):
|
|
|
96
96
|
return f"[Field] Shape: {self.shape} (across {len(self.parts)} pools)"
|
|
97
97
|
|
|
98
98
|
class QueryResult:
|
|
99
|
-
"""A
|
|
99
|
+
"""A query result containing entities. Fields (e.g. qr.position) implement array interface to look like numpy"""
|
|
100
100
|
def __init__(self, pool_list: list[Pool], field_shapes: dict[str, Shape], field_dtypes: dict[str, np.dtype],
|
|
101
101
|
entity_ids: np.ndarray):
|
|
102
102
|
self.pool_list = pool_list
|
|
103
103
|
self.entity_ids = entity_ids
|
|
104
|
+
self.fields = list(field_shapes)
|
|
104
105
|
self._field_shapes = field_shapes
|
|
105
106
|
self._field_dtypes = field_dtypes
|
|
106
|
-
self._fields = list(field_shapes)
|
|
107
107
|
self._data: dict[str, np.ndarray] = {f: [p.data[f][0:len(p)] for p in pool_list] for f in field_shapes.keys()}
|
|
108
108
|
self._len = sum(len(pool) for pool in self.pool_list)
|
|
109
109
|
|
|
@@ -111,7 +111,7 @@ class QueryResult:
|
|
|
111
111
|
if (data := self.__dict__.get("_data")) is not None and name in data:
|
|
112
112
|
# the 'or' part is in case no pools match the query and we want qr.position[:] += 1 still to work (noop)
|
|
113
113
|
return _Field(data[name] or [np.empty((0, *self._field_shapes[name]), self._field_dtypes[name])])
|
|
114
|
-
raise AttributeError(f"'{name}' not part of {self.
|
|
114
|
+
raise AttributeError(f"'{name}' not part of {self.fields}")
|
|
115
115
|
|
|
116
116
|
def __setattr__(self, name, value):
|
|
117
117
|
if (data := self.__dict__.get("_data")) is not None and name in data:
|
|
@@ -124,5 +124,5 @@ class QueryResult:
|
|
|
124
124
|
|
|
125
125
|
def __repr__(self):
|
|
126
126
|
return (f"[QueryResult]\n- Entities: {len(self.entity_ids)} (pools: {len(self.pool_list)})"
|
|
127
|
-
f"\n- Fields: {self.
|
|
127
|
+
f"\n- Fields: {self.fields}"
|
|
128
128
|
f"\n- Shapes: {list(self._field_shapes.values())}\n- Dtypes: {list(self._field_dtypes.values())}")
|
|
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
|