create_expr

sherpa.utils.create_expr(vals, mask=None, format='%s', delim='-')[source] [edit on github]

Create a string representation of a filter.

Use the mask to convert the input values into a set of comma-separated filters - low value and high value, separated by the delimiter - that represent the data. If the mask is not given then the values must be “channel” values (that is, two values are consecutive if there difference is 1).

Parameters:
valssequence

The values that represent the sequence if mask is not None, otherwise the selected channel numbers (in this case integer values).

masksequence of bool or None, optional

The mask setting for the full dataset, without any filtering applied. A value of True indicates the element is included and False means it is excluded.

formatstr, optional

The format used to display each value.

delimstr, optional

The separator for a range.

Raises:
ValueError

If the vals and mask sequences do not match: the length of vals must equal the number of True values in mask.

See also

create_expr_integrated, parse_expr

Examples

>>> create_expr([1, 2, 3, 4])
'1-4'
>>> create_expr([1, 2, 4, 5, 7])
'1-2,4-5,7'
>>> create_expr([1, 2, 3, 4], [True, True, True, True])
'1-4'
>>> create_expr([0.1, 0.2, 0.4, 0.8], [True, True, True, True])
'0.1-0.8'
>>> create_expr([0.1, 0.2, 0.4, 0.8], [True, True, True, False, False, True])
'0.1-0.4,0.8'