seg1d.processing.Features.shared

static Features.shared(D1, D2=None)[source]

get data with only features shared amongst all sets

Parameters:
D1Dict{feature:value} or List[Dict{feature:value}]

sets of references to be parsed for shared features

D2Dict{feature:value} or List[Dict{feature:value}], optional

optional dictionary, if supplied, will return as a secondary dict that also contains only shared features

Returns:
d1same as input

original data with only features shared by all inputs

d1, d2same as input

original data with only features shared by all inputs

Notes

This relies on proper feature labels. It cannot take arrays as there is no way to know what columns correspond to what features.

Examples

>>> import seg1d.processing as process
>>> d1 = {'a':[1,2], 'b':[2,2]}
>>> d2 = {'e':[3,2], 'b':[5,1], 'a':[5,5]}
>>> d3 = {'b':[8,2], 'a':[3,3], 'c': [1,2]}
>>> r1, r2 = process.Features.shared(d1,[d2,d3])
>>> print({k:r1[k] for k in sorted(r1)})
{'a': [1, 2], 'b': [2, 2]}
>>> print({k:r[k] for r in r2 for k in sorted(r)})
{'a': [3, 3], 'b': [8, 2]}