Skip to content

Commit

Permalink
update centrography test for dep induced precision breakage (#69)
Browse files Browse the repository at this point in the history
* update centrography test for dep induced precision breakage

* handle order change on minimum rotated rectangle

* roll mrr points while testing to ensure correctness

* update test to avoid infinite loop

* remove unused

---------

Co-authored-by: ljwolf <levi.john.wolf@gmail.com>
Co-authored-by: Martin Fleischmann <martin@martinfleischmann.net>
  • Loading branch information
3 people committed Feb 27, 2023
1 parent 5e2922f commit 6723b40
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions pointpats/tests/test_centrography.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,25 @@ def setUp(self):
)

def test_centrography_mar(self):
min_x, min_y, max_x, max_y = minimum_rotated_rectangle(self.points)
np.testing.assert_array_almost_equal(min_x, [36.40165, 104.61744])
np.testing.assert_array_almost_equal(min_y, [4.0872803, 30.417528])
np.testing.assert_array_almost_equal(max_x, [75.599075, -0.7261505])
np.testing.assert_array_almost_equal(max_y, [107.913445, 73.47376251220703])
mrr = minimum_rotated_rectangle(self.points)
known = np.array(
[
[36.40165, 104.61744],
[4.087286, 30.417522],
[75.59908, -0.726158],
[107.913445, 73.47376251220703],
]
)
for i in range(5):
success = np.allclose(mrr, np.roll(known, i, axis=0))
if success:
break
if not success:
raise AssertionError(
f"Minimum Rotated Rectangle cannot be"
f"aligned with correct answer:"
f"\ncomputed {mrr}\nknown: {known}"
)

def test_centrography_mbr(self):
min_x, min_y, max_x, max_y = minimum_bounding_rectangle(self.points)
Expand Down

0 comments on commit 6723b40

Please sign in to comment.