Skip to content

Commit

Permalink
[Fix] Fix failed unit tests caused by the new released numpy (#838)
Browse files Browse the repository at this point in the history
* [Fix] Fix failed unit tests caused by the new released numpy

* minor fix
  • Loading branch information
zhouzaida committed Dec 20, 2022
1 parent 4147e97 commit b44048a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/test_visualizer/test_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,21 +364,21 @@ def test_draw_polygons(self):
visualizer.draw_polygons(torch.tensor([[1, 1], [2, 2], [16, 4]]))

def test_draw_binary_masks(self):
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(np.bool)
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(bool)
visualizer = Visualizer(image=self.image)
visualizer.draw_binary_masks(binary_mask)
visualizer.draw_binary_masks(torch.from_numpy(binary_mask))
# multi binary
binary_mask = np.random.randint(0, 2, size=(2, 10, 10)).astype(np.bool)
binary_mask = np.random.randint(0, 2, size=(2, 10, 10)).astype(bool)
visualizer = Visualizer(image=self.image)
visualizer.draw_binary_masks(binary_mask, colors=['r', (0, 255, 0)])
# test the error that the size of mask and image are different.
with pytest.raises(AssertionError):
binary_mask = np.random.randint(0, 2, size=(8, 10)).astype(np.bool)
binary_mask = np.random.randint(0, 2, size=(8, 10)).astype(bool)
visualizer.draw_binary_masks(binary_mask)

# test non binary mask error
binary_mask = np.random.randint(0, 2, size=(10, 10, 3)).astype(np.bool)
binary_mask = np.random.randint(0, 2, size=(10, 10, 3)).astype(bool)
with pytest.raises(AssertionError):
visualizer.draw_binary_masks(binary_mask)

Expand Down Expand Up @@ -495,7 +495,7 @@ def test_draw_featmap(self):

def test_chain_call(self):
visualizer = Visualizer(image=self.image)
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(np.bool)
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(bool)
visualizer.draw_bboxes(torch.tensor([1, 1, 2, 2])). \
draw_texts('test', torch.tensor([5, 5])). \
draw_lines(x_datas=torch.tensor([1, 5]),
Expand Down

0 comments on commit b44048a

Please sign in to comment.