Skip to content

Commit

Permalink
Make compatible with numpy 2.0 (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Jun 26, 2024
1 parent 2817d62 commit 230df0a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Unreleased
* Support classical transforms and predicates, and QASM registers, with up to 64
bits. Add an attribute to the pytket module to assert this.
* Add `PauliSynthStrat.Greedy` strategy to `TermSequenceBox`.
* Update version requirements on dependencies, removing all upper bounds (in
particular allowing compatibility with numpy 2.0).

1.29.2 (June 2024)
------------------
Expand Down
2 changes: 1 addition & 1 deletion pytket/pytket/utils/outcomearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def to_intlist(self, big_endian: bool = True) -> List[int]:
array = OutcomeArray.from_readouts(np.fliplr(self.to_readouts()))
bitcapacity = array.shape[-1] * 8
intify = lambda bytear: reduce(
operator.or_, (num << (8 * i) for i, num in enumerate(bytear[::-1])), 0
operator.or_, (int(num) << (8 * i) for i, num in enumerate(bytear[::-1])), 0
) >> (bitcapacity - array.width)
intar = np.apply_along_axis(intify, -1, array)
return list(intar)
Expand Down
23 changes: 12 additions & 11 deletions pytket/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,22 @@ def finalize_options(self):
license="Apache 2",
packages=setuptools.find_packages() + ["pytket.qasm.includes"],
install_requires=[
"sympy ~=1.6",
"numpy >=1.21.4, <2.0",
"lark ~=1.1",
"scipy ~=1.13",
"sympy >= 1.12.1",
"numpy >= 1.26.4",
"lark >= 1.1.9",
"scipy >= 1.13.1",
"networkx >= 2.8.8",
"graphviz ~= 0.14",
"jinja2 ~= 3.0",
"types-pkg_resources",
"typing-extensions ~= 4.2",
"qwasm ~= 1.0",
"graphviz >= 0.20.3",
"jinja2 >= 3.1.4",
"types-pkg_resources >= 0.1.3",
"typing-extensions >= 4.12.2",
"qwasm >= 1.0.1",
],
extras_require={
"ZX": [
"quimb ~= 1.8",
"autoray >= 0.6.1",
"numba >= 0.60.0",
"quimb >= 1.8.2",
"autoray >= 0.6.12",
],
},
ext_modules=[
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/assertion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_assertion_init() -> None:

def test_assertion() -> None:
# P =|00><00| tensor I + |111><111|
P = np.zeros((8, 8), dtype=np.complex_)
P = np.zeros((8, 8), dtype=np.complex128)
P[0, 0] = 1
P[1, 1] = 1
P[7, 7] = 1
Expand Down
2 changes: 1 addition & 1 deletion pytket/tests/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def test_exp_to_circ() -> None:
u = (
np.asarray(
[[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]],
dtype=np.complex_,
dtype=np.complex128,
)
* -PI
/ 4
Expand Down

0 comments on commit 230df0a

Please sign in to comment.