Skip to content

Commit

Permalink
MNT: drop support for yt 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 17, 2022
1 parent fe2e8ba commit 3a9bc92
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 173 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 3a9bc92

Please sign in to comment.