microecs 0.2.2__tar.gz → 0.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: microecs
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: MicroECS: Minimal Entity Component System (ECS) in python and numpy
5
5
  Home-page: https://gitlab.com/meehai/microecs
6
6
  License: MIT
@@ -70,10 +70,16 @@ class _Field(np.lib.mixins.NDArrayOperatorsMixin):
70
70
  for v, chunk in zip(views, np.split(full, np.cumsum(self._lens)[:-1])):
71
71
  v[:] = chunk
72
72
 
73
- # qr.position[:, 0] (or any >1 axis as well as slices not exact indices) is allowed. qr.position[0] is not.
74
73
  def __getitem__(self, key):
74
+ if isinstance(key, (int, np.integer)): # qr.position[i] -> entity i's row, from its own pool
75
+ key = range(self.len)[key] # numpy's exact int-index rule, for free: wraps neg, raises on OOB
76
+ pool_ix = int(np.searchsorted(self._bounds, key, side="right")) - 1
77
+ return self.parts[pool_ix][key - self._bounds[pool_ix]]
78
+
75
79
  if not (isinstance(key, tuple) and key and key[0] == slice(None)):
76
- raise TypeError("entity-axis indexing crosses pools; use [:, k]. Use .numpy() to get a proper np.ndarray.")
80
+ raise TypeError("Unsupported indexing. Use .numpy() for a proper array. To set items, use qr.attr[:, k]=xxx"
81
+ ". For fancy indexing qr[i, 0:3, k], use qr[i][0:3, k].")
82
+
77
83
  return _Field([part[key] for part in self.parts])
78
84
 
79
85
  def __iter__(self):
@@ -6,5 +6,5 @@ from .world import World
6
6
  class TickSystem(ABC):
7
7
  """Generic tick-level system. Called inside the hot main engine loop on every tick"""
8
8
  @abstractmethod
9
- def on_tick(self, scene: World):
9
+ def on_tick(self, world: World):
10
10
  """callback called on each tick"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: microecs
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: MicroECS: Minimal Entity Component System (ECS) in python and numpy
5
5
  Home-page: https://gitlab.com/meehai/microecs
6
6
  License: MIT
@@ -3,7 +3,7 @@ from pathlib import Path
3
3
  from setuptools import setup, find_packages
4
4
 
5
5
  NAME = "microecs"
6
- VERSION = "0.2.2"
6
+ VERSION = "0.2.3"
7
7
  DESCRIPTION = "MicroECS: Minimal Entity Component System (ECS) in python and numpy"
8
8
  URL = "https://gitlab.com/meehai/microecs"
9
9
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes