neurokernel.plsel.SelectorMethods

class neurokernel.plsel.SelectorMethods[source]

Class for manipulating and using path-like selectors.

Contains class methods for expanding selectors, selecting rows from a Pandas DataFrame using a selector, etc.

The class can also be used to create new MultiIndex instances from selectors that can be fully expanded into an explicit set of identifiers (and therefore contain no ambiguous symbols such as ‘*’ or ‘[:]’).

__init__()

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

are_consecutive(int_list) Check whether a list of integers is consecutive.
are_disjoint(*selectors) Check whether several selectors are disjoint.
collapse(selector) Collapse a selector into a single string.
count_ports(selector) Count number of distinct port identifiers in unambigious selector.
expand(selector[, pad_len]) Expand an unambiguous selector into a list of identifiers.
get_index(df, selector[, start, stop, names]) Return index corresponding to rows selected by specified selector.
get_tuples(df, selector[, start, stop]) Return tuples containing index labels selected by specified selector.
index_to_selector(idx) Convert an index into an expanded port selector.
is_ambiguous(selector) Check whether a selector cannot be expanded into an explicit list of identifiers.
is_expandable(selector) Check whether a selector can be expanded into multiple identifiers.
is_identifier(s) Check whether a selector or token sequence can identify a single port.
is_in(s, t) Check whether all of the identifiers in one selector are comprised by another.
is_selector(s) Check whether a string or sequence is a valid selector.
is_selector_empty(selector) Check whether a string or sequence is an empty selector.
is_selector_seq(s) Check whether a sequence is a valid selector.
is_selector_str(s) Check whether a string is a valid selector.
make_index(selector[, names]) Create an index from the specified selector.
make_index_two_concat(sel_0, sel_1[, names]) Create an index from two selectors concatenated elementwise.
make_index_two_prod(sel_0, sel_1[, names]) Create an index from the product of two selectors.
max_levels(selector) Return maximum number of token levels in selector.
p_error(p)
p_level(p) level : ASTERISK | INTEGER | INTEGER_SET | INTERVAL | STRING | STRING_SET
p_selector_comma_selector(p) selector : selector COMMA selector
p_selector_dotplus_selector(p) selector : selector DOTPLUS selector
p_selector_level(p) selector : level
p_selector_paren_selector(p) selector : LPAREN selector RPAREN
p_selector_plus_selector(p) selector : selector PLUS selector
p_selector_selector_level(p) selector : selector level
p_selector_selector_plus_level(p) selector : selector PLUS level
pad_parsed(selector[, pad_len, inplace]) Pad token lists in a parsed selector to some maximum length.
pad_selector(selector[, pad_len]) Expand and pad a selector with blank tokens.
pad_tuple_list(tuple_list, pad_len) Pad a list of tuples with blank strings.
parse(selector[, pad_len]) Parse a selector string into tokens.
select(df, selector[, start, stop]) Select rows from DataFrame using a path-like selector.
t_ASTERISK(t) /*
t_COMMA(t) ,
t_DOTPLUS(t) .+
t_INTEGER(t) /?d+
t_INTEGER_SET(t) /?[(?:d+,?)+]
t_INTERVAL(t) /?[d*:d*]
t_LPAREN(t) (
t_PLUS(t) +
t_RPAREN(t) )
t_STRING(t) /[^*/[]():,.d][^+*/[]():,.]*
t_STRING_SET(t) /?[(?:[^+*/[]():,.d][^+*/[]():,.]*,?)+]
t_error(t)
to_identifier(s) Convert an expanded selector/token sequence into a single port identifier string.
tokenize(selector) Tokenize a selector string.
tokens_to_str(tokens) Convert expanded/parsed token sequence into a single selector string.

Attributes

lexer
parser
tokens