def test_filter_out_dead(grid: RectangularGrid): cells = CellList(grid=grid) cells.extend([CellData.create_cell(dead=bool(i % 2)) for i in range(10)]) assert_array_equal(cells.alive(), [0, 2, 4, 6, 8]) assert_array_equal(cells.alive([1, 2, 3, 6]), [2, 6]) mask = np.arange(10) < 5 assert_array_equal(cells.alive(mask), [0, 2, 4])
def create_cell_tuple( cls, **kwargs, ) -> Tuple: iteration = 0 phagosome = np.empty(MAX_CONIDIA) phagosome.fill(-1) return CellData.create_cell_tuple(**kwargs) + ( iteration, phagosome, )
def test_get_neighboring_cells(grid: RectangularGrid): point = Point(x=4.5, y=4.5, z=4.5) raw_cells = [CellData.create_cell(point=point) for _ in range(5)] raw_cells[1]['point'] = Point(x=-1, y=4.5, z=4.5) raw_cells[4]['point'] = Point(x=4.5, y=4.5, z=-1) cells = CellList(grid=grid) cells.extend(raw_cells) assert_array_equal(cells.get_neighboring_cells(cells[0]), [0, 2, 3]) assert_array_equal(cells.get_cells_in_voxel(Voxel(x=0, y=0, z=0)), [0, 2, 3])
def create_cell_tuple( cls, **kwargs, ) -> Tuple: initializer = { 'phagosome': kwargs.get('phagosome', -1 * np.ones(MAX_CONIDIA, dtype=np.int64)), } # ensure that these come in the correct order return CellData.create_cell_tuple(**kwargs) + tuple([ initializer[key] for key, *_ in PhagocyteCellData.PHAGOCYTE_FIELDS ])
def create_cell_tuple( cls, *, status=Status.NONGRANULATING, granule_count=0, **kwargs, ) -> Tuple: iteration = 0 return CellData.create_cell_tuple(**kwargs) + ( status, iteration, granule_count, )
def create_cell_tuple( cls, *, iron_pool: float = 0, status: Status = Status.RESTING, **kwargs, ) -> np.record: iteration = 0 phagosome = np.empty(MAX_PHAGOSOME_LENGTH) phagosome.fill(-1) return CellData.create_cell_tuple(**kwargs) + ( status, iron_pool, iteration, phagosome, )
def create_cell_tuple(cls, **kwargs) -> Tuple: initializer = { 'iron_pool': kwargs.get('iron_pool', 0), 'state': kwargs.get('state', AfumigatusCellState.FREE), 'status': kwargs.get('status', AfumigatusCellStatus.RESTING_CONIDIA), 'is_root': kwargs.get('is_root', True), 'vec': kwargs.get('vec', random_sphere_point()), # dz, dy, dx 'activation_iteration': kwargs.get('activation_iteration', 0), 'growth_iteration': kwargs.get('growth_iteration', 0), 'boolean_network': kwargs.get('boolean_network', cls.initial_boolean_network()), 'bn_iteration': kwargs.get('bn_iteration', 0), 'next_branch': kwargs.get('next_branch', -1), 'next_septa': kwargs.get('next_septa', -1), 'previous_septa': kwargs.get('previous_septa', -1), } # ensure that these come in the correct order return CellData.create_cell_tuple(**kwargs) + tuple( [initializer[key] for key, *_ in AfumigatusCellData.AFUMIGATUS_FIELDS] )
def create_cell_tuple( cls, *, iron: float = 0, status: Status = Status.RESTING, form: Form = Form.CONIDIA, iteration=0, mobile=False, internalized=False, health=100, **kwargs, ) -> Tuple: return CellData.create_cell_tuple(**kwargs) + ( form, status, iteration, mobile, internalized, iron, health, )
def test_move_cell(grid: RectangularGrid): point = Point(x=4.5, y=4.5, z=4.5) raw_cells = [CellData.create_cell(point=point) for _ in range(5)] raw_cells[1]['point'] = Point(x=-1, y=4.5, z=4.5) raw_cells[4]['point'] = Point(x=4.5, y=4.5, z=-1) cells = CellList(grid=grid) cells.extend(raw_cells) cells[0]['point'] = Point(x=50, y=50, z=50) # updating an incorrect index will not update the cell at index 0 cells.update_voxel_index([1, 3]) assert_array_equal(cells.get_neighboring_cells(cells[2]), [0, 2, 3]) assert cells._reverse_voxel_index[0] == grid.get_voxel(point) # this should correctly update the voxel index cells.update_voxel_index([0]) assert_array_equal(cells.get_neighboring_cells(cells[0]), [0]) assert cells._reverse_voxel_index[0] == grid.get_voxel(cells[0]['point'])
def cell(grid: RectangularGrid, point: Point): # a single cell in the middle of the domain cell = CellData.create_cell(point=point) cells = CellData([cell]) yield cells