From 2579ed3bccc4c6356e154b5a155bf29bb0d65d93 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 29 Jun 2023 17:01:50 +0100 Subject: [PATCH 01/11] Move from setup.py to pyproject.toml. --- pyproject.toml | 36 ++++++++++++++++++++++++++++ setup.py | 27 --------------------- swiftsnap => swiftsimio/swiftsnap.py | 2 +- 3 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py rename swiftsnap => swiftsimio/swiftsnap.py (99%) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..335c239c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = ["swiftsimio"] + +[project] +name = "swiftsimio" +version="6.1.1" +authors = [ + { name="Josh Borrow", email="joshua.borrow@durham.ac.uk" }, +] +description="SWIFTsim (swift.dur.ac.uk) i/o routines for python." +readme = "README.md" +requires-python = ">3.8.0" +classifiers = [ + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Operating System :: OS Independent", +] +dependencies = [ + "numpy", + "h5py", + "unyt>=2.9.0", + "numba>=0.50.0", +] + +[project.urls] +"Homepage" = "https://github.com/SWIFTSIM/swiftsimio" +"Bug Tracker" = "https://github.com/SWIFTSIM/swiftsimio/issues" +"Documentation" = "https://swiftsimio.readthedocs.io/en/latest" + +[project.scripts] +swiftsnap = "swiftsimio.swiftsnap:swiftsnap" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 4a5109c9..00000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -import setuptools -from swiftsimio import __version__ - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="swiftsimio", - version=__version__, - description="SWIFTsim (swift.dur.ac.uk) i/o routines for python.", - url="https://github.com/swiftsim/swiftsimio", - author="Josh Borrow", - author_email="joshua.borrow@durham.ac.uk", - packages=setuptools.find_packages(), - long_description=long_description, - long_description_content_type="text/markdown", - zip_safe=False, - scripts=["swiftsnap"], - classifiers=[ - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", - "Operating System :: OS Independent", - ], - install_requires=["numpy", "unyt>=2.9.0", "h5py", "numba>=0.50.0"], - python_requires=">3.8.0", -) diff --git a/swiftsnap b/swiftsimio/swiftsnap.py similarity index 99% rename from swiftsnap rename to swiftsimio/swiftsnap.py index a0330d37..183fabfb 100755 --- a/swiftsnap +++ b/swiftsimio/swiftsnap.py @@ -60,7 +60,7 @@ def decode(bytestring: bytes) -> str: ), ) -if __name__ == "__main__": +def swiftsnap(): import swiftsimio as sw import unyt From 26cda329a39af02d1bcedf8333c7d6f70b7e96dc Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 29 Jun 2023 17:15:34 +0100 Subject: [PATCH 02/11] Get scripts, tests and formatting script working with pyproject.toml. --- format.sh | 2 +- pyproject.toml | 2 +- swiftsimio/swiftsnap.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/format.sh b/format.sh index a8da7e2e..67641a8c 100755 --- a/format.sh +++ b/format.sh @@ -20,7 +20,7 @@ fi black="./black_formatting_env/bin/python3 -m black" # Formatting command -files=$(echo {*.py,tests/*.py,swiftsimio/*.py,swiftsimio/*/*.py,swiftsimio/*/*/*.py}) +files=$(echo {tests/*.py,swiftsimio/*.py,swiftsimio/*/*.py,swiftsimio/*/*/*.py}) cmd="$black -t py38 $files" # Print the help diff --git a/pyproject.toml b/pyproject.toml index 335c239c..b629ae28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [tool.setuptools] -packages = ["swiftsimio"] +packages = ["swiftsimio", "tests"] [project] name = "swiftsimio" diff --git a/swiftsimio/swiftsnap.py b/swiftsimio/swiftsnap.py index 183fabfb..d2aeb3ba 100755 --- a/swiftsimio/swiftsnap.py +++ b/swiftsimio/swiftsnap.py @@ -60,6 +60,7 @@ def decode(bytestring: bytes) -> str: ), ) + def swiftsnap(): import swiftsimio as sw import unyt From 3393906c63a4e8dabd2bd8f6215b5f4c22181e1a Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 29 Jun 2023 17:50:11 +0100 Subject: [PATCH 03/11] . --- scripts/benchmark_visualisation.py | 79 ------- swiftsimio/optional_packages.py | 11 - swiftsimio/visualisation/sphviewer.py | 301 -------------------------- tests/test_sphviewer_integration.py | 58 ----- 4 files changed, 449 deletions(-) delete mode 100644 scripts/benchmark_visualisation.py delete mode 100644 swiftsimio/visualisation/sphviewer.py delete mode 100644 tests/test_sphviewer_integration.py diff --git a/scripts/benchmark_visualisation.py b/scripts/benchmark_visualisation.py deleted file mode 100644 index 95eb444f..00000000 --- a/scripts/benchmark_visualisation.py +++ /dev/null @@ -1,79 +0,0 @@ -""" -A short benchmarking script. As of 19th May 2019, -our visualisation takes approximately 21 seconds to -complete this task on a 2018 Macbook Pro with a -2.7 GhZ i7. -""" - -from swiftsimio.visualisation import scatter -from numpy import ones_like, array, float32, float64, zeros -from numpy.random import rand, seed -from time import time - -number_of_particles = 100_000 -res = 1024 - -seed(1234) - -print("Generating particles") -x = rand(number_of_particles).astype(float64) -y = rand(number_of_particles).astype(float64) -h = rand(number_of_particles).astype(float32) * 0.2 -m = ones_like(h) -print("Finished generating particles") - -print("Compiling") -t = time() -scatter( - array([0.0], dtype=float64), - array([0.0], dtype=float64), - array([1.0], dtype=float32), - array([0.01], dtype=float32), - 128, -) -print(f"Took {time() - t} to compile.") - -print("Scattering") -t = time() -image = scatter(x, y, m, h, res) -dt_us = time() - t -print(f"Took {dt_us} to scatter.") - -try: - from sphviewer.tools import QuickView - import os - - os.environ["MKL_NUM_THREADS"] = "1" - os.environ["NUMEXPR_NUM_THREADS"] = "1" - os.environ["OMP_NUM_THREADS"] = "1" - - print("Comparing with pySPHViewer") - coordinates = zeros((number_of_particles, 3)) - coordinates[:, 0] = x - coordinates[:, 1] = y - h = 1.778_002 * h # The kernel_gamma we use. - - t = time() - qv = QuickView( - coordinates, - hsml=h, - mass=m, - xsize=res, - ysize=res, - r="infinity", - plot=False, - logscale=False, - ).get_image() - dt_pysphviewer = time() - t - print(f"pySPHViewer took {dt_pysphviewer} on the same problem.") - print(f"Note that pySPHViewer is running in single-threaded mode.") - - ratio = dt_us / dt_pysphviewer - - if ratio < 1.0: - print(f"That makes us {1 / ratio} x faster 😀 ") - else: - print(f"That makes pySphviewer {ratio} x faster 😔") - -except: - print("pySPHViewer not available for comparison") diff --git a/swiftsimio/optional_packages.py b/swiftsimio/optional_packages.py index 479e2ea4..f3d98a28 100644 --- a/swiftsimio/optional_packages.py +++ b/swiftsimio/optional_packages.py @@ -5,7 +5,6 @@ + tqdm: progress bars + scipy.spatial: KDTrees -+ sphviewer: visualisation + numba/cuda: visualisation """ @@ -30,16 +29,6 @@ def tqdm(x, *args, **kwargs): TREE_AVAILABLE = False -# Py-sphviewer -try: - import sphviewer as viewer - - SPHVIEWER_AVAILABLE = True -except (ImportError, ModuleNotFoundError): - viewer = None - SPHVIEWER_AVAILABLE = False - - # Astropy try: import astropy diff --git a/swiftsimio/visualisation/sphviewer.py b/swiftsimio/visualisation/sphviewer.py deleted file mode 100644 index 21492228..00000000 --- a/swiftsimio/visualisation/sphviewer.py +++ /dev/null @@ -1,301 +0,0 @@ -""" -Py-SPHViewer integration for SWIFTsimIO. - -This allows you to hook directly into the Scene and QuickView objects, -and provides helpful wrappers around the functions in py-sphviewer. -""" - -import numpy as np - -from swiftsimio.reader import __SWIFTParticleDataset -from swiftsimio.objects import cosmo_array -from swiftsimio.optional_packages import TREE_AVAILABLE, SPHVIEWER_AVAILABLE, viewer -from unyt import unyt_array - -from typing import Union, List - -from .smoothing_length_generation import generate_smoothing_lengths - - -class SPHViewerWrapper(object): - """ - Wrapper for Py-SPHViewer to use SWIFTsimIO data structures. - """ - - # Forward declarations - # Internal smoothing lengths that are used in the case where we - # need to generate our own - _internal_smoothing_lengths = None - # Pixel grid output units - smooth_units = None - - def __init__( - self, - dataset, - smooth_over: Union[unyt_array, cosmo_array, str] = "masses", - hsml_name: Union[str, None] = "smoothing_lengths", - ): - """ - Initialise the Particles class of py-sphviewer. - - Parameters - ---------- - data : - the particle dataset to render (e.g. data.gas would render the gas) - hsml_name : str, optional - the name of the object that contains smoothing lengths. If this - is None, attempt to create smoothing lengths that encompass 32 - nearest neighbours. - smooth_over : str, optional - the name of the object to smooth over. Default to mass if not - provided. This can also be an arbritary unyt or cosmo array. - """ - - if not SPHVIEWER_AVAILABLE: - raise ImportError("Unable to find py-sphviewer on your system") - - self.data = dataset - - if isinstance(smooth_over, unyt_array) or isinstance(smooth_over, cosmo_array): - self.smooth_over = smooth_over - elif isinstance(smooth_over, str): - self.smooth_over = getattr(self.data, smooth_over) - else: - raise AttributeError( - "Invalid type {} passed to smooth_over parameter. " - "Only allowed classes are: str, unyt_array, cosmo_array.".format( - type(smooth_over) - ) - ) - - self.__set_smoothing_lengths(hsml_name) - self.__create_particles_instance() - - return - - def __set_smoothing_lengths(self, hsml_name: Union[str, None]): - """ - Internal function for setting smoothing lengths. - - Object containing smoothing length data may be provided. If omitted - smoothing lengths are generated using internal tree structure. - - Parameters - ---------- - hsml_name : str, optional - the name of the object that contains smoothing lengths. If this - is None, attempt to create smoothing lengths that encompass 32 - nearest neighbours. - """ - - # Parameters required to generate smoothing lengths - number_of_neighbours = int( - round(self.data.metadata.hydro_scheme["Kernel target N_ngb"][0]) - ) - kernel_eta = self.data.metadata.hydro_scheme["Kernel eta"][0] - - kernel_gamma = ((3.0 * number_of_neighbours) / (4.0 * 3.14159)) ** ( - 1 / 3 - ) / kernel_eta - - if hsml_name is None: - self._internal_smoothing_lengths = generate_smoothing_lengths( - self.data.coordinates, - boxsize=self.data.metadata.boxsize, - kernel_gamma=kernel_gamma, - ) - else: - try: - self._internal_smoothing_lengths = getattr(self.data, hsml_name) - except AttributeError: - self._internal_smoothing_lengths = generate_smoothing_lengths( - self.data.coordinates, - boxsize=self.data.metadata.boxsize, - kernel_gamma=kernel_gamma, - ) - - def __create_particles_instance(self): - """ - Internal function for creating the particles instance. - - Requires the smoothing lengths to be set first. - """ - - if self._internal_smoothing_lengths is None: - raise AssertionError( - "Property _internal_smoothing_lengths should have been set already." - "Please report to developers on GitHub." - ) - - if self._internal_smoothing_lengths.units != self.data.coordinates.units: - raise AssertionError( - "Smoothing lengths and coordinates are not provided in the same units! " - "To use py-sphviewer integration, please set these to being equal " - "by using .convert_to_units() on both arrays." - ) - else: - self.length_units = self.data.coordinates.units - - self.smooth_units = self.smooth_over.units / (self.length_units ** 2) - - self.particles = viewer.Particles( - pos=self.data.coordinates.value, - hsml=self._internal_smoothing_lengths.value, - mass=self.smooth_over.value, - ) - - return - - def get_autocamera(self): - """ - Sets a sensible value for the camera based on the camera's built in - properties. - """ - - self.camera = viewer.Camera() - self.camera.set_autocamera(self.particles) - - return self.camera - - def get_camera( - self, - x: Union[None, float] = None, - y: Union[None, float] = None, - z: Union[None, float] = None, - r: Union[None, float] = None, - t: Union[None, float] = None, - p: Union[None, float] = None, - zoom: Union[None, float] = None, - roll: Union[None, float] = None, - xsize: Union[None, int] = None, - ysize: Union[None, int] = None, - extent: Union[None, List[float]] = None, - ): - """ - Get the py-sphviewer camera object. - - See py-sphviewer for detailed documentation - - Parameters - ---------- - - x, y, z : float, optional - Cartesian co-ordinates of the object being viewed - r : float, optional - Cartesian distance to the object - t : float, optional - p : float, optional - zoom : float, optional - roll : float, optional - xsize, ysize : int, optional - output pixel size - extent : list of float, optional - Area to render between - - Notes - ----- - - This method also sets self.camera that is used later. - """ - - def convert_if_not_none(parameter): - # Convert our parameter to the length units of the rest of - # the data if it is not None or some non-standard choice. - if parameter is None: - return None - elif isinstance(parameter, str): - # This is the case if r="infinity" - return parameter - else: - return parameter.to(self.length_units).value - - self.camera = viewer.Camera( - x=convert_if_not_none(x), - y=convert_if_not_none(y), - z=convert_if_not_none(z), - r=convert_if_not_none(r), - t=t, - p=p, - zoom=zoom, - roll=roll, - xsize=xsize, - ysize=ysize, - extent=extent, - ) - - return self.camera - - def get_scene(self, camera: Union["viewer.Camera", None] = None): - """ - Get the scene for a given camera. - - If there is no camera provided, we use the internal self.camera. - If this is not set, then we raise an AttributeError. - - Parameters - ---------- - - camera : viewer.Camera, optional - Camera object used to render scene - """ - - if camera is not None: - self.scene = viewer.Scene(self.particles, camera) - elif self.camera is not None: - self.scene = viewer.Scene(self.particles, self.camera) - else: - raise AttributeError( - "You must make a choice for the camera, either by calling " - ".get_camera() or by defining your own py-sphviewer camera " - "and passing it to the get_scene function." - ) - - return self.scene - - def get_render(self): - """ - Returns the render object and sets self.render using the internal - scene object. - - Notes - ----- - - self.image and self.extent are also provided as values that represent the render's - image and extent including the input units. - """ - - self.render = viewer.Render(self.scene) - - self.image = self.render.get_image() * self.smooth_units - self.extent = self.render.get_extent() * self.length_units - - return self.render - - def quick_view( - self, xsize: int, ysize: int, r: Union[None, float] = None, **kwargs - ): - """ - Simple render of a scene with auto camera setting - - Analogous to sphviewer.tools.QuickView but easier to directly call. - - Parameters - ---------- - - xsize, ysize : int - camera size in pixels - - r : float, optional - distance to image centre - - Notes - ----- - All of the quantities are presented on a linear scale. - """ - - self.get_autocamera() - self.camera.set_params(xsize=xsize, ysize=ysize, r=r, **kwargs) - - self.get_scene() - - return self.get_render() diff --git a/tests/test_sphviewer_integration.py b/tests/test_sphviewer_integration.py deleted file mode 100644 index 4940193c..00000000 --- a/tests/test_sphviewer_integration.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -Uses test data to test the py-sphviewer integration. -""" - -from tests.helper import requires -from swiftsimio import load, mask -from swiftsimio.visualisation.sphviewer import SPHViewerWrapper -from swiftsimio.optional_packages import SPHVIEWER_AVAILABLE - -from unyt import unyt_array as array - -create_plots = False - -try: - import matplotlib.pyplot as plt - from matplotlib.colors import LogNorm -except (ImportError, ModuleNotFoundError): - create_plots = False - pass - - -@requires("cosmological_volume.hdf5") -def test_gas_rendering(filename, create_plots=create_plots): - if not SPHVIEWER_AVAILABLE: - return - - data = load(filename) - - data.gas.coordinates.convert_to_units("Mpc") - data.gas.smoothing_lengths.convert_to_units("Mpc") - - wrap = SPHViewerWrapper(data.gas) - - wrap.quick_view(xsize=512, ysize=512, r="infinity") - - if create_plots: - plt.imshow(wrap.image.value, extent=wrap.extent.value, origin="lower") - - plt.savefig("test_pysphviewer_integration.png") - - -@requires("cosmological_volume.hdf5") -def test_dm_rendering(filename, create_plots=create_plots): - if not SPHVIEWER_AVAILABLE: - return - - data = load(filename) - - data.dark_matter.coordinates.convert_to_units("Mpc") - - wrap = SPHViewerWrapper(data.dark_matter) - - wrap.quick_view(xsize=512, ysize=512, r="infinity") - - if create_plots: - plt.imshow(wrap.image.value, extent=wrap.extent.value, origin="lower") - - plt.savefig("test_pysphviewer_integration.png") From 05bf5f3cba60617f9a64618eefb0287e5de49077 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 29 Jun 2023 17:56:11 +0100 Subject: [PATCH 04/11] Remove pysphviewer from optional requirements. --- optional_requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/optional_requirements.txt b/optional_requirements.txt index ed8e62b8..0aa6ee8b 100644 --- a/optional_requirements.txt +++ b/optional_requirements.txt @@ -2,7 +2,6 @@ numba pytest black -py-sphviewer matplotlib scipy wily From 3931e18d12c832f41f6ecddb63c2b9cde110d790 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Fri, 30 Jun 2023 11:54:31 +0100 Subject: [PATCH 05/11] Avoid installing tests module. --- pyproject.toml | 2 +- tests/__init__.py | 0 tests/test_accelerated.py | 2 +- tests/test_helper.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 tests/__init__.py diff --git a/pyproject.toml b/pyproject.toml index b629ae28..335c239c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [tool.setuptools] -packages = ["swiftsimio", "tests"] +packages = ["swiftsimio"] [project] name = "swiftsimio" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_accelerated.py b/tests/test_accelerated.py index 07222f91..a443eb5e 100644 --- a/tests/test_accelerated.py +++ b/tests/test_accelerated.py @@ -12,7 +12,7 @@ import numpy as np import h5py -from helper import create_in_memory_hdf5 +from .helper import create_in_memory_hdf5 def test_ranges_from_array(): diff --git a/tests/test_helper.py b/tests/test_helper.py index b4737dab..bc71cd62 100644 --- a/tests/test_helper.py +++ b/tests/test_helper.py @@ -2,7 +2,7 @@ Tests the helper functions if necessary. """ -from helper import create_in_memory_hdf5 +from .helper import create_in_memory_hdf5 def test_create_in_memory_hdf5(): From 79572c5b1c172afc191b4015e2a6be0a14a73874 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Fri, 30 Jun 2023 12:05:45 +0100 Subject: [PATCH 06/11] Remove pysphviewer from docs. --- docs/source/getting_started/index.rst | 2 -- docs/source/visualisation/index.rst | 3 -- docs/source/visualisation/py-sphviewer.rst | 40 ---------------------- 3 files changed, 45 deletions(-) delete mode 100644 docs/source/visualisation/py-sphviewer.rst diff --git a/docs/source/getting_started/index.rst b/docs/source/getting_started/index.rst index e7950f3f..9715fdaa 100644 --- a/docs/source/getting_started/index.rst +++ b/docs/source/getting_started/index.rst @@ -38,8 +38,6 @@ Optional packages that do not store this variable in the snapshots (e.g. dark matter) + ``tqdm``, required for progress bars for some long-running tasks. If not installed no progress bar will be shown. -+ ``py-sphviewer``, if you wish to use our integration with this visualisation - code. Installing diff --git a/docs/source/visualisation/index.rst b/docs/source/visualisation/index.rst index c760fa48..e2edcda9 100644 --- a/docs/source/visualisation/index.rst +++ b/docs/source/visualisation/index.rst @@ -24,8 +24,6 @@ The output of these functions comes with associated units and has the correct dimensions. There are lower-level APIs (also documented here) that provide additional functionality. -Finally, we also describe here the integration with :mod:`py-sphviewer`. - .. toctree:: :maxdepth: 2 @@ -33,5 +31,4 @@ Finally, we also describe here the integration with :mod:`py-sphviewer`. slice volume_render tools - py-sphviewer diff --git a/docs/source/visualisation/py-sphviewer.rst b/docs/source/visualisation/py-sphviewer.rst deleted file mode 100644 index 1f0f1d03..00000000 --- a/docs/source/visualisation/py-sphviewer.rst +++ /dev/null @@ -1,40 +0,0 @@ -Py-SPHViewer Integration -======================== - -We provide a wrapper of the ever-popular py-sphviewer_ for easy use with -:mod:`swiftsimio` datasets. Particle datasets that do not contain smoothing -lengths will have them generated through the use of the scipy ``cKDTree``. -You can get access to the objects through a sub-module as follows: - -.. code-block:: python - - from swiftsimio import load - from swiftsimio.visualisation.sphviewer import SPHViewerWrapper - import matplotlib.pyplot as plt - - data = load("cosmo_volume_example.hdf5") - - resolution = 2048 - - gas = SPHViewerWrapper(data.gas, smooth_over="masses") - gas_temp = SPHViewerWrapper( - data.gas, - smooth_over=data.gas.masses * data.gas.temperatures - ) - dark_matter = SPHViewerWrapper(data.dark_matter, smooth_over="masses") - - gas.quick_view(xsize=resolution, ysize=resolution, r="infinity") - gas_temp.quick_view(xsize=resolution, ysize=resolution, r="infinity") - dark_matter.quick_view(xsize=resolution, ysize=resolution, r="infinity") - - plt.imsave("gas_image.png", gas.image) - plt.imsave("gas_temp.png", gas_temp.image / gas.image) - plt.imsave("dm_image.png", dark_matter.image) - - -The :obj:`swiftsimio.visualisation.sphviewer.SPHViewerWrapper` object allows you -to get access to the particles, camera, and render object through ``.particles``, -``.get_camera()`` and ``.camera``, and ``.get_render()`` and ``.render`` -respectively. - -.. _py-sphviewer: https://github.com/alejandrobll/py-sphviewer \ No newline at end of file From dd5f8e497ea106337ac15c82352e9c8b245be7f9 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Fri, 30 Jun 2023 12:16:22 +0100 Subject: [PATCH 07/11] Ensure swiftsnap script runs as script if run with python. --- swiftsimio/swiftsnap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swiftsimio/swiftsnap.py b/swiftsimio/swiftsnap.py index d2aeb3ba..4d1a9de3 100755 --- a/swiftsimio/swiftsnap.py +++ b/swiftsimio/swiftsnap.py @@ -190,3 +190,7 @@ def swiftsnap(): for name, scheme in data.subgrid_scheme.items(): if name != "NamedColumns": print(f"{name.replace('Model', 'model')}: {decode(scheme)}") + + +if __name__ == "__main__": + swiftsnap() From 0363346d69be2e949a054851237fc938aa700a5e Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 6 Jul 2023 16:16:24 +0100 Subject: [PATCH 08/11] Adjust supported versions and dependencies. --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 335c239c..da53b807 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,13 +17,15 @@ requires-python = ">3.8.0" classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", "Operating System :: OS Independent", ] dependencies = [ "numpy", "h5py", - "unyt>=2.9.0", + "unyt>=3.0.0", "numba>=0.50.0", ] From c51ba4811c25248d869df68fc954bcb326c25c63 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 6 Jul 2023 16:16:38 +0100 Subject: [PATCH 09/11] Exclude some temporary filename patterns in gitignore. --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 5ea03cf9..ae215674 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +# Temporary files +*~ +\#* +.\#* + # Python environment. env/* From 849e8ffa35ade3c8a753bbe0d3539bf2ced3def9 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 6 Jul 2023 16:22:50 +0100 Subject: [PATCH 10/11] Add python3.10 and 3.11 to test build matrix. --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index a2cdf8b6..f2640aa7 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9] + python-version: [3.8, 3.9, "3.10", "3.11"] steps: - uses: actions/checkout@v2 From 58d96013c3934244405363b39219b0792c3ef109 Mon Sep 17 00:00:00 2001 From: Kyle Oman Date: Thu, 6 Jul 2023 16:23:23 +0100 Subject: [PATCH 11/11] Revert to unyt>=2.9.0, 3.0.0 not yet released. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index da53b807..02d8d45d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ dependencies = [ "numpy", "h5py", - "unyt>=3.0.0", + "unyt>=2.9.0", "numba>=0.50.0", ]