Skip to content

Commit

Permalink
Add objects folder inside property tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hynes committed Mar 5, 2019
1 parent c6df224 commit 256f64e
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 17 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import numpy as np
import pytest
from hypothesis import assume, given
from numpy.testing import assert_array_equal, assert_allclose
from hypothesis import given

from skspatial.objects import Point, Vector, Line
from .strategies import st_arrays, st_point, st_vector, st_vector_nonzero
from skspatial.objects import Point, Vector
from tests.property.strategies import st_arrays, st_point, st_vector


@given(st_arrays)
Expand All @@ -19,7 +18,7 @@ def test_length(array):

assert point != vector
assert point.array.size == vector.array.size == 3
assert_array_equal(point.array, vector.array)
assert np.allclose(point.array, vector.array)

else:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
from hypothesis import given

from .strategies import st_point, st_vector, st_vector_nonzero, st_line

from skspatial.objects import Line
from tests.property.strategies import st_point, st_vector_nonzero, st_line


@given(st_point(), st_vector_nonzero())
Expand Down
13 changes: 13 additions & 0 deletions tests/property/objects/test_plane.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from hypothesis import given

from skspatial.objects import Plane
from tests.property.strategies import st_point


@given(st_point(), st_point(), st_point())
def test_from_points_failure(point_a, point_b, point_c):

if point_a.is_collinear(point_b, point_c):
with pytest.raises(Exception):
Plane.from_points(point_a, point_b, point_c)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import pytest
from hypothesis import given

from skspatial.constants import ATOL
from .strategies import st_point, st_vector
from tests.property.strategies import st_point, st_vector


@given(st_point(), st_vector())
Expand All @@ -21,8 +20,3 @@ def test_add_subtract(point, vector):

point_3 = point_2.subtract(vector)
assert point.is_close(point_3)

# A point is collinear with itself.
assert point.is_collinear(point, point)

assert point.is_collinear(point_2, point_3, atol=ATOL)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from skspatial.constants import ATOL
from skspatial.objects import Vector
from .strategies import st_floats, st_point, st_vector, st_vector_nonzero
from tests.property.strategies import st_floats, st_point, st_vector, st_vector_nonzero


@given(st_point(), st_point())
Expand Down
23 changes: 23 additions & 0 deletions tests/property/test_comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from hypothesis import given

from skspatial.objects import Line
from tests.property.strategies import st_point


@given(st_point(), st_point(), st_point())
def test_is_collinear(point_a, point_b, point_c):

assert point_a.is_collinear(point_a, point_a)
assert point_a.is_collinear(point_a, point_b)

all_different = not (point_a.is_close(point_b) or point_b.is_close(point_c))

if point_a.is_collinear(point_b, point_c) and all_different:

line_ab = Line.from_points(point_a, point_b)
line_bc = Line.from_points(point_b, point_c)

assert line_ab.contains_point(point_c)
assert line_bc.contains_point(point_a)

assert line_ab.is_coplanar(line_bc)
2 changes: 1 addition & 1 deletion tests/property/test_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from hypothesis import given

from skspatial.measurement import area_triangle, volume_tetrahedron
from .strategies import st_point, st_line
from tests.property.strategies import st_point, st_line


@given(st_point(), st_point(), st_point())
Expand Down
2 changes: 1 addition & 1 deletion tests/property/test_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from skspatial.constants import ATOL
from skspatial.objects import Vector
from .strategies import st_point, st_line, st_plane
from tests.property.strategies import st_point, st_line, st_plane


@pytest.mark.parametrize('name_object', ['line', 'plane'])
Expand Down
Empty file added tests/unit/objects/__init__.py
Empty file.

0 comments on commit 256f64e

Please sign in to comment.