Skip to content

Commit

Permalink
Merge pull request #153 from neutrinoceros/drop_yt_4.0
Browse files Browse the repository at this point in the history
MNT: drop support for yt 4.0.x
  • Loading branch information
neutrinoceros committed Oct 17, 2022
2 parents fe2e8ba + 979bd1e commit 62d018b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 180 deletions.
7 changes: 2 additions & 5 deletions README.md
Expand Up @@ -37,13 +37,10 @@ version 0.12.0 brings experimental *native* support for streched grids, which is
active development upstream, in yt itself.

Slices should now work seamlessly even with older versions of yt, however
yt 4.1 (to be released) will be required to perform projections correctly.
yt 4.1 will be required to perform projections correctly.

In the meantime, I recommend installing yt from source. At the time of writing,
the branch attached to the following pull request is required for projections with
stretched grids:
**update**: yt_idefix 0.13.3 is the last release allowing yt 4.0.x, yt_idefix 0.14.0 requires yt 4.1

https://github.com/yt-project/yt/pull/2998

### yt_idefix 0.11 and older (deprecated)

Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = yt_idefix
version = 0.13.4
version = 0.14.0
description = An extension module for yt, adding a frontend for Idefix
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -35,7 +35,7 @@ packages = find:
install_requires =
inifix>=2.3.0
numpy>=1.17.3
yt>=4.0.2
yt>=4.1.0
python_requires = >=3.8

[options.extras_require]
Expand Down
27 changes: 4 additions & 23 deletions tests/test_vtk.py
@@ -1,19 +1,15 @@
import os
import re
from importlib.metadata import version

import pytest
from more_itertools import distinct_combinations
from packaging.version import Version
from unyt import Unit, assert_allclose_units

import yt
import yt_idefix
from yt_idefix.api import IdefixVtkDataset, PlutoVtkDataset
from yt_idefix.loaders import VisibleDeprecationWarning

YT_VERSION = Version(version("yt"))

# A sample list of units for test.
# The first three values are chosen randomly
# and others are calculated correspondingly.
Expand Down Expand Up @@ -218,28 +214,13 @@ def mom_den(field, data):
def test_slice_plot(vtk_file):
file = vtk_file
ds = yt.load(file["path"], geometry=file["geometry"], unit_system="code")
if YT_VERSION < Version("4.1.dev0"):
yt.SlicePlot(ds, 2, fields=("gas", "density"))
else:
# this should work but it's broken with yt 4.0.x
# it is fixed in https://github.com/yt-project/yt/pull/3489
yt.SlicePlot(ds, normal=(0, 0, 1), fields=("gas", "density"))


@pytest.mark.skipif(
YT_VERSION < Version("4.0.5"),
reason=(
"This test breaks at collection because a ResourceWarning is emitted.\n"
"It is resolved in yt 4.0.5"
),
)
yt.SlicePlot(ds, normal=(0, 0, 1), fields=("gas", "density"))


def test_projection_plot(vtk_file):
file = vtk_file
ds = yt.load(file["path"], geometry=file["geometry"], unit_system="code")
if YT_VERSION < Version("4.1.dev0"):
yt.ProjectionPlot(ds, 2, fields=("gas", "density"))
else:
yt.ProjectionPlot(ds, normal=(0, 0, 1), fields=("gas", "density"))
yt.ProjectionPlot(ds, normal=(0, 0, 1), fields=("gas", "density"))


def test_load_magic(vtk_file):
Expand Down
2 changes: 1 addition & 1 deletion yt_idefix/__init__.py
Expand Up @@ -2,4 +2,4 @@
# immediately after `import yt.extensions.idefix`
from yt_idefix.api import *

__version__ = "0.13.4"
__version__ = "0.14.0"
Empty file removed yt_idefix/_vendors/__init__.py
Empty file.
30 changes: 0 additions & 30 deletions yt_idefix/_vendors/base_particle_io_handler.py

This file was deleted.

83 changes: 0 additions & 83 deletions yt_idefix/_vendors/streched_grids.py

This file was deleted.

30 changes: 2 additions & 28 deletions yt_idefix/data_structures.py
Expand Up @@ -7,45 +7,30 @@
import weakref
from abc import ABC, abstractmethod
from functools import cached_property
from importlib.metadata import version
from typing import Literal

import inifix
import numpy as np
from packaging.version import Version

from yt.data_objects.index_subobjects.stretched_grid import StretchedGrid
from yt.data_objects.static_output import Dataset
from yt.funcs import setdefaultattr
from yt.geometry.grid_geometry_handler import GridIndex
from yt.utilities.lib.misc_utilities import _obtain_coords_and_widths
from yt_idefix._typing import UnitLike

from ._io import C_io, dmp_io, vtk_io
from ._io.commons import IdefixFieldProperties, IdefixMetadata
from .definitions import _PlutoBaseUnits, pluto_def_constants
from .fields import BaseVtkFields, IdefixDmpFields, IdefixVtkFields, PlutoVtkFields

try:
from yt.data_objects.index_subobjects.stretched_grid import StretchedGrid
except ImportError:
from ._vendors.streched_grids import StretchedGrid # type: ignore [no-redef]

try:
from yt.utilities.lib.misc_utilities import _obtain_coords_and_widths
except ImportError:
from ._vendors.streched_grids import (
_obtain_coords_and_widths, # type: ignore [no-redef]
)

# import IO classes to ensure they are properly registered,
# even though we don't call them directly
from .io import IdefixDmpIO, IdefixVtkIO, PlutoVtkIO # noqa

ytLogger = logging.getLogger("yt")


YT_VERSION = Version(version("yt"))


class IdefixGrid(StretchedGrid):
_id_offset = 0

Expand All @@ -56,13 +41,6 @@ def __init__(self, id, cell_widths, filename, index, level, dims):
self.Level = level
self.ActiveDimensions = dims

def __repr__(self):
if YT_VERSION >= Version("4.1"):
# https://github.com/yt-project/yt/pull/3936
return super().__repr__()
else:
return "IdefixGrid_%04i (%s)" % (self.id, self.ActiveDimensions)


class IdefixHierarchy(GridIndex, ABC):
grid = IdefixGrid
Expand Down Expand Up @@ -487,10 +465,6 @@ def __init__(
else:
self._definitions_header = None

if YT_VERSION < Version("4.1.dev0"):
# https://github.com/yt-project/yt/pull/3772
filename = os.path.abspath(os.path.expanduser(filename))

super().__init__(
filename,
dataset_type=dataset_type,
Expand Down
9 changes: 1 addition & 8 deletions yt_idefix/io.py
Expand Up @@ -3,17 +3,10 @@

import numpy as np

from yt.utilities.io_handler import BaseIOHandler
from yt.utilities.io_handler import BaseIOHandler, BaseParticleIOHandler

from ._io import dmp_io, vtk_io

try:
from yt.utilities.io_handler import BaseParticleIOHandler
except ImportError:
from ._vendors.base_particle_io_handler import (
BaseParticleIOHandler, # type: ignore [no-redef]
)


class SingleGridIO(BaseIOHandler, ABC):
_particle_reader = False
Expand Down

0 comments on commit 62d018b

Please sign in to comment.