After one inicializates and instace of TrialDataManager(), the print function works as expected.
tdm = TrialDataManager()
print(tdm)
TrialDataManager:
Base data fields:
None
Source data fields:
None
Pre-event-selection static data fields:
None
Static data fields:
None
Global fitparam data fields:
None
After adding the data fields, it still works before initializing them:
{
"name": "UFuncTypeError",
"message": "ufunc 'minimum' did not contain a loop with signature matching types (dtype([('ra', '<f8'), ('dec', '<f8'), ('weight', '<f8')]), dtype([('ra', '<f8'), ('dec', '<f8'), ('weight', '<f8')])) -> None",
"stack": "---------------------------------------------------------------------------
UFuncTypeError Traceback (most recent call last)
Cell In[20], line 1
----> 1 print(tdm)
File ~/LRZ Sync+Share/master_thesis/Projects/stack_analysis_masq_BLLacs/skyllh.stack_public/skyllh/core/trialdata.py:578, in TrialDataManager.__str__(self)
574 s += '\
'
576 s1 = 'Source data fields:\
'
577 s2 = '\
'.join(
--> 578 [
579 str(df)
580 for (_, df) in self._source_data_fields_dict.items()
581 ]
582 )
583 if s2 == '':
584 s2 = 'None'
File ~/LRZ Sync+Share/master_thesis/Projects/stack_analysis_masq_BLLacs/skyllh.stack_public/skyllh/core/trialdata.py:579, in <listcomp>(.0)
574 s += '\
'
576 s1 = 'Source data fields:\
'
577 s2 = '\
'.join(
578 [
--> 579 str(df)
580 for (_, df) in self._source_data_fields_dict.items()
581 ]
582 )
583 if s2 == '':
584 s2 = 'None'
File ~/LRZ Sync+Share/master_thesis/Projects/stack_analysis_masq_BLLacs/skyllh.stack_public/skyllh/core/trialdata.py:195, in DataField.__str__(self)
193 if self._values is not None:
194 dtype = str(self._values.dtype)
--> 195 vmin = np.min(self._values)
196 vmax = np.max(self._values)
198 s = f'{classname(self)}: {self.name}: '
File ~/envs/SkyLLH/lib/python3.10/site-packages/numpy/core/fromnumeric.py:2953, in min(a, axis, out, keepdims, initial, where)
2836 @array_function_dispatch(_min_dispatcher)
2837 def min(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
2838 where=np._NoValue):
2839 \"\"\"
2840 Return the minimum of an array or minimum along an axis.
2841
(...)
2951 6
2952 \"\"\"
-> 2953 return _wrapreduction(a, np.minimum, 'min', axis, None, out,
2954 keepdims=keepdims, initial=initial, where=where)
File ~/envs/SkyLLH/lib/python3.10/site-packages/numpy/core/fromnumeric.py:88, in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
85 else:
86 return reduction(axis=axis, out=out, **passkwargs)
---> 88 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
UFuncTypeError: ufunc 'minimum' did not contain a loop with signature matching types (dtype([('ra', '<f8'), ('dec', '<f8'), ('weight', '<f8')]), dtype([('ra', '<f8'), ('dec', '<f8'), ('weight', '<f8')])) -> None"
}
The reason seems to be that the str method for DataField objects computes the minimun and maximum value. But for the Source Data Fields we don't have one parameter with a range of values, but rather two parameters with a single value, namely the declination and right ascension. Therefore, when trying to compute the minima on this special case, it crashes.
A possible solution could be to handle this case of source data fields separatedly, but I don't know if the same bug could arise for the other data fields, and therefore a more profound change is better.
After one inicializates and instace of TrialDataManager(), the print function works as expected.
After adding the data fields, it still works before initializing them:
Nevertheless, after calculating the source data fields, it crashes:
The reason seems to be that the str method for DataField objects computes the minimun and maximum value. But for the Source Data Fields we don't have one parameter with a range of values, but rather two parameters with a single value, namely the declination and right ascension. Therefore, when trying to compute the minima on this special case, it crashes.
A possible solution could be to handle this case of source data fields separatedly, but I don't know if the same bug could arise for the other data fields, and therefore a more profound change is better.