Skip to content

Commit

Permalink
DEPR: deprecation cycle (4.0 -> 4.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 28, 2021
1 parent 7567464 commit 3ecb96a
Show file tree
Hide file tree
Showing 25 changed files with 10 additions and 663 deletions.
5 changes: 1 addition & 4 deletions doc/source/cookbook/complex_plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ or during image creation with the ``buff_size`` argument to any
of the four preceding classes.

2. ``figure_size``, which can be altered with either
:meth:`~yt.visualization.plot_container.PlotContainer.set_figure_size`
or with :meth:`~yt.visualization.plot_container.PlotWindow.set_window_size`
(the latter simply calls
:meth:`~yt.visualization.plot_container.PlotContainer.set_figure_size`),
:meth:`~yt.visualization.plot_container.PlotContainer.set_figure_size`,
or can be set during image creation with the ``window_size`` argument.
This sets the size of the final image (including the visualization and,
if applicable, the axes and colorbar as well) in inches.
Expand Down
4 changes: 0 additions & 4 deletions doc/source/reference/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ particularly with complicated layouts.
~yt.visualization.eps_writer.single_plot
~yt.visualization.eps_writer.multiplot
~yt.visualization.eps_writer.multiplot_yt
~yt.visualization.eps_writer.return_cmap
~yt.visualization.eps_writer.return_colormap

.. _derived-quantities-api:
Expand All @@ -663,7 +662,6 @@ See :ref:`derived-quantities`.
~yt.data_objects.derived_quantities.TotalMass
~yt.data_objects.derived_quantities.TotalQuantity
~yt.data_objects.derived_quantities.WeightedAverageQuantity
~yt.data_objects.derived_quantities.WeightedVariance

.. _callback-api:

Expand All @@ -675,7 +673,6 @@ See also :ref:`callbacks`.

.. autosummary::

~yt.visualization.plot_window.PWViewerMPL.annotate_clear
~yt.visualization.plot_window.PWViewerMPL.clear_annotations
~yt.visualization.plot_modifications.ArrowCallback
~yt.visualization.plot_modifications.CellEdgesCallback
Expand Down Expand Up @@ -709,7 +706,6 @@ See also :ref:`colormaps`.

.. autosummary::

~yt.visualization.color_maps.add_cmap
~yt.visualization.color_maps.add_colormap
~yt.visualization.color_maps.make_colormap
~yt.visualization.color_maps.show_colormaps
Expand Down
15 changes: 0 additions & 15 deletions yt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import yt.visualization.volume_rendering.api as volume_rendering
from yt.frontends.stream.api import hexahedral_connectivity
from yt.frontends.ytdata.api import save_as_dataset
from yt.loaders import simulation # deprecated alias for load_simulation
from yt.loaders import (
load,
load_amr_grids,
Expand Down Expand Up @@ -142,17 +141,3 @@

# TransferFunctionHelper, MultiVariateTransferFunction
# off_axis_projection


def _check_deprecated_parameters():
from yt._maintenance.deprecation import issue_deprecation_warning
from yt.config import ytcfg

if ytcfg.get("yt", "load_field_plugins"):
issue_deprecation_warning(
"Found deprecated parameter 'load_field_plugins' in yt's configuration file.",
removal="4.1.0",
)


_check_deprecated_parameters()
30 changes: 0 additions & 30 deletions yt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import toml
from more_itertools import always_iterable

from yt._maintenance.deprecation import issue_deprecation_warning
from yt.utilities.configuration_tree import ConfigLeaf, ConfigNode

ytcfg_defaults = {}
Expand Down Expand Up @@ -77,17 +76,8 @@ def config_dir():
return conf_dir


def old_config_file():
return os.path.join(config_dir(), "ytrc")


def old_config_dir():
return os.path.join(os.path.expanduser("~"), ".yt")


# For backward compatibility, do not use these vars internally in yt
CONFIG_DIR = config_dir()
_OLD_CONFIG_FILE = old_config_file()


class YTConfig:
Expand Down Expand Up @@ -199,26 +189,6 @@ def _repr_json_(self):
_global_config_file = YTConfig.get_global_config_file()
_local_config_file = YTConfig.get_local_config_file()

if os.path.exists(old_config_file()):
if os.path.exists(_global_config_file):
issue_deprecation_warning(
f"The configuration file {old_config_file()} is deprecated in "
f"favor of {_global_config_file}. Currently, both are present. "
"Please manually remove the deprecated one to silence "
"this warning.",
since="4.0.0",
removal="4.1.0",
)
else:
issue_deprecation_warning(
f"The configuration file {_OLD_CONFIG_FILE} is deprecated. "
f"Please migrate your config to {_global_config_file} by running: "
"'yt config migrate'",
since="4.0.0",
removal="4.1.0",
)


if not os.path.exists(_global_config_file):
cfg = {"yt": {}}
try:
Expand Down
13 changes: 0 additions & 13 deletions yt/data_objects/derived_quantities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np

from yt._maintenance.deprecation import issue_deprecation_warning
from yt.funcs import camelcase_to_underscore, iter_fields
from yt.units.yt_array import array_like_field
from yt.utilities.exceptions import YTParticleTypeNotFound
Expand Down Expand Up @@ -459,18 +458,6 @@ def reduce_intermediate(self, values):
return rvals


class WeightedVariance(WeightedStandardDeviation):
def __call__(self, fields, weight):
issue_deprecation_warning(
"'weighted_variance' incorrectly returns the "
"standard deviation and has been deprecated. "
"Use 'weighted_standard_deviation' instead.",
since="4.0.0",
removal="4.1.0",
)
return super().__call__(fields, weight)


class AngularMomentumVector(DerivedQuantity):
r"""
Calculates the angular momentum vector, using gas (grid-based) and/or particles.
Expand Down
12 changes: 0 additions & 12 deletions yt/data_objects/index_subobjects/octree_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import yt.geometry.particle_deposit as particle_deposit
import yt.geometry.particle_smooth as particle_smooth
from yt._maintenance.deprecation import issue_deprecation_warning
from yt.data_objects.selection_objects.data_selection_objects import (
YTSelectionContainer,
)
Expand Down Expand Up @@ -526,15 +525,6 @@ def select_particles(self, selector, x, y, z):
return mask

def get_vertex_centered_data(self, fields):
_old_api = isinstance(fields, (str, tuple))
if _old_api:
message = (
"get_vertex_centered_data() requires list of fields, rather than "
"a single field as an argument."
)
issue_deprecation_warning(message, since="4.0.0", removal="4.1.0")
fields = [fields]

# Make sure the field list has only unique entries
fields = list(set(fields))
new_fields = {}
Expand All @@ -550,8 +540,6 @@ def get_vertex_centered_data(self, fields):
np.add(new_fields[field], cg[field][:-1, :-1, :-1], new_fields[field])
np.multiply(new_fields[field], 0.125, new_fields[field])

if _old_api:
return new_fields[fields[0]]
return new_fields


Expand Down
77 changes: 1 addition & 76 deletions yt/data_objects/static_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,25 +274,6 @@ def periodicity(self):
return (True, True, True)
return self._periodicity

@periodicity.setter
def periodicity(self, val):
# remove this setter to break backward compatibility
issue_deprecation_warning(
"Dataset.periodicity should not be overridden manually. "
"In the future, this will become an error. "
"Use `Dataset.force_periodicity` instead.",
since="4.0.0",
removal="4.1.0",
)
err_msg = f"Expected a 3-element boolean tuple, received `{val}`."
if not is_sequence(val):
raise TypeError(err_msg)
if len(val) != 3:
raise ValueError(err_msg)
if any(not isinstance(p, (bool, np.bool_)) for p in val):
raise TypeError(err_msg)
self._periodicity = tuple(bool(p) for p in val)

def force_periodicity(self, val=True):
"""
Override box periodicity to (True, True, True).
Expand Down Expand Up @@ -1703,51 +1684,7 @@ def _deposit_field(field, data):
)
return ("deposit", field_name)

def add_smoothed_particle_field(
self, smooth_field, method="volume_weighted", nneighbors=64, kernel_name="cubic"
):
"""Add a new smoothed particle field
WARNING: This method is deprecated since yt-4.0.
Creates a new smoothed field based on the particle *smooth_field*.
Parameters
----------
smooth_field : tuple
The field name tuple of the particle field the smoothed field will
be created from. This must be a field name tuple so yt can
appropriately infer the correct particle type.
method : string, default 'volume_weighted'
The particle smoothing method to use. Can only be 'volume_weighted'
for now.
nneighbors : int, default 64
The number of neighbors to examine during the process.
kernel_name : string, default `cubic`
This is the name of the smoothing kernel to use. Current supported
kernel names include `cubic`, `quartic`, `quintic`, `wendland2`,
`wendland4`, and `wendland6`.
Returns
-------
The field name tuple for the newly created field.
"""
issue_deprecation_warning(
"This method is deprecated. "
"Since yt-4.0, it's no longer necessary to add a field specifically for "
"smoothing, because the global octree is removed. The old behavior of "
"interpolating onto a grid structure can be recovered through data objects "
"like ds.arbitrary_grid, ds.covering_grid, and most closely ds.octree. The "
"visualization machinery now treats SPH fields properly by smoothing onto "
"pixel locations. See this page to learn more: "
"https://yt-project.org/doc/yt4differences.html",
since="4.0.0",
removal="4.1.0",
)

def add_gradient_fields(self, fields=None, input_field=None):
def add_gradient_fields(self, fields=None):
"""Add gradient fields.
Creates four new grid-based fields that represent the components of the gradient
Expand Down Expand Up @@ -1792,18 +1729,6 @@ def add_gradient_fields(self, fields=None, input_field=None):
For instance, with cylindrical data, one gets 'density_gradient_<r,theta,z>'
"""
if input_field is not None:
issue_deprecation_warning(
"keyword argument 'input_field' is deprecated in favor of 'fields' "
"and will be removed in a future version of yt.",
since="4.0.0",
removal="4.1.0",
)
if fields is not None:
raise TypeError(
"Can not use both 'fields' and 'input_field' keyword arguments"
)
fields = input_field
if fields is None:
raise TypeError("Missing required positional argument: fields")

Expand Down
53 changes: 0 additions & 53 deletions yt/data_objects/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np
from more_itertools import always_iterable

from yt._maintenance.deprecation import issue_deprecation_warning
from yt.config import ytcfg
from yt.data_objects.analyzer_objects import AnalysisTask, create_quantity_proxy
from yt.data_objects.particle_trajectories import ParticleTrajectories
Expand Down Expand Up @@ -353,58 +352,6 @@ def eval(self, tasks, obj=None):
store.result.append(rv)
return [v for k, v in sorted(return_values.items())]

@classmethod
def from_filenames(cls, filenames, parallel=True, setup_function=None, **kwargs):
r"""Create a time series from either a filename pattern or a list of
filenames.
This method provides an easy way to create a
:class:`~yt.data_objects.time_series.DatasetSeries`, given a set of
filenames or a pattern that matches them. Additionally, it can set the
parallelism strategy.
Parameters
----------
filenames : list or pattern
This can either be a list of filenames (such as ["DD0001/DD0001",
"DD0002/DD0002"]) or a pattern to match, such as
"DD*/DD*.index"). If it's the former, they will be loaded in
order. The latter will be identified with the glob module and then
sorted.
parallel : True, False or int
This parameter governs the behavior when .piter() is called on the
resultant DatasetSeries object. If this is set to False, the time
series will not iterate in parallel when .piter() is called. If
this is set to either True or an integer, it will be iterated with
1 or that integer number of processors assigned to each parameter
file provided to the loop.
setup_function : callable, accepts a ds
This function will be called whenever a dataset is loaded.
Examples
--------
>>> def print_time(ds):
... print(ds.current_time)
...
>>> ts = DatasetSeries.from_filenames(
... "GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0[0-6][0-9]0",
... setup_function=print_time,
... )
...
>>> for ds in ts:
... SlicePlot(ds, "x", ("gas", "density")).save()
"""
issue_deprecation_warning(
"DatasetSeries.from_filenames() is deprecated and will be removed "
"in a future version of yt. Use DatasetSeries() directly.",
since="4.0.0",
removal="4.1.0",
)
obj = cls(filenames, parallel=parallel, setup_function=setup_function, **kwargs)
return obj

@classmethod
def from_output_log(cls, output_log, line_prefix="DATASET WRITTEN", parallel=True):
filenames = []
Expand Down
20 changes: 1 addition & 19 deletions yt/fields/field_info_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy as np
from unyt.exceptions import UnitConversionError

from yt._maintenance.deprecation import issue_deprecation_warning
from yt.fields.field_exceptions import NeedsConfiguration
from yt.funcs import mylog, only_on_root
from yt.geometry.geometry_handler import is_curvilinear
Expand Down Expand Up @@ -267,7 +266,7 @@ def setup_fluid_aliases(self, ftype="gas"):
self.alias((ftype, alias), field)

@staticmethod
def _sanitize_sampling_type(sampling_type, particle_type=None):
def _sanitize_sampling_type(sampling_type):
"""Detect conflicts between deprecated and new parameters to specify the
sampling type in a new field.
Expand All @@ -277,9 +276,6 @@ def _sanitize_sampling_type(sampling_type, particle_type=None):
----------
sampling_type : str
One of "cell", "particle" or "local" (case insensitive)
particle_type : str
This is a deprecated argument of the add_field method,
which was replaced by sampling_type.
Raises
------
Expand All @@ -300,20 +296,6 @@ def _sanitize_sampling_type(sampling_type, particle_type=None):
sampling_type,
", ".join(acceptable_samplings),
)

if particle_type:
issue_deprecation_warning(
"'particle_type' keyword argument is deprecated in favour "
"of the positional argument 'sampling_type'.",
since="4.0.0",
removal="4.1.0",
)
if sampling_type != "particle":
raise RuntimeError(
"Conflicting values for parameters "
"'sampling_type' and 'particle_type'."
)

return sampling_type

def add_field(self, name, function, sampling_type, **kwargs):
Expand Down
Loading

0 comments on commit 3ecb96a

Please sign in to comment.