How to use the pynpoint.core.dataio.ConfigPort function in pynpoint

To help you get started, we’ve selected a few pynpoint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PynPoint / PynPoint / tests / test_core / test_configport.py View on Github external
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()
github PynPoint / PynPoint / tests / test_core / test_configport.py View on Github external
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 attribute == pytest.approx(0.027, rel=self.limit, abs=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.'
github PynPoint / PynPoint / tests / test_core / test_configport.py View on Github external
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
github PynPoint / PynPoint / tests / test_core / test_configport.py View on Github external
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.'
github PynPoint / PynPoint / tests / test_core / test_configport.py View on Github external
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
github PynPoint / PynPoint / pynpoint / core / processing.py View on Github external
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')
github PynPoint / PynPoint / pynpoint / core / processing.py View on Github external
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')
github PynPoint / PynPoint / pynpoint / core / dataio.py View on Github external
tag : str
            The tag name of the port. The port can be used to get data from the dataset with the
            key `config`.
        data_storage_in : pynpoint.core.dataio.DataStorage
            The input DataStorage. It is possible to give the constructor of an ConfigPort a
            DataStorage instance which will link the port to that DataStorage. Usually the
            DataStorage is set later by calling
            :func:`~pynpoint.core.dataio.Port.set_database_connection`.

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

        super(ConfigPort, self).__init__(tag, data_storage_in)

        if tag != 'config':
            raise ValueError('The tag name of the central configuration should be \'config\'.')