ZeroDivisionError: float division by zero when attempting to read back an empty table
Summary
ZeroDivisionError
is raised during an attempt to read an empty (but initialized) table from the DB.
The error is related to the units management (conversion/decomposition of dimensionless units).
Steps to reproduce
$ git checkout -b feature/atmosphere_db_2
$ mamba create -n calibpipe -c conda-forge python=3.12
$ pip install -e .[test]
$ cwltool dpps-uc-120-13.cwl dpps-uc-120-13.cfg
What is the expected correct behavior?
In this case, and empty table with a correct schema and units must be returned.
Relevant logs and/or screenshots
2024-05-10 17:48:07,188 ERROR [calibpipe.SelectMDP] (tool.run): Caught unexpected exception: float division by zero
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/ctapipe/core/tool.py", line 426, in run
self.start()
File "/usr/local/lib/python3.12/site-packages/calibpipe/tools/reference_atmospheric_profile_selector.py", line 78, in start
previous_atmospheric_model_table = TableHandler.read_table_from_database(AtmosphericModelContainer, connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/calibpipe/database/interfaces/table_handler.py", line 88, in read_table_from_database
return QTable(
^^^^^^^
File "/usr/local/lib/python3.12/site-packages/astropy/table/table.py", line 908, in __init__
self._set_column_attribute("unit", units)
File "/usr/local/lib/python3.12/site-packages/astropy/table/table.py", line 942, in _set_column_attribute
if value not in (np.ma.masked, None):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/numpy/ma/core.py", line 4182, in __eq__
return self._comparison(other, operator.eq)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/numpy/ma/core.py", line 4138, in _comparison
check = compare(sdata, odata)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/astropy/units/core.py", line 960, in __eq__
return is_effectively_unity(self._to(other))
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/astropy/units/core.py", line 1189, in _to
return self_decomposed.scale / other_decomposed.scale
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero
Environment
- Version used: e623a142
- Operation System: python:3.12