20
20
from altair .utils .core import TYPECODE_MAP as _TYPE_CODE
21
21
from altair .utils .core import parse_shorthand as _parse
22
22
from altair .utils .schemapi import Optional , SchemaBase , Undefined
23
- from altair .vegalite .v5 .api import Parameter , SelectionPredicateComposition
23
+ from altair .vegalite .v5 .api import Parameter
24
24
from altair .vegalite .v5 .schema import channels
25
25
from altair .vegalite .v5 .schema ._typing import (
26
26
BinnedTimeUnit_T ,
@@ -93,10 +93,6 @@ def _parse_aggregate(
93
93
raise TypeError (msg )
94
94
95
95
96
- def _wrap_composition (predicate : Predicate , / ) -> SelectionPredicateComposition :
97
- return SelectionPredicateComposition (predicate .to_dict ())
98
-
99
-
100
96
def _one_of_flatten (
101
97
values : tuple [OneOfType , ...] | tuple [Sequence [OneOfType ]] | tuple [Any , ...], /
102
98
) -> Sequence [OneOfType ]:
@@ -305,7 +301,10 @@ class field:
305
301
{'field': 'Origin', 'type': 'nominal'}
306
302
307
303
>>> field.one_of("Origin", "Japan", "Europe")
308
- SelectionPredicateComposition({'field': 'Origin', 'oneOf': ['Japan', 'Europe']})
304
+ FieldOneOfPredicate({
305
+ field: 'Origin',
306
+ oneOf: ('Japan', 'Europe')
307
+ })
309
308
"""
310
309
311
310
def __new__ ( # type: ignore[misc]
@@ -320,60 +319,52 @@ def one_of(
320
319
/ ,
321
320
* values : OneOfType | Sequence [OneOfType ],
322
321
timeUnit : TimeUnitType = Undefined ,
323
- ) -> SelectionPredicateComposition :
322
+ ) -> Predicate :
324
323
seq = _one_of_flatten (values )
325
324
one_of = _one_of_variance (* seq )
326
- p = FieldOneOfPredicate (field = field , oneOf = one_of , timeUnit = timeUnit )
327
- return _wrap_composition (p )
325
+ return FieldOneOfPredicate (field = field , oneOf = one_of , timeUnit = timeUnit )
328
326
329
327
@classmethod
330
328
def eq (
331
329
cls , field : str , value : ValueType , / , * , timeUnit : TimeUnitType = Undefined
332
- ) -> SelectionPredicateComposition :
333
- p = FieldEqualPredicate (field = field , equal = value , timeUnit = timeUnit )
334
- return _wrap_composition (p )
330
+ ) -> Predicate :
331
+ return FieldEqualPredicate (field = field , equal = value , timeUnit = timeUnit )
335
332
336
333
@classmethod
337
334
def lt (
338
335
cls , field : str , value : ValueType , / , * , timeUnit : TimeUnitType = Undefined
339
- ) -> SelectionPredicateComposition :
340
- p = FieldLTPredicate (field = field , lt = value , timeUnit = timeUnit )
341
- return _wrap_composition (p )
336
+ ) -> Predicate :
337
+ return FieldLTPredicate (field = field , lt = value , timeUnit = timeUnit )
342
338
343
339
@classmethod
344
340
def lte (
345
341
cls , field : str , value : ValueType , / , * , timeUnit : TimeUnitType = Undefined
346
- ) -> SelectionPredicateComposition :
347
- p = FieldLTEPredicate (field = field , lte = value , timeUnit = timeUnit )
348
- return _wrap_composition (p )
342
+ ) -> Predicate :
343
+ return FieldLTEPredicate (field = field , lte = value , timeUnit = timeUnit )
349
344
350
345
@classmethod
351
346
def gt (
352
347
cls , field : str , value : ValueType , / , * , timeUnit : TimeUnitType = Undefined
353
- ) -> SelectionPredicateComposition :
354
- p = FieldGTPredicate (field = field , gt = value , timeUnit = timeUnit )
355
- return _wrap_composition (p )
348
+ ) -> Predicate :
349
+ return FieldGTPredicate (field = field , gt = value , timeUnit = timeUnit )
356
350
357
351
@classmethod
358
352
def gte (
359
353
cls , field : str , value : ValueType , / , * , timeUnit : TimeUnitType = Undefined
360
- ) -> SelectionPredicateComposition :
361
- p = FieldGTEPredicate (field = field , gte = value , timeUnit = timeUnit )
362
- return _wrap_composition (p )
354
+ ) -> Predicate :
355
+ return FieldGTEPredicate (field = field , gte = value , timeUnit = timeUnit )
363
356
364
357
@classmethod
365
358
def valid (
366
359
cls , field : str , value : bool , / , * , timeUnit : TimeUnitType = Undefined
367
- ) -> SelectionPredicateComposition :
368
- p = FieldValidPredicate (field = field , valid = value , timeUnit = timeUnit )
369
- return _wrap_composition (p )
360
+ ) -> Predicate :
361
+ return FieldValidPredicate (field = field , valid = value , timeUnit = timeUnit )
370
362
371
363
@classmethod
372
364
def range (
373
365
cls , field : str , value : RangeType , / , * , timeUnit : TimeUnitType = Undefined
374
- ) -> SelectionPredicateComposition :
375
- p = FieldRangePredicate (field = field , range = value , timeUnit = timeUnit )
376
- return _wrap_composition (p )
366
+ ) -> Predicate :
367
+ return FieldRangePredicate (field = field , range = value , timeUnit = timeUnit )
377
368
378
369
379
370
# NOTE: Ignore everything below #
0 commit comments