fix input for background.traces, raise error in FlatTrace for negative trace #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR cleans up a few things in Background.
Added a condition to FlatTrace that trace position must be negative. This check was originally done in Background when a FlatTrace was being used, but should generally be done. Before, if trace_pos was negative, a fully masked trace was being returned.
Previously, Background produced an unrelated error if 'traces' was None. Now, if no trace/number is passed in, a FlatTrace in the middle of the image will be used.
There was some other inconsistencies with inputs - the docstring said 'traces' must be a list, but the logic in the code implied that it could be a Trace object not in a list. Also, a FlatTrace object can be defined with either a float or an int, where previously 'Background' allowed only integer inputs. I fixed this to allow either single trace/int/float or list trace/int/float inputs. The only condition is that lists must all be of the same type (either numeric or
Trace
). I also added some checks for input to make sure something valid is passed in fortraces
(either None, int/float or list of int/float to define FlatTraces, or a Trace object, or a list of Trace objects). I also added tests for all of these allowed inputs.