Skip to content

Commit

Permalink
Update test_space.py
Browse files Browse the repository at this point in the history
Fix remaining TestPropertyLayer

A condition always is a function, never a mask (for now).
  • Loading branch information
EwoutH committed Dec 6, 2023
1 parent 8219eeb commit 377c552
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/test_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,13 @@ def test_set_cells_no_condition(self):
np.testing.assert_array_equal(self.layer.data, np.full((10, 10), 2))

def test_set_cells_with_condition(self):
condition = np.full((10, 10), False)
condition[5, :] = True # Only update the 5th row
self.layer.set_cell((5, 5), 1)
condition = lambda x: x == 0
self.layer.set_cells(3, condition)
self.assertEqual(np.sum(self.layer.data[5, :] == 3), 10)
self.assertEqual(np.sum(self.layer.data != 3), 90)

def test_set_cells_invalid_condition(self):
with self.assertRaises(ValueError):
self.layer.set_cells(4, condition=np.full((5, 5), False)) # Invalid shape
self.assertEqual(self.layer.data[5, 5], 1)
self.assertEqual(self.layer.data[0, 0], 3)
# Check if the sum is correct
self.assertEqual(np.sum(self.layer.data), 3 * 99 + 1)

# Modify Cells Test
def test_modify_cell_lambda(self):
Expand Down

0 comments on commit 377c552

Please sign in to comment.