oprattr 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of oprattr might be problematic. Click here for more details.
- oprattr-0.2.0/CHANGELOG.md +9 -0
- oprattr-0.2.0/DEVELOPERS.md +16 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/PKG-INFO +1 -1
- {oprattr-0.1.0 → oprattr-0.2.0}/pyproject.toml +1 -1
- {oprattr-0.1.0 → oprattr-0.2.0}/src/oprattr/__init__.py +2 -2
- {oprattr-0.1.0 → oprattr-0.2.0}/src/oprattr/_operations.py +1 -1
- {oprattr-0.1.0 → oprattr-0.2.0}/src/oprattr/mixins.py +79 -6
- {oprattr-0.1.0 → oprattr-0.2.0}/tests/print-exceptions.py +1 -1
- {oprattr-0.1.0 → oprattr-0.2.0}/.gitignore +0 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/.python-version +0 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/README.md +0 -0
- /oprattr-0.1.0/src/oprattr/_types.py → /oprattr-0.2.0/src/oprattr/abstract.py +0 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/src/oprattr/operators.py +0 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/src/oprattr/py.typed +0 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/tests/test_object.py +0 -0
- {oprattr-0.1.0 → oprattr-0.2.0}/uv.lock +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Developer Notes
|
|
2
|
+
|
|
3
|
+
This document contains notes for those who wish to contribute to `oprattr` by modifying the code base. In order to develop `oprattr`, you should fork the respository, edit your forked copy, and submit a pull request for integration with the original repository.
|
|
4
|
+
|
|
5
|
+
Note that this is a living document and is subject to change without notice.
|
|
6
|
+
|
|
7
|
+
## Version Numbers
|
|
8
|
+
|
|
9
|
+
When incrementing the version number to X.Y.Z, please do the following
|
|
10
|
+
* create a new subsection in `CHANGELOG.md`, below **NEXT**, with the title
|
|
11
|
+
formatted as vX.Y.Z (YYYY-MM-DD)
|
|
12
|
+
* update the version number in `pyproject.toml`
|
|
13
|
+
* commit with the message "Increment version to X.Y.Z"
|
|
14
|
+
* create a tag named "vX.Y.Z" with the message "version X.Y.Z"
|
|
15
|
+
* push and follow tags
|
|
16
|
+
|
|
@@ -6,7 +6,7 @@ import numpy
|
|
|
6
6
|
|
|
7
7
|
from . import mixins
|
|
8
8
|
from . import operators
|
|
9
|
-
from . import
|
|
9
|
+
from . import abstract
|
|
10
10
|
from ._operations import (
|
|
11
11
|
unary,
|
|
12
12
|
equality,
|
|
@@ -19,7 +19,7 @@ from ._operations import (
|
|
|
19
19
|
T = typing.TypeVar('T')
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class Operand(
|
|
22
|
+
class Operand(abstract.Object[T], mixins.Numpy):
|
|
23
23
|
"""A concrete implementation of a real-valued object."""
|
|
24
24
|
|
|
25
25
|
def __abs__(self):
|
|
@@ -3,12 +3,85 @@ import typing
|
|
|
3
3
|
|
|
4
4
|
import numpy
|
|
5
5
|
|
|
6
|
-
from . import
|
|
6
|
+
from . import abstract
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
T = typing.TypeVar('T')
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
class Real:
|
|
13
|
+
"""Mixin for adding basic real-valued operator support."""
|
|
14
|
+
|
|
15
|
+
def __abs__(self):
|
|
16
|
+
return self
|
|
17
|
+
|
|
18
|
+
def __pos__(self):
|
|
19
|
+
return self
|
|
20
|
+
|
|
21
|
+
def __neg__(self):
|
|
22
|
+
return self
|
|
23
|
+
|
|
24
|
+
def __eq__(self, other):
|
|
25
|
+
return False
|
|
26
|
+
|
|
27
|
+
def __ne__(self, other):
|
|
28
|
+
return not (self == other)
|
|
29
|
+
|
|
30
|
+
def __lt__(self, other):
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
def __le__(self, other):
|
|
34
|
+
return (self < other) and (self == other)
|
|
35
|
+
|
|
36
|
+
def __gt__(self, other):
|
|
37
|
+
return not (self <= other)
|
|
38
|
+
|
|
39
|
+
def __ge__(self, other):
|
|
40
|
+
return not (self < other)
|
|
41
|
+
|
|
42
|
+
def __add__(self, other):
|
|
43
|
+
return self
|
|
44
|
+
|
|
45
|
+
def __radd__(self, other):
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
def __sub__(self, other):
|
|
49
|
+
return self
|
|
50
|
+
|
|
51
|
+
def __rsub__(self, other):
|
|
52
|
+
return self
|
|
53
|
+
|
|
54
|
+
def __mul__(self, other):
|
|
55
|
+
return self
|
|
56
|
+
|
|
57
|
+
def __rmul__(self, other):
|
|
58
|
+
return self
|
|
59
|
+
|
|
60
|
+
def __truediv__(self, other):
|
|
61
|
+
return self
|
|
62
|
+
|
|
63
|
+
def __rtruediv__(self, other):
|
|
64
|
+
return self
|
|
65
|
+
|
|
66
|
+
def __floordiv__(self, other):
|
|
67
|
+
return self
|
|
68
|
+
|
|
69
|
+
def __rfloordiv__(self, other):
|
|
70
|
+
return self
|
|
71
|
+
|
|
72
|
+
def __mod__(self, other):
|
|
73
|
+
return self
|
|
74
|
+
|
|
75
|
+
def __rmod__(self, other):
|
|
76
|
+
return self
|
|
77
|
+
|
|
78
|
+
def __pow__(self, other):
|
|
79
|
+
return self
|
|
80
|
+
|
|
81
|
+
def __rpow__(self, other):
|
|
82
|
+
return self
|
|
83
|
+
|
|
84
|
+
|
|
12
85
|
UserFunction = typing.Callable[..., T]
|
|
13
86
|
|
|
14
87
|
|
|
@@ -54,7 +127,7 @@ class Numpy:
|
|
|
54
127
|
numpy.ndarray,
|
|
55
128
|
numbers.Number,
|
|
56
129
|
list,
|
|
57
|
-
|
|
130
|
+
abstract.Object,
|
|
58
131
|
}
|
|
59
132
|
|
|
60
133
|
def __array_ufunc__(self, ufunc, method, *args, **kwargs):
|
|
@@ -89,7 +162,7 @@ class Numpy:
|
|
|
89
162
|
return NotImplemented
|
|
90
163
|
if out:
|
|
91
164
|
kwargs['out'] = tuple(
|
|
92
|
-
x._data if isinstance(x,
|
|
165
|
+
x._data if isinstance(x, abstract.Object)
|
|
93
166
|
else x for x in out
|
|
94
167
|
)
|
|
95
168
|
if self._implements(ufunc):
|
|
@@ -134,7 +207,7 @@ class Numpy:
|
|
|
134
207
|
|
|
135
208
|
_FUNCTION_TYPES = {
|
|
136
209
|
numpy.ndarray,
|
|
137
|
-
|
|
210
|
+
abstract.Object,
|
|
138
211
|
} | set(numpy.ScalarType)
|
|
139
212
|
|
|
140
213
|
def __array_function__(self, func, types, args, kwargs):
|
|
@@ -251,7 +324,7 @@ class Numpy:
|
|
|
251
324
|
`arg` if `arg` is an instance of the base object class; otherwise, it
|
|
252
325
|
will return the unmodified argument.
|
|
253
326
|
"""
|
|
254
|
-
if isinstance(arg,
|
|
327
|
+
if isinstance(arg, abstract.Object):
|
|
255
328
|
return arg._data
|
|
256
329
|
return arg
|
|
257
330
|
|
|
@@ -267,7 +340,7 @@ class Numpy:
|
|
|
267
340
|
"""
|
|
268
341
|
return tuple(
|
|
269
342
|
ti for ti in types
|
|
270
|
-
if not issubclass(ti,
|
|
343
|
+
if not issubclass(ti, abstract.Object)
|
|
271
344
|
)
|
|
272
345
|
|
|
273
346
|
@classmethod
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|