Exemplo n.º 1
0
def test_coordinate_cylindrical() -> None:
    """Test the cylindrical property of the coordinate class."""
    coordinate_1 = Coordinate(3., 4., 5.)
    coordinate_2 = Coordinate(20., 3., 7.)

    cylindrical_1 = Cylindrical(p=5., phi=0.92729521800161, z=5.)
    cylindrical_2 = Cylindrical(p=20.223748416157, phi=0.1488899476095, z=7.)

    assert_cylindrical_isclose(coordinate_1.cylindrical, cylindrical_1)
    assert_cylindrical_isclose(coordinate_2.cylindrical, cylindrical_2)
Exemplo n.º 2
0
def test_coordinate_from_cartesian() -> None:
    """Test the from_cartestian() method of the coordinate class."""
    coordinate_1 = Coordinate(3., 4., 5.)
    coordinate_2 = Coordinate(20., 3., 7.)

    cartesian_1 = Coordinate.from_cartesian(3., 4., 5.)
    cartesian_2 = Coordinate.from_cartesian(20., 3., 7.)

    assert_coordinate_isclose(coordinate_1, cartesian_1)
    assert_coordinate_isclose(coordinate_2, cartesian_2)
Exemplo n.º 3
0
def test_coordinate_from_cylindrical() -> None:
    """Test the from_cylindrical() method of the coordinate class."""
    coordinate_1 = Coordinate(3., 4., 5.)
    coordinate_2 = Coordinate(20., 3., 7.)

    cylindrical_1 = Coordinate.from_cylindrical(5., 0.92729521800161, 5.)
    cylindrical_2 = Coordinate.from_cylindrical(20.223748416157,
                                                0.1488899476095, 7.)

    assert_coordinate_isclose(coordinate_1, cylindrical_1)
    assert_coordinate_isclose(coordinate_2, cylindrical_2)
Exemplo n.º 4
0
def get_random_coordinate() -> Coordinate:
    """Get a random coordinate."""
    return Coordinate(
        get_random_float(),
        get_random_float(),
        get_random_float(),
    )
Exemplo n.º 5
0
def test_coordinate_represenation() -> None:
    """Test the representation of the coordinate class."""
    coordinate_1 = Coordinate(3., 4., 5.)

    given_representation = repr(coordinate_1)
    expected_representation = "Coordinate(x=3.0, y=4.0, z=5.0)"

    assert (given_representation == expected_representation)
Exemplo n.º 6
0
def test_marker_isclose() -> None:
    """Test the isclose method."""
    c = Coordinate(1, 1, 1)

    assert c.isclose(c)
    assert c.isclose(Coordinate(1.00000000001, 1, 1))
    assert not c.isclose(Coordinate(1.1, 1.1, 1.1))
Exemplo n.º 7
0
def test_coordinate_spherical() -> None:
    """Test the spherical property of the coordinate class."""
    coordinate_1 = Coordinate(3., 4., 5.)
    coordinate_2 = Coordinate(70., 34., 83.)

    spherical_1 = Spherical(
        r=7.0710678118655,
        theta=0.92729521800161,
        phi=0.78539816339745,
    )
    spherical_2 = Spherical(
        r=113.77609590771,
        theta=0.45215386228578,
        phi=0.75320133230042,
    )

    assert_spherical_isclose(coordinate_1.spherical, spherical_1)
    assert_spherical_isclose(coordinate_2.spherical, spherical_2)
Exemplo n.º 8
0
def test_coordinate_from_spherical() -> None:
    """Test the from_spherical() method of the coordinate class."""
    coordinate_1 = Coordinate(3., 4., 5.)
    coordinate_2 = Coordinate(70., 34., 83.)

    spherical_1 = Coordinate.from_spherical(
        7.0710678118655,
        0.92729521800161,
        0.78539816339745,
    )
    spherical_2 = Coordinate.from_spherical(
        113.77609590771,
        0.45215386228578,
        0.75320133230042,
    )

    assert_coordinate_isclose(coordinate_1, spherical_1)
    assert_coordinate_isclose(coordinate_2, spherical_2)
Exemplo n.º 9
0
def test_markers_position() -> None:
    """Test the properties of the marker class."""
    given_id = 13
    given_position = Coordinate(4., 5., 6.)

    marker = Marker(
        given_id,
        given_position,
    )

    assert (given_id == marker.id)
    assert (given_position == marker.position)
Exemplo n.º 10
0
def test_markers_instantiates() -> None:
    """Test that the marker class can be instantiated."""
    Marker(1, Coordinate(1., 2., 3.))
Exemplo n.º 11
0
def test_marker_str() -> None:
    """Test that the marker string is as expected."""
    m = Marker(4, Coordinate(5, 0, 7))

    assert str(m) == "<Marker 4: 0° left, 5.00m away>"
Exemplo n.º 12
0
def test_coordinates_instantiates() -> None:
    """Test that the coordinate class can be instantiated."""
    Coordinate(1, 2, 3)