Skip to content

Commit

Permalink
Update unit tests to handle NumPy arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-caron committed Jun 17, 2024
1 parent 045d425 commit a2585cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
coveralls --service=github
test:
name: "Test ${{ matrix.os }} with python-${{ matrix.python-version }}"
name: "Test ${{ matrix.os }} with Python ${{ matrix.python-version }}"
runs-on: ${{ matrix.os }}

strategy:
Expand Down
13 changes: 10 additions & 3 deletions tests/test_fox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import unittest

import numpy as np

from foxplot.fox import Fox


Expand Down Expand Up @@ -209,7 +211,8 @@ def test_repeat_last_on_missing_2(self):
fox.unpack({"x": 12, "time": 1.0})
fox.data._freeze(2)
self.assertEqual(fox.data.config_a._values.tolist(), [config_a] * 2)
self.assertEqual(fox.data.x._values.tolist(), [None, 12])
self.assertTrue(np.isnan(fox.data.x._values[0]))
self.assertTrue(np.allclose(fox.data.x._values[1:], [12.0]))

def test_repeat_last_on_missing_3(self):
fox = Fox(time="time")
Expand All @@ -219,7 +222,8 @@ def test_repeat_last_on_missing_3(self):
fox.unpack({"x": 22, "time": 2.0})
fox.data._freeze(3)
self.assertEqual(fox.data.config_a._values.tolist(), [config_a] * 3)
self.assertEqual(fox.data.x._values.tolist(), [None, 12, 22])
self.assertTrue(np.isnan(fox.data.x._values[0]))
self.assertTrue(np.allclose(fox.data.x._values[1:], [12.0, 22.0]))

def test_repeat_last_on_missing_4(self):
fox = Fox(time="time")
Expand All @@ -230,4 +234,7 @@ def test_repeat_last_on_missing_4(self):
fox.unpack({"x": 32, "time": 3.0})
fox.data._freeze(4)
self.assertEqual(fox.data.config_a._values.tolist(), [config_a] * 4)
self.assertEqual(fox.data.x._values.tolist(), [None, 12, 22, 32])
self.assertTrue(np.isnan(fox.data.x._values[0]))
self.assertTrue(
np.allclose(fox.data.x._values[1:], [12.0, 22.0, 32.0])
)

0 comments on commit a2585cd

Please sign in to comment.