Skip to content

Better access to logical operand predicates #695

@jakevdp

Description

@jakevdp

Vega-Lite has a number of logical operands; e.g.

  • alt.LogicalAndPredicate
  • alt.LogicalOrPredicate
  • alt.LogicalNotPredicate

These come up, for example, in constructing filter transforms. It would be useful to make these available to Altair users via Python's logical operators, &, |, and ~, respectively.

There are two challenges:

  1. How to implement them effectively... maybe create some sort of PredicateMixin for these classes? If we were constructing the wrapper classes by hand, it would make sense for alt.Predicate to be the base class of each of these logical predicates... perhaps we should change the code generation framework so that this kind of class hierarchy is (optionally) inferred in generated classes? Sounds hard to do well in a general way, though.

  2. The interaction with selection operands (e.g. alt.SelectionOr, alt.SelectionAnd, alt.SelectionNot, and alt.NamedSelection) makes this a bit tricky, because NamedSelection objects serve two purposes in Altair (they act both as a alt.SelectionDef and a alt.SelectionPredicate depending on the context).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions