Specification for a single slice.
This is intended to be an immutable class that specifies a single slice. Use this in conjunction with get_slices_for_features_dict to generate slices for a dictionary of features.
Examples: - columns = ['age'], features =  This means to slice by the 'age' column. - columns = ['age'], features = [('gender', 'female')] This means to slice by the 'age' column if the 'gender' is 'female'. - For more examples, refer to the tests in slicer_test.py.
__init__( columns=(), features=() )
Initialises a SingleSliceSpec.
columns: an iterable of column names to slice on.
features: a iterable of features to slice on. Each feature is a (key, value) tuple. Note that the value can be either a string or an int, and the type is taken into account when comparing values, so SingleSliceSpec(features=[('age', '5')]) will not match a slice with age=5.
ValueError: There was overlap between the columns specified in columns and those in features.
ValueError: columns or features was a string: they should probably be a singleton list containing that string.
Generates all slices that match this specification from the data.
Should only be called within this file.
Examples: - columns = , features =  slice accessor has features age=, gender=['f'], interest=['knitting'] returns [] - columns = ['age'], features = [('gender', 'f')] slice accessor has features age=, gender=['f'], interest=['knitting'] returns [[('age', 5), ('gender, 'f')]] - columns = ['interest'], features = [('gender', 'f')] slice accessor has features age=, gender=['f'], interest=['knitting', 'games'] returns [[('gender', 'f'), ('interest, 'knitting')], [('gender', 'f'), ('interest, 'games')]]
accessor: slice accessor.
A SliceKeyType for each slice that matches this specification. Nothing will be yielded if there no slices matched this specification. The entries in the yielded SliceKeyTypes are guaranteed to be sorted by key names (and then values, if necessary), ascending.
Returns True if this specification represents the overall slice.
Determines if this slice spec is applicable to a slice of data.
slice_key: The slice as a SliceKeyType
True if the slice_spec is applicable to the given slice, False otherwise.