예제 #1
0
        def test__outside_border__relocates_to_source_border(self):
            thetas = np.linspace(0.0, 2.0 * np.pi, 32)
            circle = list(map(lambda x: (np.cos(x), np.sin(x)), thetas))

            source_border = analysis.SourcePlaneBorder(circle,
                                                       3,
                                                       centre=(0.0, 0.0))

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(2.5, 0.37))
            assert source_border.coordinates_to_radius(
                relocated_coordinate) == pytest.approx(1.0, 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(25.3, -9.2))
            assert source_border.coordinates_to_radius(
                relocated_coordinate) == pytest.approx(1.0, 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(13.5, 0.0))
            assert source_border.coordinates_to_radius(
                relocated_coordinate) == pytest.approx(1.0, 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(-2.5, -0.37))
            assert source_border.coordinates_to_radius(
                relocated_coordinate) == pytest.approx(1.0, 1e-3)
예제 #2
0
        def test__inside_border__move_factor_is_1(self):
            coordinates = [(1.0, 0.0), (0.0, 1.0), (-1.0, 0.0), (0.0, -1.0)]

            source_border = analysis.SourcePlaneBorder(coordinates,
                                                       3,
                                                       centre=(0.0, 0.0))

            assert source_border.move_factor(coordinate=(0.5, 0.0)) == 1.0
            assert source_border.move_factor(coordinate=(-0.5, 0.0)) == 1.0
            assert source_border.move_factor(coordinate=(0.25, 0.25)) == 1.0
            assert source_border.move_factor(coordinate=(0.0, 0.0)) == 1.0
예제 #3
0
        def test__including_shift_sets_correct_values(self):
            coordinates = [(2.0, 1.0), (1.0, 2.0), (0.0, 1.0), (1.0, 0.0)]

            source_border = analysis.SourcePlaneBorder(coordinates,
                                                       3,
                                                       centre=(1.0, 1.0))

            assert source_border.coordinates == [(2.0, 1.0), (1.0, 2.0),
                                                 (0.0, 1.0), (1.0, 0.0)]
            assert source_border.radii == [1.0, 1.0, 1.0, 1.0]
            assert source_border.thetas == [0.0, 90.0, 180.0, 270.0]
예제 #4
0
        def test__outside_border_double_its_radius__move_factor_is_05(self):
            coordinates = [(1.0, 0.0), (0.0, 1.0), (-1.0, 0.0), (0.0, -1.0)]

            source_border = analysis.SourcePlaneBorder(coordinates,
                                                       3,
                                                       centre=(0.0, 0.0))

            assert source_border.move_factor(
                coordinate=(2.0, 0.0)) == pytest.approx(0.5, 1e-3)
            assert source_border.move_factor(
                coordinate=(0.0, 2.0)) == pytest.approx(0.5, 1e-3)
            assert source_border.move_factor(
                coordinate=(-2.0, 0.0)) == pytest.approx(0.5, 1e-3)
            assert source_border.move_factor(
                coordinate=(0.0, -2.0)) == pytest.approx(0.5, 1e-3)
예제 #5
0
        def test__outside_border_simple_cases__relocates_to_correct_coordinate(
                self):
            thetas = np.linspace(0.0, 2.0 * np.pi, 16)
            circle = list(map(lambda x: (np.cos(x), np.sin(x)), thetas))

            source_border = analysis.SourcePlaneBorder(circle,
                                                       3,
                                                       centre=(0.0, 0.0))

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(2.0, 0.0))
            assert relocated_coordinate == pytest.approx((1.0, 0.0), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(1.0, 1.0))
            assert relocated_coordinate == pytest.approx(
                (0.5 * math.sqrt(2), 0.5 * math.sqrt(2)), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(0.0, 2.0))
            assert relocated_coordinate == pytest.approx((0.0, 1.0), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(-1.0, 1.0))
            assert relocated_coordinate == pytest.approx(
                (-0.5 * math.sqrt(2), 0.5 * math.sqrt(2)), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(-2.0, 0.0))
            assert relocated_coordinate == pytest.approx((-1.0, 0.0), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(-1.0, -1.0))
            assert relocated_coordinate == pytest.approx(
                (-0.5 * math.sqrt(2), -0.5 * math.sqrt(2)), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(0.0, -1.0))
            assert relocated_coordinate == pytest.approx((0.0, -1.0), 1e-3)

            relocated_coordinate = source_border.relocated_coordinate(
                coordinate=(1.0, -1.0))
            assert relocated_coordinate == pytest.approx(
                (0.5 * math.sqrt(2), -0.5 * math.sqrt(2)), 1e-3)