Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cython 3 #1143

Merged
merged 13 commits into from
Sep 1, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/oldest-test-reqs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ase==3.16.0
cmake==3.13.0
cython==0.29.14
cython==3.0.2
dynasor==1.1b0; platform_system != "Windows"
gsd==2.4.2
matplotlib==3.0.0
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to
### Added
* The `gsd.hoomd.Frame` class is supported as a system-like input.

### Changed
* Require building with cython>=3.0.2

## v2.13.0 -- 2023-05-09

### Added
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ def list_benchmark_modules():
"""
import glob

modules = glob.glob(os.path.join(os.path.dirname(__file__), "benchmark_*"))
prefixdir = "benchmarks/"
modules = [f[len(prefixdir) : -3] for f in modules]
dir_path = os.path.dirname(__file__)
modules = glob.glob(os.path.join(dir_path, "benchmark_*"))
modules = [f[len(dir_path) + 1 : -3] for f in modules]
return modules


Expand Down
3 changes: 2 additions & 1 deletion benchmarks/reports/benchmark.json
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,6 @@
]
]
}
]
],
"5ddf603fa828b2130199b90d39fe4cb02072007c": []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The benchmarking script records the SHA of the commit it was run on and the results. I cut the benchmarking script off before it got all the way done so it couldn't record all the results at the end. I can manually revert this change if necessary.

}
1 change: 1 addition & 0 deletions doc/source/reference/credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ Tommy Waltmann
* Contributed code, design, documentation, and testing for ``freud.locality.FilterRAD`` class.
* Fixed segfault in neighborlists owned by compute objects.
* Added support for ``gsd.hoomd.Frame`` in ``NeighborQuery.from_system`` calls.
* Added support for building with cython 3.0

Maya Martirossyan

Expand Down
13 changes: 4 additions & 9 deletions freud/box.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -718,15 +718,7 @@ cdef class Box:
pass
return NotImplemented

def __mul__(arg1, arg2):
# Note Cython treats __mul__ and __rmul__ as one operation, so
# type checks are necessary.
if isinstance(arg1, freud.box.Box):
self = arg1
scale = arg2
else:
scale = arg1
self = arg2
def __mul__(self, scale):
if scale > 0:
return self.__class__(Lx=self.Lx*scale,
Ly=self.Ly*scale,
Expand All @@ -736,6 +728,9 @@ cdef class Box:
else:
raise ValueError("Box can only be multiplied by positive values.")

def __rmul__(self, scale):
return self * scale

def plot(self, title=None, ax=None, image=[0, 0, 0], *args, **kwargs):
"""Plot a :class:`~.box.Box` object.

Expand Down
2 changes: 0 additions & 2 deletions freud/locality.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ cdef class NeighborQueryResult:
yield (npoint.query_point_idx, npoint.point_idx, npoint.distance)
npoint = dereference(iterator).next()

raise StopIteration

def toNeighborList(self, sort_by_distance=False):
"""Convert query result to a freud :class:`~NeighborList`.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools", "wheel", "oldest-supported-numpy", "cython>=0.29.14,<3.0.0", "scikit-build>=0.17.3", "cmake"]
requires = ["setuptools", "wheel", "oldest-supported-numpy", "cython>=3.0.2", "scikit-build>=0.17.3", "cmake"]

[tool.black]
target-version = ['py36']
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-test-compatible.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ase>=3.16.0
cmake>=3.13.0
coverage>=6.2
cython>=0.29.14, <3.0.0
cython>=3.0.2
dynasor>=1.1b0; platform_system != "Windows"
GitPython>=3.1.24
gsd>=2.4.2
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ase==3.22.1
cmake==3.27.0
coverage==7.2.7
cython==0.29.35
cython==3.0.2
dynasor==1.1.1; platform_system != "Windows"
GitPython==3.1.32
gsd==3.1.0
Expand Down