Core
Ordering
Bases: Enum
Represents ordering.
Source code in orderings/core.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
LESS = -1
class-attribute
instance-attribute
The left item is less than the right item.
EQUAL = 0
class-attribute
instance-attribute
The left item is equal to the right item.
GREATER = 1
class-attribute
instance-attribute
The left item is greater than the right item.
is_less() -> bool
Checks if the ordering is LESS
.
Returns:
Type | Description |
---|---|
bool
|
Whether the ordering is |
Source code in orderings/core.py
24 25 26 27 28 29 30 |
|
is_equal() -> bool
Checks if the ordering is EQUAL
.
Returns:
Type | Description |
---|---|
bool
|
Whether the ordering is |
Source code in orderings/core.py
32 33 34 35 36 37 38 |
|
is_greater() -> bool
Checks if the ordering is GREATER
.
Returns:
Type | Description |
---|---|
bool
|
Whether the ordering is |
Source code in orderings/core.py
40 41 42 43 44 45 46 |
|
is_less_or_equal() -> bool
Checks if the ordering is LESS
or
EQUAL
.
This is equivalent to:
ordering.is_less() or ordering.is_equal()
Returns:
Type | Description |
---|---|
bool
|
Source code in orderings/core.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
is_not_equal() -> bool
Checks if the ordering is not EQUAL
.
This is equivalent to:
not ordering.is_equal()
Returns:
Type | Description |
---|---|
bool
|
Whether the ordering is not |
Source code in orderings/core.py
63 64 65 66 67 68 69 70 71 72 73 74 |
|
is_greater_or_equal() -> bool
Checks if the ordering is GREATER
or
EQUAL
.
This is equivalent to:
ordering.is_greater() or ordering.is_equal()
Returns:
Type | Description |
---|---|
bool
|
Source code in orderings/core.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
PartialCompare
Bases: PartialOrdered[T]
, Protocol[T]
Implements partial ordering via delegation to the
partial_compare
method.
Note
Please note that this protocol does not implement equality methods.
Source code in orderings/core.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
partial_compare(value: T) -> Ordering
Defines partial ordering via the Ordering
enumeration.
Source code in orderings/core.py
104 105 106 107 |
|
Compare
Implements total ordering via delegation to the
compare
method.
Source code in orderings/core.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
compare(other: Self) -> Ordering
Defines ordering via the Ordering
enumeration.
Source code in orderings/core.py
128 129 130 131 |
|
is_compare(item: Any) -> TypeIs[Compare]
Checks if the item
implements the Compare
protocol.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Any
|
The item to check. |
required |
Returns:
Type | Description |
---|---|
TypeIs[Compare]
|
Whether the |
Source code in orderings/core.py
152 153 154 155 156 157 158 159 160 161 |
|
compare(left: PartialOrdered[T], right: T) -> Ordering
Compares left
and right
, returning Ordering
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
left |
PartialOrdered[T]
|
The left value. |
required |
right |
T
|
The right value. |
required |
Returns:
Type | Description |
---|---|
Ordering
|
The result. |
Source code in orderings/core.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|