Bases: Function
Implementation of logical negation (~).
This class represents a logical NOT operation that can be performed on
on a single arguments. It supports chaining of multiple NOT 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 the number of args is not equal to one.
|
Examples:
>>> a = Not(Label.key == "k1")
>>> b = ~a
Methods:
Name |
Description |
__invert__ |
Supports chaining of multiple Not operations using the ~ operator.
|
Source code in valor/schemas/symbolic/operators.py
| class Not(Function):
"""Implementation of logical negation (~).
This class represents a logical NOT operation that can be performed on
on a single arguments. It supports chaining of multiple NOT operations
using the `~` operator.
Parameters
----------
*args : Any
The arguments to be logically ORed together. At least two arguments
are required.
Raises
------
ValueError
If the number of args is not equal to one.
Examples
--------
>>> a = Not(Label.key == "k1")
>>> b = ~a
Methods
-------
__invert__()
Supports chaining of multiple `Not` operations using the `~` operator.
"""
def __init__(self, *args):
if len(args) != 1:
raise ValueError("Negation only takes one argument.")
elif isinstance(args[0], Not):
return args[0]._args
super().__init__(*args)
def __invert__(self):
"""Inverts negation so return contents."""
if isinstance(self._args, list):
raise ValueError("Negation only takes one argument.")
return self._args
|
Functions
valor.schemas.Not.__invert__()
Inverts negation so return contents.
Source code in valor/schemas/symbolic/operators.py
| def __invert__(self):
"""Inverts negation so return contents."""
if isinstance(self._args, list):
raise ValueError("Negation only takes one argument.")
return self._args
|