laserkelvin / PySpecTools

Routines for rotational spectroscopy analysis written in Python 3
MIT License
31 stars 5 forks source link

process_linelist_batch does not read in param_dic or **kwargs #17

Open aowen-uwmad opened 4 years ago

aowen-uwmad commented 4 years ago

H. Smith, UW - Madison, found the issue that .process_linelist_batch() does not read in user options for passing to the .process_linelist() function. (the following line numbers are based on the assignment.py file located in /pyspectools/spectra)

param_dict

I think the issue lies in the preprocessing at the start of the function, lines 2433 - 2438:

   if param_dict == yml_path:
       raise ValueError("Please provide arguments to param_dict or yml_path.")
   if yml_path:
       param_dict = routines.read_yaml(yml_path)
       yml_path = Path(yml_path)
       root = yml_path.parents[0]

These are the only two checks of the input. The first check is fine, however if yml_path: reuses the param_dict keyword name and thus overwrites any keywords that the user provides in param_dict in the initial function call. Suggest renaming this variable.

**kwargs

Additional **kwargs are currently not passed to the .process_linelist() function. Currently only the default subdict items generated by the param_dict = routines.read_yaml(yml_path) are being passed in lines 2455, 2457, which appears to affect only the linelist object:

   for name, subdict in param_dict.items():
           ...
           linelist_obj = func(name=name, **subdict)
           ...
           self.process_linelist(name=linelist_obj.name, linelist=linelist_obj)

Suggested fix

The attached code block assumes param_dict > **kwargs and they are .process_linelist() options, and that routines.read_yaml(yml_path) affects only the LineList object.

process_linelist_batch-modified.txt