Skip to content

Commit

Permalink
Merge pull request #18 from quantumlib/numpy-version
Browse files Browse the repository at this point in the history
Make __array__ safe for numpy < 2
  • Loading branch information
NoureldinYosri authored Nov 11, 2024
2 parents ec72ad5 + 7813245 commit a3c5d2a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ jobs:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true

- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true
2 changes: 0 additions & 2 deletions .github/workflows/stable-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ jobs:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true

- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
verbose: true
3 changes: 2 additions & 1 deletion tunits/core/cython/with_unit_value_array.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ class ValueArray(WithUnit):

def __array__(WithUnit self, dtype=None, copy: bool=False):
if self.is_dimensionless:
# TODO: pass copy to np.asarray.
return np.asarray(conversion_to_double(self.conv) * self.value,
dtype=dtype, copy=copy)
dtype=dtype)

unit_array = np.full_like(self.value, self.unit, dtype=object)
result = self.value * unit_array
Expand Down

0 comments on commit a3c5d2a

Please sign in to comment.