def test_unit(array): vector = Vector(array) vector_unit = vector.unit() assert math.isclose(vector_unit.norm(), 1) assert (vector.norm() * vector_unit).is_close(array) assert vector_unit.is_parallel(vector) angle = vector.angle_between(vector_unit) assert math.isclose(angle, 0, abs_tol=ATOL)
def test_add_subtract(arrays): array_point, array_vector = arrays point = Point(array_point) vector = Vector(array_vector) point_2 = point + array_vector assert math.isclose(point.distance_point(point_2), vector.norm()) point_3 = point_2 - array_vector assert point.is_close(point_3)