Beispiel #1
0
    def test_get_config_attribute(self) -> None:
        create_config(self.test_dir + 'PynPoint_config.ini')
        Pypeline(self.test_dir, self.test_dir, self.test_dir)

        storage = DataStorage(self.test_dir + 'PynPoint_database.hdf5')
        port = ConfigPort('config', None)

        with pytest.warns(UserWarning) as warning:
            attribute = port.get_attribute('CPU')

        assert len(warning) == 1
        assert warning[0].message.args[0] == 'ConfigPort can not load data unless a database is ' \
                                             'connected.'

        assert attribute is None

        port = ConfigPort('config', storage)

        attribute = port.get_attribute('CPU')
        assert attribute == 1

        attribute = port.get_attribute('NFRAMES')
        assert attribute == 'NAXIS3'

        attribute = port.get_attribute('PIXSCALE')
        assert np.allclose(attribute, 0.027, rtol=limit, atol=0.)

        with pytest.warns(UserWarning) as warning:
            attribute = port.get_attribute('test')

        assert len(warning) == 1
        assert warning[0].message.args[
            0] == 'The attribute \'test\' was not found.'

        assert attribute is None
Beispiel #2
0
    def test_create_config_port(self) -> None:
        storage = DataStorage(self.test_dir + 'PynPoint_database.hdf5')

        with pytest.raises(ValueError) as error:
            ConfigPort('images', storage)

        assert str(error.value) == 'The tag name of the central configuration should be ' \
                                   '\'config\'.'

        port = ConfigPort('config', None)

        with pytest.warns(UserWarning) as warning:
            check_error = port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[0] == 'ConfigPort can not load data unless a database is ' \
                                             'connected.'

        assert not check_error

        port = ConfigPort('config', storage)
        assert isinstance(port, ConfigPort)

        with pytest.warns(UserWarning) as warning:
            port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[0] == 'No data under the tag which is linked by the ' \
                                             'ConfigPort.'
Beispiel #3
0
    def test_get_config_attribute(self):
        create_config(self.test_dir + "PynPoint_config.ini")
        Pypeline(self.test_dir, self.test_dir, self.test_dir)

        storage = DataStorage(self.test_dir + "PynPoint_database.hdf5")
        port = ConfigPort("config", None)

        with pytest.warns(UserWarning) as warning:
            attribute = port.get_attribute("CPU")

        assert len(warning) == 1
        assert warning[0].message.args[0] == "ConfigPort can not load data unless a database is " \
                                             "connected."

        assert attribute is None

        port = ConfigPort("config", storage)

        attribute = port.get_attribute("CPU")
        assert attribute == 1

        attribute = port.get_attribute("NFRAMES")
        assert attribute == "NAXIS3"

        attribute = port.get_attribute("PIXSCALE")
        assert np.allclose(attribute, 0.027, rtol=limit, atol=0.)

        with pytest.warns(UserWarning) as warning:
            attribute = port.get_attribute("test")

        assert len(warning) == 1
        assert warning[0].message.args[
            0] == "No attribute found - requested: test."

        assert attribute is None
Beispiel #4
0
    def test_create_config_port(self):
        storage = DataStorage(self.test_dir + "PynPoint_database.hdf5")

        with pytest.raises(ValueError) as error:
            ConfigPort("images", storage)

        assert str(
            error.value
        ) == "The tag name of the central configuration should be 'config'."

        port = ConfigPort("config", None)

        with pytest.warns(UserWarning) as warning:
            check_error = port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[0] == "ConfigPort can not load data unless a database is " \
                                             "connected."

        assert not check_error

        port = ConfigPort("config", storage)
        assert isinstance(port, ConfigPort)

        with pytest.warns(UserWarning) as warning:
            port._check_error_cases()

        assert len(warning) == 1
        assert warning[0].message.args[
            0] == "No data under the tag which is linked by the ConfigPort."
Beispiel #5
0
    def __init__(self,
                 name_in):
        """
        Abstract constructor of a PypelineModule which needs a name as identifier.

        :param name_in: The name of the PypelineModule.
        :type name_in: str

        :return: None
        """

        assert (isinstance(name_in, str)), "Name of the PypelineModule needs to be a string."

        self._m_name = name_in
        self._m_data_base = None
        self._m_config_port = ConfigPort("config")
Beispiel #6
0
    def __init__(self, name_in: str) -> None:
        """
        Abstract constructor of a :class:`~pynpoint.core.processing.PypelineModule`.

        Parameters
        ----------
        name_in : str
            The name of the :class:`~pynpoint.core.processing.PypelineModule`.

        Returns
        -------
        NoneType
            None
        """

        self._m_name = name_in
        self._m_data_base = None
        self._m_config_port = ConfigPort('config')
Beispiel #7
0
    def __init__(self,
                 name_in):
        """
        Abstract constructor of a PypelineModule. Needs a name as identifier.

        Parameters
        ----------
        name_in : str
            The name of the PypelineModule.

        Returns
        -------
        NoneType
            None
        """

        assert isinstance(name_in, str), 'Name of the PypelineModule needs to be a string.'

        self._m_name = name_in
        self._m_data_base = None
        self._m_config_port = ConfigPort('config')