def test_subdivide_segment_returns_partition_for_odd_partition_size(): p1 = np.array([0.0, 0.0, 0.0]) p2 = np.array([2.0, 0.0, 0.0]) partition_size = 5 expected_partition_points = np.array([ [0.0, 0.0, 0.0], [0.5, 0.0, 0.0], [1.0, 0.0, 0.0], [1.5, 0.0, 0.0], [2.0, 0.0, 0.0], ]) np.testing.assert_array_almost_equal(subdivide_segment( p1, p2, partition_size), expected_partition_points, decimal=7)
def test_subdivide_segment_returns_partition_omitting_endpoint(): p1 = np.array([0.0, 0.0, 0.0]) p2 = np.array([1.0, 0.0, 0.0]) partition_size = 5 expected_partition_points = np.array([ [0.0, 0.0, 0.0], [0.2, 0.0, 0.0], [0.4, 0.0, 0.0], [0.6, 0.0, 0.0], [0.8, 0.0, 0.0], ]) np.testing.assert_array_almost_equal( subdivide_segment(p1, p2, partition_size, endpoint=False), expected_partition_points, decimal=7, )
def test_subdivide_segment_raises_exception_for_invalid_partition_size_value(): p1 = np.array([0.0, 0.0, 0.0]) p2 = np.array([1.0, 0.0, 0.0]) with pytest.raises(ValueError): subdivide_segment(p1, p2, 1)