Build: #1 failed
Job: Pipeline PR Test 6.6.6 failed
build fitting configuration[inp6-expected6-false]: Test case result
The below summarizes the result of the test " build fitting configuration[inp6-expected6-false]" in build 1 of Pipeline - Pipeline Pull Request Test - PIPE-2893-hsd_baseline-enable-sinusoid-option - Pipeline PR Test 6.6.6.
- Description
- build fitting configuration[inp6-expected6-false]
- Test class
- pipeline.hsd.tasks.baseline.worker_test
- Method
- test_build_fitting_configuration[inp6-expected6-False]
- Duration
- < 1 sec
- Status
- Failed (New Failure)
Error Log
ValueError: Unsupported fitting function type: <class 'list'>
inp = {17: 'poly', 19: 'cspline', 23: 'cspline'}
expected = {'17': 'poly', 19: 'spline'}, should_raise = False
@pytest.mark.parametrize(
"inp, expected, should_raise",
[
# valid inputs
({17: DEF, 19: DEF, 23: DEF}, None, False),
({17: DEF, 19: DEF, 23: DEF}, {}, False),
({17: "cspline", 19: "cspline", 23: "cspline"}, "spline", False), # SPLINE = CSPLINE in the FittingFunction class of fitrorder.py
({17: DEF, 19: DEF, 23: DEF}, {30: "poly"}, False),
({17: "poly", 19: "poly", 23: "poly"}, "poly", False),
({17: DEF, 19: DEF, 23: "poly"}, {"23":"poly"}, False),
({17:"poly", 19:"cspline", 23: DEF}, {"17":"poly", 19:"spline"}, False),
({17:"poly", 19:"cspline", 23:"poly"}, {17:"poly", 19:"spline", 23:"poly"}, False),
# error inputs
(ValueError, "badfunc", True),
(ValueError, {19:"invalid"}, True),
],
)
def test_build_fitting_configuration(inp, expected, should_raise):
if should_raise:
with pytest.raises(expected):
worker.build_fitting_configuration(inp, SPWS)
return
> cfg = worker.build_fitting_configuration(inp, SPWS)
hsd/tasks/baseline/worker_test.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
spw_id_list = {17: 'poly', 19: 'cspline', 23: 'cspline'}
fit_function = [17, 19, 23], ms = None, context = None, switchpoly = True
@staticmethod
def build_fitting_configuration(
spw_id_list: Union[List[int], set[Any]],
fit_function: Optional[Union[str, Dict[Union[int, str], str]]] = "cspline",
ms: MeasurementSet = None,
context: Context = None,
switchpoly=True
) -> Dict[int, BaselineFitParamConfig]:
"""
Convert the fit_function parameter into a dictionary mapping each SPW ID to its BaselineFitParamConfig.
If fit_function is None or falsy, the default 'cspline' is used.
If a single string is provided, one BaselineFitParamConfig instance is created and applied to all SPWs.
If a dictionary is provided, keys are normalized to integers; SPWs not specified default to 'cspline'.
Args:
switchpoly:
context:
ms: Measurement set
fit_function: The fit function parameter (str, dict, or None).
spw_id_list: List of spectral window IDs to process.
Raises:
ValueError: fit_function has unsupported value.
Returns:
A dictionary mapping each SPW ID (int) to a BaselineFitParamConfig instance.
"""
valid_functions = {'spline', 'cspline', 'poly', 'polynomial', 'sinusoid'}
if isinstance(fit_function, str):
if fit_function not in valid_functions:
raise ValueError(f"Unsupported fitting function value: {fit_function}")
heuristics_out = dict.fromkeys(
spw_id_list,
BaselineFitParamConfig(
fitfunc=fit_function,
switchpoly=switchpoly
)
)
return heuristics_out
if isinstance(fit_function, dict):
spw_function_map = dict.fromkeys(spw_id_list, "cspline")
spw_function_map.update(fit_function)
heuristics_out = {}
# Need to fill in the input fit functions. We could make this cleaner without
# the virtual2real section, but I'm not sure if the keys will match.
for key, value in spw_function_map.items():
# Check that all the functions are supported.
if not value in valid_functions:
raise ValueError(f"Unsupported fitting function value: {value}")
_key = context.observing_run.virtual2real_spw_id(key, ms) if context else key
heuristics_out[_key] = BaselineFitParamConfig(
fitfunc=spw_function_map[key],
switchpoly=switchpoly
)
return heuristics_out
else:
> raise ValueError(f"Unsupported fitting function type: {type(fit_function)}")
E ValueError: Unsupported fitting function type: <class 'list'>
hsd/tasks/baseline/worker.py:662: ValueError