Bases: Function
Implementation of logical OR (|).
This class represents a logical OR operation that can be performed on
two or more arguments. It supports chaining of multiple OR operations
using the |
operator.
Parameters:
Name |
Type |
Description |
Default |
*args
|
Any
|
The arguments to be logically ORed together. At least two arguments
are required.
|
()
|
Raises:
Type |
Description |
ValueError
|
If fewer than two arguments are provided.
|
Examples:
>>> a = Or(Label.key == "k1", Label.key == "k2")
>>> b = Or(Label.value == "v1", Label.value == "v2")
>>> c = a | b
Methods:
Name |
Description |
__or__ |
Supports chaining of multiple Or operations using the | operator.
|
Source code in valor/schemas/symbolic/operators.py
| class Or(Function):
"""Implementation of logical OR (|).
This class represents a logical OR operation that can be performed on
two or more arguments. It supports chaining of multiple OR operations
using the `|` operator.
Parameters
----------
*args : Any
The arguments to be logically ORed together. At least two arguments
are required.
Raises
------
ValueError
If fewer than two arguments are provided.
Examples
--------
>>> a = Or(Label.key == "k1", Label.key == "k2")
>>> b = Or(Label.value == "v1", Label.value == "v2")
>>> c = a | b
Methods
-------
__or__(other)
Supports chaining of multiple `Or` operations using the `|` operator.
"""
def __init__(self, *args):
if len(args) < 2:
raise ValueError("Expected at least two arguments.")
super().__init__(*args)
def __or__(self, other: Any):
if isinstance(other, Or):
self._args.extend(other._args)
else:
self._args.append(other)
return self
|