astropy / specreduce

Tools for the reduction of spectroscopic observations from Optical and NIR instruments
https://specreduce.readthedocs.io
61 stars 38 forks source link

test_supported_models and test_transmission_model fails #116

Closed olebole closed 2 years ago

olebole commented 2 years ago

I am currently packaging specreduce for Debian. When running the CI test after building, I get the following error:

____________________________ test_supported_models _____________________________

self = <astropy.io.ascii.core.BaseInputter object at 0x7fd5013154b0>
table = None, newline = None

    def get_lines(self, table, newline=None):
        """…"""
        try:
            if (hasattr(table, 'read')
>                   or ('\n' not in table + '' and '\r' not in table + '')):
E                   TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

/usr/lib/python3/dist-packages/astropy/io/ascii/core.py:329: TypeError

During handling of the above exception, another exception occurred:

self = <astropy.io.ascii.core.BaseInputter object at 0x7fd5013154b0>
table = None, newline = None

    def get_lines(self, table, newline=None):
        """…"""
        try:
            if (hasattr(table, 'read')
                    or ('\n' not in table + '' and '\r' not in table + '')):
                with get_readable_fileobj(table,
                                          encoding=self.encoding) as fileobj:
                    table = fileobj.read()
            if newline is None:
                lines = table.splitlines()
            else:
                lines = table.split(newline)
        except TypeError:
            try:
                # See if table supports indexing, slicing, and iteration
>               table[0]
E               TypeError: 'NoneType' object is not subscriptable

/usr/lib/python3/dist-packages/astropy/io/ascii/core.py:340: TypeError

During handling of the above exception, another exception occurred:

table = None
read_kwargs = {'fast_reader': {'enable': True}, 'fill_values': [('', '0')], 'names': ['wavelength', 'extinction']}
format = None, fast_reader = {'enable': True}

    def _guess(table, read_kwargs, format, fast_reader):
        […]
        # keep track of the failed guess and move on.
        for guess_kwargs in filtered_guess_kwargs:
            t0 = time.time()
            try:
                # If guessing will try all Readers then use strict req'ts on column names
                if 'Reader' not in read_kwargs:
                    guess_kwargs['strict_names'] = True

                reader = get_reader(**guess_kwargs)

                reader.guessing = True
                dat = reader.read(table)
                _read_trace.append({'kwargs': copy.deepcopy(guess_kwargs),
                                    'Reader': reader.__class__,
                                    'status': 'Success (guessing)',
                                    'dt': f'{(time.time() - t0) * 1000:.3f} ms'})
                return dat

            except guess_exception_classes as err:
                _read_trace.append({'kwargs': copy.deepcopy(guess_kwargs),
                                    'status': f'{err.__class__.__name__}: {str(err)}',
                                    'dt': f'{(time.time() - t0) * 1000:.3f} ms'})
                failed_kwargs.append(guess_kwargs)
        else:
            # Failed all guesses, try the original read_kwargs without column requirements
            try:
                reader = get_reader(**read_kwargs)
>               dat = reader.read(table)

/usr/lib/python3/dist-packages/astropy/io/ascii/ui.py:542: 

self = <astropy.io.ascii.basic.Basic object at 0x7fd501565870>, table = None

    def read(self, table):
        """…"""
        # If ``table`` is a file then store the name in the ``data``
        # attribute. The ``table`` is a "file" if it is a string
        # without the new line specific to the OS.
        with suppress(TypeError):
            # Strings only
            if os.linesep not in table + '':
                self.data.table_name = os.path.basename(table)

        # If one of the newline chars is set as field delimiter, only
        # accept the other one as line splitter
        if self.header.splitter.delimiter == '\n':
            newline = '\r'
        elif self.header.splitter.delimiter == '\r':
            newline = '\n'
        else:
            newline = None

        # Get a list of the lines (rows) in the table
>       self.lines = self.inputter.get_lines(table, newline=newline)

/usr/lib/python3/dist-packages/astropy/io/ascii/core.py:1356: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <astropy.io.ascii.core.BaseInputter object at 0x7fd5013154b0>
table = None, newline = None

    def get_lines(self, table, newline=None):
        """…"""
        try:
            if (hasattr(table, 'read')
                    or ('\n' not in table + '' and '\r' not in table + '')):
                with get_readable_fileobj(table,
                                          encoding=self.encoding) as fileobj:
                    table = fileobj.read()
            if newline is None:
                lines = table.splitlines()
            else:
                lines = table.split(newline)
        except TypeError:
            try:
                # See if table supports indexing, slicing, and iteration
                table[0]
                table[0:1]
                iter(table)
                if len(table) > 1:
                    lines = table
                else:
                    # treat single entry as if string had been passed directly
                    if newline is None:
                        lines = table[0].splitlines()
                    else:
                        lines = table[0].split(newline)

            except TypeError:
>               raise TypeError(
                    'Input "table" must be a string (filename or data) or an iterable')
E               TypeError: Input "table" must be a string (filename or data) or an iterable

/usr/lib/python3/dist-packages/astropy/io/ascii/core.py:353: TypeError

During handling of the above exception, another exception occurred:

    def test_supported_models():
        """…"""
        for model in SUPPORTED_EXTINCTION_MODELS:
>           ext = AtmosphericExtinction(model=model)

specreduce/tests/test_extinction.py:17: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
specreduce/calibration_data.py:325: in __init__
    t = Table.read(model_path, format="ascii", names=['wavelength', 'extinction'])
/usr/lib/python3/dist-packages/astropy/table/connect.py:62: in __call__
    out = self.registry.read(cls, *args, **kwargs)
/usr/lib/python3/dist-packages/astropy/io/registry/core.py:212: in read
    data = reader(*args, **kwargs)
/usr/lib/python3/dist-packages/astropy/io/ascii/connect.py:18: in io_read
    return read(filename, **kwargs)
/usr/lib/python3/dist-packages/astropy/io/ascii/ui.py:359: in read
    dat = _guess(table, new_kwargs, format, fast_reader)
table = None
read_kwargs = {'fast_reader': {'enable': True}, 'fill_values': [('', '0')], 'names': ['wavelength', 'extinction']}
format = None, fast_reader = {'enable': True}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    def _guess(table, read_kwargs, format, fast_reader):
        […]
                msg = ['',
                       '************************************************************************',
                       '** ERROR: Unable to guess table format with the guesses listed above. **',
                       '**                                                                    **',
                       '** To figure out why the table did not read, use guess=False and      **',
                       '** fast_reader=False, along with any appropriate arguments to read(). **',
                       '** In particular specify the format and any known attributes like the **',
                       '** delimiter.                                                         **',
                       '************************************************************************']
                lines.extend(msg)
>               raise core.InconsistentTableError('\n'.join(lines))
E               astropy.io.ascii.core.InconsistentTableError: 
E               ERROR: Unable to guess table format with the guesses listed below: […]
/usr/lib/python3/dist-packages/astropy/io/ascii/ui.py:573: InconsistentTableError

That is with astropy 5.1, specreduce 1.0.0, synphot 1.1.1, Python 3.10.5. The test runs on an isolated computer, i.e. no internet; however there is no hint that something was tried to downloaded in the error message. The error message for test_transmission_model looks similar. Full build log is attached. specreduce_1.0.0-1_amd64.build.txt

olebole commented 2 years ago

After some investigation, I am closing this. the transmission and emission model data comes from the specreduce-data repository, which is not accessible during the Debian build. I will package this repository as well, as it seems to be useful when using specreduce.