示例#1
0
 def test_init_general_gaussian(self):
     window = "general_gaussian"
     shape = (5, 5)
     w = Window(
         window=window,
         shape=shape,
         p=0.5,
         std=2,
     )
     assert w.is_valid()
     np.testing.assert_array_almost_equal(w.data,
                                          GENERAL_GAUSS55_PWR05_STD2)
     assert w.name == window
     assert w.shape == shape
示例#2
0
    def test_init(
        self,
        window,
        window_type,
        shape,
        kwargs,
        answer_shape,
        answer_coeff,
        answer_circular,
    ):
        if kwargs is None:
            w = Window(window=window, shape=shape)
        else:
            w = Window(window=window, shape=shape, kwargs=kwargs)

        assert w.is_valid()
        assert w.name == window_type
        assert w.shape == answer_shape
        assert w.circular is answer_circular
        np.testing.assert_array_almost_equal(w.data, answer_coeff)
示例#3
0
    def test_is_valid(self):
        change_attribute = np.array([0, 0, 0, 1])

        # Change one attribute at a time and check whether the window is valid
        for i in range(len(change_attribute)):
            w = Window()

            valid_window = True
            if sum(change_attribute[:3]) == 1:
                valid_window = False

            if change_attribute[0]:  # Set type from str to int
                w.name = 1
            elif change_attribute[1]:  # Add a third axis
                w = np.expand_dims(w, 1)
            elif change_attribute[2]:  # Change circular boolean value to str
                w.circular = "True"

            # Roll axis to change which attribute to change next time
            change_attribute = np.roll(change_attribute, 1)

            assert w.is_valid() == valid_window
示例#4
0
 def test_plot_invalid_window(self):
     w = Window()
     w.name = 1
     assert w.is_valid() is False
     with pytest.raises(ValueError, match="Window is invalid."):
         w.plot()