You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 90, in auto_format_func
out = format_func(format, val)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 88, in
format_func = lambda format_, val: format_(val)
^^^^^^^^^^^^
File "/Users/dvandeputte/Repositories/pahfit/pahfit/features/features_format.py", line 16, in _fmt
raise e
File "/Users/dvandeputte/Repositories/pahfit/pahfit/features/features_format.py", line 9, in _fmt
if ma.is_masked(v) or ma.is_masked(v[0]):
~^^^
IndexError: invalid index to scalar variable.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 535, in _pformat_col_iter
yield format_col_str(idx)
^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 523, in format_col_str
left = format_func(col_format, col[(idx,) + multidim0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 103, in _auto_format_func
raise ValueError(f"Format function for value {val} failed.") from err
ValueError: Format function for value 0.0 failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 779, in format
self.pformat(max_lines=1)
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 883, in pformat
lines, outs = _pformat_col(
^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 294, in _pformat_col
col_strs = [
^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 294, in
col_strs = [
^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 537, in _pformat_col_iter
raise ValueError(
ValueError: Unable to parse format string "<function fmt_func.._fmt at 0x103640540>" for entry "[ 0. 0. inf]" in column "power"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/dvandeputte/Downloads/pahfit_debug/debug.py", line 3, in
print(m)
File "/Users/dvandeputte/Repositories/pahfit/pahfit/model.py", line 133, in repr
return self._status_message() + self.features.repr()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/table.py", line 1632, in repr
return self.base_repr(html=False, max_width=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/table.py", line 1606, in base_repr
data_lines, outs = self.formatter._pformat_table(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/Repositories/pahfit/pahfit/features/features_format.py", line 51, in _pformat_table
col.info.format = fmt_func(col.info.format or "g")
^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/utils/data_info.py", line 244, in set
setattr(instance._parent, self.attr, value)
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 1262, in setattr
super().setattr(item, value)
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 783, in format
raise ValueError(
ValueError: Invalid format for column 'power': could not display values in this column using this format
Cause
I don't know how to solve this, but I was able to narrow it down to a certain behavior. We’re using a formatting function that expects 3-tuples as input, and this function is passed to the pretty printer for the table. But astropy.table.pprint, does something automagically with the dimensionality, and ends up passing the individual elements to our function, instead of tuples.
With the working example pack, we get a BoundedMaskedColumn (a type that we derive from the regular MaskedColumn), while its a regular Column for the lines only case.
For some reason, pprint behaves differently in this case, and it probably depends on the details of BoundedMaskedColumn. I have not tried this with a regular MaskedColumn.
Workaround
A temporary workaround would be to add a starlight component to the yaml file, and then remove it in python (by setting model.features = model.features[1:]). This forces the relevant columns to be BoundedMaskedColumn.
The text was updated successfully, but these errors were encountered:
Bug description
The code crashes when trying to print Features.
Reproducing
This is a strange bug, reproducible with very minimal examples
This crashes:
with the following minimal yaml file
On the other hand, if a stellar component is added, everything is fine
Exceptions and tracebacks
Click for full output
Traceback (most recent call last):
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 90, in auto_format_func
out = format_func(format, val)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 88, in
format_func = lambda format_, val: format_(val)
^^^^^^^^^^^^
File "/Users/dvandeputte/Repositories/pahfit/pahfit/features/features_format.py", line 16, in _fmt
raise e
File "/Users/dvandeputte/Repositories/pahfit/pahfit/features/features_format.py", line 9, in _fmt
if ma.is_masked(v) or ma.is_masked(v[0]):
~^^^
IndexError: invalid index to scalar variable.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 535, in _pformat_col_iter
yield format_col_str(idx)
^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 523, in format_col_str
left = format_func(col_format, col[(idx,) + multidim0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 103, in _auto_format_func
raise ValueError(f"Format function for value {val} failed.") from err
ValueError: Format function for value 0.0 failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 779, in format
self.pformat(max_lines=1)
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 883, in pformat
lines, outs = _pformat_col(
^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 294, in _pformat_col
col_strs = [
^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 294, in
col_strs = [
^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/pprint.py", line 537, in _pformat_col_iter
raise ValueError(
ValueError: Unable to parse format string "<function fmt_func.._fmt at 0x103640540>" for entry "[ 0. 0. inf]" in column "power"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/dvandeputte/Downloads/pahfit_debug/debug.py", line 3, in
print(m)
File "/Users/dvandeputte/Repositories/pahfit/pahfit/model.py", line 133, in repr
return self._status_message() + self.features.repr()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/table.py", line 1632, in repr
return self.base_repr(html=False, max_width=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/table.py", line 1606, in base_repr
data_lines, outs = self.formatter._pformat_table(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dvandeputte/Repositories/pahfit/pahfit/features/features_format.py", line 51, in _pformat_table
col.info.format = fmt_func(col.info.format or "g")
^^^^^^^^^^^^^^^
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/utils/data_info.py", line 244, in set
setattr(instance._parent, self.attr, value)
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 1262, in setattr
super().setattr(item, value)
File "/Users/dvandeputte/opt/miniconda3/envs/pahfitcube/lib/python3.11/site-packages/astropy/table/column.py", line 783, in format
raise ValueError(
ValueError: Invalid format for column 'power': could not display values in this column using this format
Cause
I don't know how to solve this, but I was able to narrow it down to a certain behavior. We’re using a formatting function that expects 3-tuples as input, and this function is passed to the pretty printer for the table. But astropy.table.pprint, does something automagically with the dimensionality, and ends up passing the individual elements to our function, instead of tuples.
With the working example pack, we get a BoundedMaskedColumn (a type that we derive from the regular MaskedColumn), while its a regular Column for the lines only case.
For some reason, pprint behaves differently in this case, and it probably depends on the details of BoundedMaskedColumn. I have not tried this with a regular MaskedColumn.
Workaround
A temporary workaround would be to add a starlight component to the yaml file, and then remove it in python (by setting model.features = model.features[1:]). This forces the relevant columns to be BoundedMaskedColumn.
The text was updated successfully, but these errors were encountered: