question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better access to logical operand predicates

See original GitHub issue

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).

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Apr 30, 2018

Yes, you can do them in Altair. But no, you can’t have or and not as keys within the same object… I’m not quite sure how to interpret your intent here.

Is this what you were intending to do?

{'and': [
        {'or': [
            alt.FieldRangePredicate(field='year', range=[1850, 1880]), 
            alt.FieldRangePredicate(field='year', range=[1960, 2000])
        ]},
        {'not': alt.FieldRangePredicate(field='year', range=[1870, 1880])}
    ]
} 
0reactions
jakevdpcommented, Aug 9, 2018

@breadbaron fixed in #1075, which will make it into the 2.2 release 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Db2 12 - Predicates and access path selection - IBM
The Predicates of a SQL statement affect how Db2 selects the access path for the statement. ... that are connected together by AND...
Read more >
Unit 2 Lab 3 Teacher Guide - The Beauty and Joy of Computing
Predicates are reporters that report only Boolean values: true or false . Students have used predicates with conditionals such as if and repeat...
Read more >
Overview of Predicates | InterSystems SQL Reference
Use of Predicates​​ A predicate is a condition expression that evaluates to a boolean value, either true or false. Predicates can be used...
Read more >
Predicate expressions - Splunk Documentation
Examples of relational operators are equal to ( = ) and is greater than ( > ). clientip = "192.0.2.0" count > 15....
Read more >
avpath - Predicates - Cloud - Talend Help Center
avpath allows you to use the following types of operators in predicate expressions: comparison operators. string comparison operators. logical operators.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found