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.

@@ -0,0 +1,9 @@
1
+ ## NEXT
2
+
3
+ ## v0.2.0
4
+
5
+ - Rename `_types` submodule to `abstract`
6
+
7
+ ## v0.1.0
8
+
9
+ - Hello world!
@@ -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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oprattr
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Add your description here
5
5
  Author-email: Matthew Young <myoung.space.science@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oprattr"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -6,7 +6,7 @@ import numpy
6
6
 
7
7
  from . import mixins
8
8
  from . import operators
9
- from . import _types
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(_types.Object[T], mixins.Numpy):
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):
@@ -1,7 +1,7 @@
1
1
  import typing
2
2
 
3
3
  from . import operators
4
- from ._types import Object
4
+ from .abstract import Object
5
5
 
6
6
 
7
7
  class MetadataError(TypeError):
@@ -3,12 +3,85 @@ import typing
3
3
 
4
4
  import numpy
5
5
 
6
- from . import _types
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
- _types.Object,
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, _types.Object)
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
- _types.Object,
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, _types.Object):
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, _types.Object)
343
+ if not issubclass(ti, abstract.Object)
271
344
  )
272
345
 
273
346
  @classmethod
@@ -1,6 +1,6 @@
1
1
  """
2
2
  This script generates and echos exceptions related to operations on instances of
3
- the `Object` class. It is meant as a supplement to rigorous tests.
3
+ the `Operand` class. It is meant as a supplement to rigorous tests.
4
4
  """
5
5
 
6
6
  import oprattr
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes