Skip to content

Commit

Permalink
feat: explicitly implement the dtype on numpy quantities (#1922)
Browse files Browse the repository at this point in the history
  • Loading branch information
keewis authored Jan 20, 2024
1 parent 666517d commit b50ddc5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pint/facets/numpy/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ def flat(self):
def shape(self) -> Shape:
return self._magnitude.shape

@property
def dtype(self):
return self._magnitude.dtype

@shape.setter
def shape(self, value):
self._magnitude.shape = value
Expand Down
5 changes: 5 additions & 0 deletions pint/testsuite/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,11 @@ def test_shape(self):
u.shape = 4, 3
assert u.magnitude.shape == (4, 3)

def test_dtype(self):
u = self.Q_(np.arange(12, dtype="uint32"))

assert u.dtype == "uint32"

@helpers.requires_array_function_protocol()
def test_shape_numpy_func(self):
assert np.shape(self.q) == (2, 2)
Expand Down

0 comments on commit b50ddc5

Please sign in to comment.