From 898b5eb174c94c6802bae70143bf69e93086e0ca Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Wed, 25 May 2022 18:27:14 +0200 Subject: [PATCH 01/32] Projection 'min' method (first commit, doesn't work yet). Address Issue #987654321 --- .../construction_data_containers.py | 17 +++++++--- yt/utilities/lib/quad_tree.pyx | 31 ++++++++++++++++--- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index 37cea50b90b..bbbd88e9c11 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -191,8 +191,10 @@ def __init__( else: self.method = method self._sum_only = False - if self.method == "mip": + if self.method in ["mip","max"]: self.func = np.max + elif self.method in ["min"]: + self.func = np.min elif self.method == "integrate": self.func = np.sum # for the future else: @@ -254,9 +256,12 @@ def get_data(self, fields=None): projected_units = self.comm.mpi_bcast(self._projected_units) self._projected_units = projected_units # Note that this will briefly double RAM usage - if self.method == "mip": + if self.method in ["mip", "max"]: # TODO: suggest mip as deprecated merge_style = -1 op = "max" + if self.method == "min": + merge_style = -2 + op = "min" elif self.method == "integrate": merge_style = 1 op = "sum" @@ -348,7 +353,7 @@ def _initialize_projected_units(self, fields, chunk): # for future field accesses. finfo.units = str(chunk[field].units) field_unit = Unit(finfo.output_units, registry=self.ds.unit_registry) - if self.method == "mip" or self._sum_only: + if self.method in ["mip","min","max"] or self._sum_only: path_length_unit = Unit(registry=self.ds.unit_registry) else: ax_name = self.ds.coordinates.axis_name[self.axis] @@ -447,7 +452,9 @@ class YTQuadTreeProj(YTProj): method : string, optional The method of projection to be performed. "integrate" : integration along the axis - "mip" : maximum intensity projection + "mip" : maximum intensity projection (deprecated) + "max" : maximum intensity projection + "min" : minimum intensity projection "sum" : same as "integrate", except that we don't multiply by the path length WARNING: The "sum" option should only be used for uniform resolution grid datasets, as other datasets may result in unphysical images. @@ -557,7 +564,7 @@ def _handle_chunk(self, chunk, fields, tree): chunk.ires.size, get_memory_usage() / 1024.0, ) - if self.method == "mip" or self._sum_only: + if self.method in ["mip","min","max"] or self._sum_only: dl = self.ds.quan(1.0, "") else: ax_name = self.ds.coordinates.axis_name[self.axis] diff --git a/yt/utilities/lib/quad_tree.pyx b/yt/utilities/lib/quad_tree.pyx index 88b71cdd5b7..8dd2d570ea4 100644 --- a/yt/utilities/lib/quad_tree.pyx +++ b/yt/utilities/lib/quad_tree.pyx @@ -16,7 +16,7 @@ cimport numpy as np from cython.operator cimport dereference as deref, preincrement as inc from libc.stdlib cimport abs, free, malloc -from yt.utilities.lib.fp_utils cimport fmax +from yt.utilities.lib.fp_utils cimport fmax,fmin from yt.utilities.exceptions import YTIntDomainOverflow @@ -51,6 +51,19 @@ cdef void QTN_max_value(QuadTreeNode *self, self.val[i] = fmax(val[i], self.val[i]) self.weight_val = 1.0 +cdef void QTN_min_value(QuadTreeNode *self, + np.float64_t *val, np.float64_t weight_val, + int nvals): + cdef int i + #cdef np.float64_t *big_num = 1.0 + #big_num = 1.0 #1e10 + for i in range(nvals): + if self.val[i] == 0: + self.val[i] = 1e50 + # end if + self.val[i] = fmin(val[i], self.val[i]) + self.weight_val = 1.0 + cdef void QTN_refine(QuadTreeNode *self, int nvals): cdef int i, j cdef np.int64_t npos[2] @@ -108,8 +121,10 @@ cdef class QuadTree: int nvals, bounds, method = "integrate"): if method == "integrate": self.combine = QTN_add_value - elif method == "mip": + elif method in ["mip","max"]: self.combine = QTN_max_value + elif method in ["min"]: + self.combine = QTN_min_value else: raise NotImplementedError self.merged = 1 @@ -202,8 +217,10 @@ cdef class QuadTree: np.ndarray[np.float64_t, ndim=2] values, np.ndarray[np.float64_t, ndim=1] wval, method): - if method == "mip" or method == -1: + if method in ["mip","max"] or method == -1: self.merged = -1 + if method == "min" or method == -2: + self.merged = -2 elif method == "integrate" or method == 1: self.merged = 1 cdef int curpos = 0 @@ -406,6 +423,9 @@ cdef class QuadTree: if self.merged == -1: for i in range(self.nvals): vdata[self.nvals * curpos + i] = fmax(node.val[i], vtoadd[i]) + elif self.merged == -2: + for i in range(self.nvals): + vdata[self.nvals * curpos + i] = fmin(node.val[i], vtoadd[i]) wdata[curpos] = 1.0 else: for i in range(self.nvals): @@ -424,7 +444,7 @@ cdef class QuadTree: vorig[i] = vtoadd[i] vtoadd[i] += node.val[i] wtoadd += node.weight_val - elif self.merged == -1: + elif self.merged in [-1,-2]: for i in range(self.nvals): vtoadd[i] = node.val[i] for i in range(2): @@ -567,6 +587,9 @@ def merge_quadtrees(QuadTree qt1, QuadTree qt2, method = 1): elif method == -1: qt1.merged = -1 func = QTN_max_value + elif method == -2: + qt1.merged = -2 + func = QTN_min_value else: raise NotImplementedError if qt1.merged != 0 or qt2.merged != 0: From c600581035fe715cdd341692c548ca79984f136e Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Wed, 25 May 2022 18:51:26 +0200 Subject: [PATCH 02/32] added mention of the new projection method in 'simple_plots.rst' in the cookbook and a mwe as 'simple_projection_methods.py' - and it looks like it's working! At least partially :) Addresses Issue #987654321 --- doc/source/cookbook/simple_plots.rst | 8 ++++++++ doc/source/cookbook/simple_projection_methods.py | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 doc/source/cookbook/simple_projection_methods.py diff --git a/doc/source/cookbook/simple_plots.rst b/doc/source/cookbook/simple_plots.rst index 1705b193c0d..5da1c2ea0f3 100644 --- a/doc/source/cookbook/simple_plots.rst +++ b/doc/source/cookbook/simple_plots.rst @@ -33,6 +33,14 @@ See :ref:`projection-plots` for more information. .. yt_cookbook:: simple_projection_weighted.py +Simple Projections (Methods) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +And here we illustrate different methods for projection plots (integrate, +minimum, maximum). + +.. yt_cookbook:: simple_projection_methods.py + Simple Phase Plots ~~~~~~~~~~~~~~~~~~ diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py new file mode 100644 index 00000000000..58ba2cd8398 --- /dev/null +++ b/doc/source/cookbook/simple_projection_methods.py @@ -0,0 +1,13 @@ +import yt + +# Load the dataset. +fname = "Shattering_V10_hdf5_plt_cnt_2101" +ds = yt.load("/Users/ryanjsfx/SCP/ReceivedFiles/Shattering/sR1e5/" + fname) + +# Create projections of temperature (with different methods) + + +for method in ["integrate", "min", "max"]: + yt.ProjectionPlot( + ds, "x", ("gas", "temperature"), method=method + ).save(fname + "_Projection_x_temperature_" + method + ".png") From f6d0d3ced6983a02b5f1c17f9305b6fde89eb93b Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Wed, 25 May 2022 21:06:11 +0200 Subject: [PATCH 03/32] switched back to the standard file to load in the cookbook script --- doc/source/cookbook/simple_projection_methods.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py index 58ba2cd8398..4df1a639b7e 100644 --- a/doc/source/cookbook/simple_projection_methods.py +++ b/doc/source/cookbook/simple_projection_methods.py @@ -1,8 +1,7 @@ import yt # Load the dataset. -fname = "Shattering_V10_hdf5_plt_cnt_2101" -ds = yt.load("/Users/ryanjsfx/SCP/ReceivedFiles/Shattering/sR1e5/" + fname) +ds = yt.load("GalaxyClusterMerger/fiducial_1to3_b0.273d_hdf5_plt_cnt_0175") # Create projections of temperature (with different methods) @@ -10,4 +9,6 @@ for method in ["integrate", "min", "max"]: yt.ProjectionPlot( ds, "x", ("gas", "temperature"), method=method - ).save(fname + "_Projection_x_temperature_" + method + ".png") + ).save(method + ".png") +## note, the default save name doesn't look at the method +## so otherwise it'd just overwrite each loop through From 68f29a92b83170c2046fdfd26deccf5ab417729f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 May 2022 19:59:27 +0000 Subject: [PATCH 04/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/source/cookbook/simple_projection_methods.py | 6 +++--- yt/data_objects/construction_data_containers.py | 8 ++++---- yt/utilities/lib/quad_tree.pyx | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py index 4df1a639b7e..7f97b9da3ab 100644 --- a/doc/source/cookbook/simple_projection_methods.py +++ b/doc/source/cookbook/simple_projection_methods.py @@ -7,8 +7,8 @@ for method in ["integrate", "min", "max"]: - yt.ProjectionPlot( - ds, "x", ("gas", "temperature"), method=method - ).save(method + ".png") + yt.ProjectionPlot(ds, "x", ("gas", "temperature"), method=method).save( + method + ".png" + ) ## note, the default save name doesn't look at the method ## so otherwise it'd just overwrite each loop through diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index bbbd88e9c11..32b485be6fb 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -191,7 +191,7 @@ def __init__( else: self.method = method self._sum_only = False - if self.method in ["mip","max"]: + if self.method in ["mip", "max"]: self.func = np.max elif self.method in ["min"]: self.func = np.min @@ -256,7 +256,7 @@ def get_data(self, fields=None): projected_units = self.comm.mpi_bcast(self._projected_units) self._projected_units = projected_units # Note that this will briefly double RAM usage - if self.method in ["mip", "max"]: # TODO: suggest mip as deprecated + if self.method in ["mip", "max"]: # TODO: suggest mip as deprecated merge_style = -1 op = "max" if self.method == "min": @@ -353,7 +353,7 @@ def _initialize_projected_units(self, fields, chunk): # for future field accesses. finfo.units = str(chunk[field].units) field_unit = Unit(finfo.output_units, registry=self.ds.unit_registry) - if self.method in ["mip","min","max"] or self._sum_only: + if self.method in ["mip", "min", "max"] or self._sum_only: path_length_unit = Unit(registry=self.ds.unit_registry) else: ax_name = self.ds.coordinates.axis_name[self.axis] @@ -564,7 +564,7 @@ def _handle_chunk(self, chunk, fields, tree): chunk.ires.size, get_memory_usage() / 1024.0, ) - if self.method in ["mip","min","max"] or self._sum_only: + if self.method in ["mip", "min", "max"] or self._sum_only: dl = self.ds.quan(1.0, "") else: ax_name = self.ds.coordinates.axis_name[self.axis] diff --git a/yt/utilities/lib/quad_tree.pyx b/yt/utilities/lib/quad_tree.pyx index 8dd2d570ea4..4d0cd0f4611 100644 --- a/yt/utilities/lib/quad_tree.pyx +++ b/yt/utilities/lib/quad_tree.pyx @@ -16,7 +16,7 @@ cimport numpy as np from cython.operator cimport dereference as deref, preincrement as inc from libc.stdlib cimport abs, free, malloc -from yt.utilities.lib.fp_utils cimport fmax,fmin +from yt.utilities.lib.fp_utils cimport fmax, fmin from yt.utilities.exceptions import YTIntDomainOverflow From b64d182d6121117d8e5b1f7d8bfe397bd9a4ddc2 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 10:31:22 +0200 Subject: [PATCH 05/32] changed 'in' to '==' and separated save from instantiation in cookbook. Address Issue #987654321 --- doc/source/cookbook/simple_projection_methods.py | 5 ++--- yt/data_objects/construction_data_containers.py | 2 +- yt/utilities/lib/quad_tree.pyx | 9 +++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py index 7f97b9da3ab..96ef6b22cd6 100644 --- a/doc/source/cookbook/simple_projection_methods.py +++ b/doc/source/cookbook/simple_projection_methods.py @@ -7,8 +7,7 @@ for method in ["integrate", "min", "max"]: - yt.ProjectionPlot(ds, "x", ("gas", "temperature"), method=method).save( - method + ".png" - ) + proj = yt.ProjectionPlot(ds, "x", ("gas", "temperature"), method=method) + proj.save() ## note, the default save name doesn't look at the method ## so otherwise it'd just overwrite each loop through diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index 32b485be6fb..dcdd9a27b26 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -193,7 +193,7 @@ def __init__( self._sum_only = False if self.method in ["mip", "max"]: self.func = np.max - elif self.method in ["min"]: + elif self.method == "min": self.func = np.min elif self.method == "integrate": self.func = np.sum # for the future diff --git a/yt/utilities/lib/quad_tree.pyx b/yt/utilities/lib/quad_tree.pyx index 4d0cd0f4611..2deedd1f875 100644 --- a/yt/utilities/lib/quad_tree.pyx +++ b/yt/utilities/lib/quad_tree.pyx @@ -121,9 +121,10 @@ cdef class QuadTree: int nvals, bounds, method = "integrate"): if method == "integrate": self.combine = QTN_add_value - elif method in ["mip","max"]: + elif method == "mip" or \ + method == "max": self.combine = QTN_max_value - elif method in ["min"]: + elif method == "min": self.combine = QTN_min_value else: raise NotImplementedError @@ -217,7 +218,7 @@ cdef class QuadTree: np.ndarray[np.float64_t, ndim=2] values, np.ndarray[np.float64_t, ndim=1] wval, method): - if method in ["mip","max"] or method == -1: + if method == "mip" or method == "max" or method == -1: self.merged = -1 if method == "min" or method == -2: self.merged = -2 @@ -444,7 +445,7 @@ cdef class QuadTree: vorig[i] = vtoadd[i] vtoadd[i] += node.val[i] wtoadd += node.weight_val - elif self.merged in [-1,-2]: + elif self.merged == -1 or self.merged == -2: for i in range(self.nvals): vtoadd[i] = node.val[i] for i in range(2): From 59310421ae7061f799c3baa16361ff659565eea6 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 10:59:02 +0200 Subject: [PATCH 06/32] added deprecation warning for 'mip' method value and removed usage of 'mip' in construction_data_containers. I'm not sure now if I should've done that to clean or left it in there to be safe... --- yt/data_objects/construction_data_containers.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index dcdd9a27b26..78263740746 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -185,13 +185,20 @@ def __init__( removal="4.2", ) method = style + issue_deprecation_warning( + "The 'mip' method value is a deprecated alias for 'max'. " + "Please use max directly.", + since="4.2", + removal="5.2", + ) + method = "max" if method == "sum": self.method = "integrate" self._sum_only = True else: self.method = method self._sum_only = False - if self.method in ["mip", "max"]: + if self.method == "max": self.func = np.max elif self.method == "min": self.func = np.min @@ -256,7 +263,7 @@ def get_data(self, fields=None): projected_units = self.comm.mpi_bcast(self._projected_units) self._projected_units = projected_units # Note that this will briefly double RAM usage - if self.method in ["mip", "max"]: # TODO: suggest mip as deprecated + if self.method == "max": merge_style = -1 op = "max" if self.method == "min": @@ -353,7 +360,7 @@ def _initialize_projected_units(self, fields, chunk): # for future field accesses. finfo.units = str(chunk[field].units) field_unit = Unit(finfo.output_units, registry=self.ds.unit_registry) - if self.method in ["mip", "min", "max"] or self._sum_only: + if self.method in ["min", "max"] or self._sum_only: path_length_unit = Unit(registry=self.ds.unit_registry) else: ax_name = self.ds.coordinates.axis_name[self.axis] @@ -564,7 +571,7 @@ def _handle_chunk(self, chunk, fields, tree): chunk.ires.size, get_memory_usage() / 1024.0, ) - if self.method in ["mip", "min", "max"] or self._sum_only: + if self.method in ["min", "max"] or self._sum_only: dl = self.ds.quan(1.0, "") else: ax_name = self.ds.coordinates.axis_name[self.axis] From 1b7851f52dc5dd9640462358e13eeac3dc66038c Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 11:16:26 +0200 Subject: [PATCH 07/32] corrected the deprecation warning to actually have the 'if' statement it was intended to have. Addresses issue #987654321 --- yt/data_objects/construction_data_containers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index 78263740746..4ae829f8ce6 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -185,11 +185,11 @@ def __init__( removal="4.2", ) method = style + if method == "mip": issue_deprecation_warning( "The 'mip' method value is a deprecated alias for 'max'. " "Please use max directly.", - since="4.2", - removal="5.2", + since="4.1", ) method = "max" if method == "sum": @@ -198,7 +198,7 @@ def __init__( else: self.method = method self._sum_only = False - if self.method == "max": + if self.method in ["max","mip"]: self.func = np.max elif self.method == "min": self.func = np.min @@ -263,7 +263,7 @@ def get_data(self, fields=None): projected_units = self.comm.mpi_bcast(self._projected_units) self._projected_units = projected_units # Note that this will briefly double RAM usage - if self.method == "max": + if self.method in ["max","mip"]: merge_style = -1 op = "max" if self.method == "min": @@ -360,7 +360,7 @@ def _initialize_projected_units(self, fields, chunk): # for future field accesses. finfo.units = str(chunk[field].units) field_unit = Unit(finfo.output_units, registry=self.ds.unit_registry) - if self.method in ["min", "max"] or self._sum_only: + if self.method in ["min", "max","mip"] or self._sum_only: path_length_unit = Unit(registry=self.ds.unit_registry) else: ax_name = self.ds.coordinates.axis_name[self.axis] @@ -571,7 +571,7 @@ def _handle_chunk(self, chunk, fields, tree): chunk.ires.size, get_memory_usage() / 1024.0, ) - if self.method in ["min", "max"] or self._sum_only: + if self.method in ["min", "max", "mip"] or self._sum_only: dl = self.ds.quan(1.0, "") else: ax_name = self.ds.coordinates.axis_name[self.axis] From e5aa19515b4dab84a25ede7cb690beb08093af5f Mon Sep 17 00:00:00 2001 From: rjfarber Date: Thu, 26 May 2022 11:36:24 +0200 Subject: [PATCH 08/32] Update doc/source/cookbook/simple_projection_methods.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit custom file name Co-authored-by: Clément Robert --- doc/source/cookbook/simple_projection_methods.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py index 96ef6b22cd6..bb319b50b88 100644 --- a/doc/source/cookbook/simple_projection_methods.py +++ b/doc/source/cookbook/simple_projection_methods.py @@ -8,6 +8,4 @@ for method in ["integrate", "min", "max"]: proj = yt.ProjectionPlot(ds, "x", ("gas", "temperature"), method=method) - proj.save() -## note, the default save name doesn't look at the method -## so otherwise it'd just overwrite each loop through + proj.save(f"projection_method_{method}.png") From 7ca093917dea968b248411716d5f86258c9c3304 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 13:54:53 +0200 Subject: [PATCH 09/32] added max,min to docstring in plot_window.py; note I'll be doing a lot of little commits since I made a lot of changes and just lost them all :*( Addresses Issue #987654321 --- yt/visualization/plot_window.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index 087ef1cbb8e..f9f41817f56 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -2205,6 +2205,8 @@ class AxisAlignedProjectionPlot(ProjectionPlot, PWViewerMPL): field by the weighting field and integrate along the line of sight. "mip" : pick out the maximum value of the field in the line of sight. + "max" : pick out the maximum value of the field in the line of sight. + "min" : pick out the minimum value of the field in the line of sight. "sum" : This method is the same as integrate, except that it does not multiply by a path length when performing the integration, and is From 90904628c7efbb4e4cdb7eb9d3e686f3427db4f1 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:01:14 +0200 Subject: [PATCH 10/32] just ran pre-commit (had to reinstall) --- yt/data_objects/construction_data_containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index 4ae829f8ce6..473b36f096f 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -185,7 +185,7 @@ def __init__( removal="4.2", ) method = style - if method == "mip": + if method == "mip": issue_deprecation_warning( "The 'mip' method value is a deprecated alias for 'max'. " "Please use max directly.", @@ -198,7 +198,7 @@ def __init__( else: self.method = method self._sum_only = False - if self.method in ["max","mip"]: + if self.method in ["max", "mip"]: self.func = np.max elif self.method == "min": self.func = np.min @@ -263,7 +263,7 @@ def get_data(self, fields=None): projected_units = self.comm.mpi_bcast(self._projected_units) self._projected_units = projected_units # Note that this will briefly double RAM usage - if self.method in ["max","mip"]: + if self.method in ["max", "mip"]: merge_style = -1 op = "max" if self.method == "min": @@ -360,7 +360,7 @@ def _initialize_projected_units(self, fields, chunk): # for future field accesses. finfo.units = str(chunk[field].units) field_unit = Unit(finfo.output_units, registry=self.ds.unit_registry) - if self.method in ["min", "max","mip"] or self._sum_only: + if self.method in ["min", "max", "mip"] or self._sum_only: path_length_unit = Unit(registry=self.ds.unit_registry) else: ax_name = self.ds.coordinates.axis_name[self.axis] From 33013123bdcbea1a51cbf2b9d7ac924d6de4109a Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:16:04 +0200 Subject: [PATCH 11/32] if/elif fixed (again...) --- doc/source/cookbook/simple_projection_methods.py | 2 +- yt/data_objects/construction_data_containers.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py index bb319b50b88..fdb0fd9f21a 100644 --- a/doc/source/cookbook/simple_projection_methods.py +++ b/doc/source/cookbook/simple_projection_methods.py @@ -1,7 +1,7 @@ import yt # Load the dataset. -ds = yt.load("GalaxyClusterMerger/fiducial_1to3_b0.273d_hdf5_plt_cnt_0175") +ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") # Create projections of temperature (with different methods) diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index 473b36f096f..ecc06d7fe90 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -190,6 +190,7 @@ def __init__( "The 'mip' method value is a deprecated alias for 'max'. " "Please use max directly.", since="4.1", + stacklevel=4, ) method = "max" if method == "sum": @@ -266,7 +267,7 @@ def get_data(self, fields=None): if self.method in ["max", "mip"]: merge_style = -1 op = "max" - if self.method == "min": + elif self.method == "min": merge_style = -2 op = "min" elif self.method == "integrate": From e515118077a6d091965cfb0260f06eb971845ca8 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:19:26 +0200 Subject: [PATCH 12/32] added min,max to test_plotwindow. Left mip in... --- yt/visualization/tests/test_plotwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/visualization/tests/test_plotwindow.py b/yt/visualization/tests/test_plotwindow.py index 9094eb9bd28..2a2ba0bee29 100644 --- a/yt/visualization/tests/test_plotwindow.py +++ b/yt/visualization/tests/test_plotwindow.py @@ -135,7 +135,7 @@ def setup(): ("gas", "density"), ) -PROJECTION_METHODS = ("integrate", "sum", "mip") +PROJECTION_METHODS = ("integrate", "sum", "mip", "min", "max") BUFF_SIZES = [(800, 800), (1600, 1600), (1254, 1254), (800, 600)] From b67ea678b1b060e9173006496aefb98f690219b3 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:22:05 +0200 Subject: [PATCH 13/32] changed mip to max in data_containers max method, both docstring and projection method call --- yt/data_objects/data_containers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yt/data_objects/data_containers.py b/yt/data_objects/data_containers.py index 78166d12c14..03197e0d37e 100644 --- a/yt/data_objects/data_containers.py +++ b/yt/data_objects/data_containers.py @@ -980,7 +980,7 @@ def max(self, field, axis=None): This will, in a parallel-aware fashion, compute the maximum of the given field. Supplying an axis will result in a return value of a - YTProjection, with method 'mip' for maximum intensity. If the max has + YTProjection, with method 'max' for maximum intensity. If the max has already been requested, it will use the cached extrema value. Parameters @@ -1006,7 +1006,7 @@ def max(self, field, axis=None): return rv[0] return rv elif axis in self.ds.coordinates.axis_name: - r = self.ds.proj(field, axis, data_source=self, method="mip") + r = self.ds.proj(field, axis, data_source=self, method="max") return r else: raise NotImplementedError(f"Unknown axis {axis}") From f1852d372472bc9b7d917336f539b6731da6db63 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:23:27 +0200 Subject: [PATCH 14/32] replaced 'mip' with 'max' in test_projection.py --- yt/data_objects/tests/test_projection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yt/data_objects/tests/test_projection.py b/yt/data_objects/tests/test_projection.py index 4f0b5777fa7..1947b9140ab 100644 --- a/yt/data_objects/tests/test_projection.py +++ b/yt/data_objects/tests/test_projection.py @@ -130,8 +130,8 @@ def test_projection(pf): def test_max_level(): ds = fake_amr_ds(fields=[("gas", "density")], units=["mp/cm**3"]) - proj = ds.proj(("gas", "density"), 2, method="mip", max_level=2) + proj = ds.proj(("gas", "density"), 2, method="max", max_level=2) assert proj[("index", "grid_level")].max() == 2 - proj = ds.proj(("gas", "density"), 2, method="mip") + proj = ds.proj(("gas", "density"), 2, method="max") assert proj[("index", "grid_level")].max() == ds.index.max_level From 7bbeef90eafe9be56459a5d6527afaf4e1ddb73b Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:27:14 +0200 Subject: [PATCH 15/32] added 'min' tests and replaced 'mip' with 'max' --- yt/data_objects/tests/test_numpy_ops.py | 12 ++++++++++-- yt/data_objects/tests/test_projection.py | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/yt/data_objects/tests/test_numpy_ops.py b/yt/data_objects/tests/test_numpy_ops.py index 709d55c32ae..ed3ab3562db 100644 --- a/yt/data_objects/tests/test_numpy_ops.py +++ b/yt/data_objects/tests/test_numpy_ops.py @@ -123,11 +123,19 @@ def test_min_max(): ) p = ad.max(("gas", "density"), axis=1) - p1 = ds.proj(("gas", "density"), 1, data_source=ad, method="mip") + p1 = ds.proj(("gas", "density"), 1, data_source=ad, method="max") + assert_equal(p[("gas", "density")], p1[("gas", "density")]) + + p = ad.min(("gas", "density"), axis=1) + p1 = ds.proj(("gas", "density"), 1, data_source=ad, method="min") assert_equal(p[("gas", "density")], p1[("gas", "density")]) p = ad.max(("gas", "density"), axis="y") - p1 = ds.proj(("gas", "density"), 1, data_source=ad, method="mip") + p1 = ds.proj(("gas", "density"), 1, data_source=ad, method="max") + assert_equal(p[("gas", "density")], p1[("gas", "density")]) + + p = ad.min(("gas", "density"), axis="y") + p1 = ds.proj(("gas", "density"), 1, data_source=ad, method="min") assert_equal(p[("gas", "density")], p1[("gas", "density")]) # Test that we can get multiple in a single pass diff --git a/yt/data_objects/tests/test_projection.py b/yt/data_objects/tests/test_projection.py index 1947b9140ab..6f96430a073 100644 --- a/yt/data_objects/tests/test_projection.py +++ b/yt/data_objects/tests/test_projection.py @@ -135,3 +135,6 @@ def test_max_level(): proj = ds.proj(("gas", "density"), 2, method="max") assert proj[("index", "grid_level")].max() == ds.index.max_level + + proj = ds.proj(("gas", "density"), 2, method="min") + assert proj[("index", "grid_level")].min() == ds.index.max_level From 1e0bc9c91a7cfc24d8a46f84f43a3330489ee179 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:28:45 +0200 Subject: [PATCH 16/32] changed 'mip' to 'max' in test_minimal_representation.py --- yt/utilities/tests/test_minimal_representation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/utilities/tests/test_minimal_representation.py b/yt/utilities/tests/test_minimal_representation.py index 28d06be779f..95e07d0552e 100644 --- a/yt/utilities/tests/test_minimal_representation.py +++ b/yt/utilities/tests/test_minimal_representation.py @@ -34,7 +34,7 @@ def test_store(): assert_equal(proj2[field], proj2_c[field]) def fail_for_different_method(): - proj2_c = ds.proj(field, "z", data_source=sp, method="mip") + proj2_c = ds.proj(field, "z", data_source=sp, method="max") assert_equal(proj2[field], proj2_c[field]) # A note here: a unyt.exceptions.UnitOperationError is raised From 7f39367e0288710bb101aa5d2a36f5b26e8c3740 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:31:15 +0200 Subject: [PATCH 17/32] replace 'mip' with 'max' in cookbook/image_resolution.py --- doc/source/cookbook/image_resolution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/cookbook/image_resolution.py b/doc/source/cookbook/image_resolution.py index b00bc44f309..012388fe18b 100644 --- a/doc/source/cookbook/image_resolution.py +++ b/doc/source/cookbook/image_resolution.py @@ -20,7 +20,7 @@ # Create projections of the density (max value in each resolution element in the image): prj = yt.ProjectionPlot( - ds, "x", ("gas", "density"), method="mip", center="max", width=(100, "kpc") + ds, "x", ("gas", "density"), method="max", center="max", width=(100, "kpc") ) # nicen up the plot by using a better interpolation: From d60be43d9e78f18da90b2aceeb4f4e499928d1ba Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:32:44 +0200 Subject: [PATCH 18/32] added msg to NotImplementedError --- yt/utilities/lib/quad_tree.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/utilities/lib/quad_tree.pyx b/yt/utilities/lib/quad_tree.pyx index 2deedd1f875..fb3de91034c 100644 --- a/yt/utilities/lib/quad_tree.pyx +++ b/yt/utilities/lib/quad_tree.pyx @@ -127,7 +127,7 @@ cdef class QuadTree: elif method == "min": self.combine = QTN_min_value else: - raise NotImplementedError + raise NotImplementedError(f"Unknown projection method {self.method!r}") self.merged = 1 self.max_level = 0 cdef int i, j From e2bf6d94e86ef9ba0dbf445aceb3c9f4447bae21 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:38:38 +0200 Subject: [PATCH 19/32] added not implemented error msg --- yt/visualization/volume_rendering/old_camera.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/visualization/volume_rendering/old_camera.py b/yt/visualization/volume_rendering/old_camera.py index cc98517de42..860c935c5a1 100644 --- a/yt/visualization/volume_rendering/old_camera.py +++ b/yt/visualization/volume_rendering/old_camera.py @@ -1873,7 +1873,7 @@ def build_volume( ): if volume is None: if self.use_kd: - raise NotImplementedError + raise NotImplementedError(f"{self.use_kd} is not implemented yet.") volume = AMRKDTree( self.ds, l_max=l_max, From 88face7877b8ca8bd6abbc4c44cfd4a3506745b9 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:41:03 +0200 Subject: [PATCH 20/32] incorporating black-jupyter fixes --- yt/visualization/volume_rendering/transfer_functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yt/visualization/volume_rendering/transfer_functions.py b/yt/visualization/volume_rendering/transfer_functions.py index 53519adf807..765c7068733 100644 --- a/yt/visualization/volume_rendering/transfer_functions.py +++ b/yt/visualization/volume_rendering/transfer_functions.py @@ -935,7 +935,9 @@ class ProjectionTransferFunction(MultiVariateTransferFunction): def __init__(self, x_bounds=(-1e60, 1e60), n_fields=1): if n_fields > 3: - raise NotImplementedError + raise NotImplementedError( + f"supplied ${n_fields} but n_fields > 3 not implemented." + ) MultiVariateTransferFunction.__init__(self) # Strip units off of x_bounds, if any x_bounds = [np.float64(xb) for xb in x_bounds] From dadf8fe7a71e7ea113c64a23e7f23acef87ee63f Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:42:43 +0200 Subject: [PATCH 21/32] not implemented error msg added --- yt/visualization/volume_rendering/render_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/visualization/volume_rendering/render_source.py b/yt/visualization/volume_rendering/render_source.py index 06465cec2d7..3acd4ac7497 100644 --- a/yt/visualization/volume_rendering/render_source.py +++ b/yt/visualization/volume_rendering/render_source.py @@ -142,7 +142,7 @@ def create_volume_source(data_source, field): elif issubclass(index_class, OctreeIndex): return OctreeVolumeSource(data_source, field) else: - raise NotImplementedError + raise NotImplementedError(f"{index_class} not implemented yet") class VolumeSource(RenderSource, abc.ABC): From b6b1d19745c1ba239c433a1e61d52b7ddc2b4193 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:44:23 +0200 Subject: [PATCH 22/32] added msg to not implemented error...not as sure about this one --- yt/visualization/plot_modifications.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/visualization/plot_modifications.py b/yt/visualization/plot_modifications.py index bb07e0a11b2..71ffff6dc2f 100644 --- a/yt/visualization/plot_modifications.py +++ b/yt/visualization/plot_modifications.py @@ -91,7 +91,7 @@ def __init__(self, *args, **kwargs): pass def __call__(self, plot: CallbackWrapper): - raise NotImplementedError + raise NotImplementedError("PlotCallback __call__ not implemented yet") def _project_coords(self, plot, coord): """ From 893d9f2d14414e12e3785fef44dd0237bd1ae984 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 14:46:53 +0200 Subject: [PATCH 23/32] precommit fixes --- yt/frontends/gadget_fof/io.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yt/frontends/gadget_fof/io.py b/yt/frontends/gadget_fof/io.py index 7d5ecbfdf21..e6fb3517612 100644 --- a/yt/frontends/gadget_fof/io.py +++ b/yt/frontends/gadget_fof/io.py @@ -15,7 +15,9 @@ def __init__(self, ds): self.offset_fields = set() def _read_fluid_selection(self, chunks, selector, fields, size): - raise NotImplementedError + raise NotImplementedError( + "IOHandlerGadgetFOFHDF5 _read_fluid_selection not implemented yet" + ) def _read_particle_coords(self, chunks, ptf): # This will read chunks and yield the results. From 02a667dcd8f6e54edb2d47259b9571dd27509038 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Thu, 26 May 2022 16:07:58 +0200 Subject: [PATCH 24/32] removed msgs from not implemented errors in yt/visualization scripts --- doc/source/cookbook/simple_projection_methods.py | 2 +- yt/visualization/plot_modifications.py | 2 +- yt/visualization/volume_rendering/old_camera.py | 2 +- yt/visualization/volume_rendering/render_source.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/source/cookbook/simple_projection_methods.py b/doc/source/cookbook/simple_projection_methods.py index fdb0fd9f21a..bb319b50b88 100644 --- a/doc/source/cookbook/simple_projection_methods.py +++ b/doc/source/cookbook/simple_projection_methods.py @@ -1,7 +1,7 @@ import yt # Load the dataset. -ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") +ds = yt.load("GalaxyClusterMerger/fiducial_1to3_b0.273d_hdf5_plt_cnt_0175") # Create projections of temperature (with different methods) diff --git a/yt/visualization/plot_modifications.py b/yt/visualization/plot_modifications.py index 71ffff6dc2f..bb07e0a11b2 100644 --- a/yt/visualization/plot_modifications.py +++ b/yt/visualization/plot_modifications.py @@ -91,7 +91,7 @@ def __init__(self, *args, **kwargs): pass def __call__(self, plot: CallbackWrapper): - raise NotImplementedError("PlotCallback __call__ not implemented yet") + raise NotImplementedError def _project_coords(self, plot, coord): """ diff --git a/yt/visualization/volume_rendering/old_camera.py b/yt/visualization/volume_rendering/old_camera.py index 860c935c5a1..cc98517de42 100644 --- a/yt/visualization/volume_rendering/old_camera.py +++ b/yt/visualization/volume_rendering/old_camera.py @@ -1873,7 +1873,7 @@ def build_volume( ): if volume is None: if self.use_kd: - raise NotImplementedError(f"{self.use_kd} is not implemented yet.") + raise NotImplementedError volume = AMRKDTree( self.ds, l_max=l_max, diff --git a/yt/visualization/volume_rendering/render_source.py b/yt/visualization/volume_rendering/render_source.py index 3acd4ac7497..06465cec2d7 100644 --- a/yt/visualization/volume_rendering/render_source.py +++ b/yt/visualization/volume_rendering/render_source.py @@ -142,7 +142,7 @@ def create_volume_source(data_source, field): elif issubclass(index_class, OctreeIndex): return OctreeVolumeSource(data_source, field) else: - raise NotImplementedError(f"{index_class} not implemented yet") + raise NotImplementedError class VolumeSource(RenderSource, abc.ABC): From d489942918db8ce0a5584d8e4e72d33813647738 Mon Sep 17 00:00:00 2001 From: rjfarber Date: Fri, 27 May 2022 20:12:34 +0200 Subject: [PATCH 25/32] Update yt/visualization/tests/test_plotwindow.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Robert --- yt/visualization/tests/test_plotwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/visualization/tests/test_plotwindow.py b/yt/visualization/tests/test_plotwindow.py index 2a2ba0bee29..c599f347df6 100644 --- a/yt/visualization/tests/test_plotwindow.py +++ b/yt/visualization/tests/test_plotwindow.py @@ -135,7 +135,7 @@ def setup(): ("gas", "density"), ) -PROJECTION_METHODS = ("integrate", "sum", "mip", "min", "max") +PROJECTION_METHODS = ("integrate", "sum", "min", "max") BUFF_SIZES = [(800, 800), (1600, 1600), (1254, 1254), (800, 600)] From e848ae2d7cb77f3455cf3c92afb8f13eaae29834 Mon Sep 17 00:00:00 2001 From: rjfarber Date: Fri, 27 May 2022 20:15:38 +0200 Subject: [PATCH 26/32] Update yt/data_objects/data_containers.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Robert --- yt/data_objects/data_containers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yt/data_objects/data_containers.py b/yt/data_objects/data_containers.py index 03197e0d37e..abd973181cf 100644 --- a/yt/data_objects/data_containers.py +++ b/yt/data_objects/data_containers.py @@ -1006,8 +1006,7 @@ def max(self, field, axis=None): return rv[0] return rv elif axis in self.ds.coordinates.axis_name: - r = self.ds.proj(field, axis, data_source=self, method="max") - return r + return self.ds.proj(field, axis, data_source=self, method="max") else: raise NotImplementedError(f"Unknown axis {axis}") From 21344cba8f03e6c4969dda98d11dd948c1123289 Mon Sep 17 00:00:00 2001 From: rjfarber Date: Fri, 27 May 2022 20:17:11 +0200 Subject: [PATCH 27/32] Update yt/data_objects/tests/test_projection.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Robert --- yt/data_objects/tests/test_projection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yt/data_objects/tests/test_projection.py b/yt/data_objects/tests/test_projection.py index 6f96430a073..2e133878091 100644 --- a/yt/data_objects/tests/test_projection.py +++ b/yt/data_objects/tests/test_projection.py @@ -136,5 +136,8 @@ def test_max_level(): proj = ds.proj(("gas", "density"), 2, method="max") assert proj[("index", "grid_level")].max() == ds.index.max_level + +def test_min_level(): + ds = fake_amr_ds(fields=[("gas", "density")], units=["mp/cm**3"]) proj = ds.proj(("gas", "density"), 2, method="min") - assert proj[("index", "grid_level")].min() == ds.index.max_level + assert proj[("index", "grid_level")].min() == ds.index.min_level From 06ecc8b914acaf8263b3000bfd6429fd88af1b90 Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Fri, 27 May 2022 20:19:44 +0200 Subject: [PATCH 28/32] added assert in test_projection --- yt/data_objects/tests/test_projection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yt/data_objects/tests/test_projection.py b/yt/data_objects/tests/test_projection.py index 2e133878091..fe37cf2306e 100644 --- a/yt/data_objects/tests/test_projection.py +++ b/yt/data_objects/tests/test_projection.py @@ -140,4 +140,7 @@ def test_max_level(): def test_min_level(): ds = fake_amr_ds(fields=[("gas", "density")], units=["mp/cm**3"]) proj = ds.proj(("gas", "density"), 2, method="min") + assert proj[("index", "grid_level")].min() == 2 + + proj = ds.proj(("gas", "density"), 2, method="max") assert proj[("index", "grid_level")].min() == ds.index.min_level From 265c9a8374fb39de3fe1fe586d9c80f8ef1f7afb Mon Sep 17 00:00:00 2001 From: Ryan Farber Date: Fri, 27 May 2022 20:21:01 +0200 Subject: [PATCH 29/32] added min implementation --- yt/data_objects/data_containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/data_objects/data_containers.py b/yt/data_objects/data_containers.py index abd973181cf..536d166f933 100644 --- a/yt/data_objects/data_containers.py +++ b/yt/data_objects/data_containers.py @@ -1039,7 +1039,7 @@ def min(self, field, axis=None): return rv[0] return rv elif axis in self.ds.coordinates.axis_name: - raise NotImplementedError("Minimum intensity projection not implemented.") + return self.ds.proj(field, axis, data_source=self, method="min") else: raise NotImplementedError(f"Unknown axis {axis}") From 9d6dabbe556ac4a837c74508bded0ac0f90e4ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 27 May 2022 21:37:02 +0200 Subject: [PATCH 30/32] fix broken test --- yt/data_objects/tests/test_projection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt/data_objects/tests/test_projection.py b/yt/data_objects/tests/test_projection.py index fe37cf2306e..ed1ab6546b5 100644 --- a/yt/data_objects/tests/test_projection.py +++ b/yt/data_objects/tests/test_projection.py @@ -140,7 +140,7 @@ def test_max_level(): def test_min_level(): ds = fake_amr_ds(fields=[("gas", "density")], units=["mp/cm**3"]) proj = ds.proj(("gas", "density"), 2, method="min") - assert proj[("index", "grid_level")].min() == 2 + assert proj[("index", "grid_level")].min() == 0 proj = ds.proj(("gas", "density"), 2, method="max") assert proj[("index", "grid_level")].min() == ds.index.min_level From 0060e05652d21c77d82fa1dc9d6f87c03e788397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 27 May 2022 22:34:55 +0200 Subject: [PATCH 31/32] DEPR: add missing deprecation warning --- yt/visualization/plot_window.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index f9f41817f56..c362d070c1a 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -2264,6 +2264,13 @@ def __init__( *, axis=None, ): + if method == "mip": + issue_deprecation_warning( + "'mip' method is a deprecated alias for 'max'. " + "Please use method='max' directly.", + since="4.1.0", + ) + method = "max" # TODO: in yt 4.2, remove default values for normal and fields, drop axis kwarg normal = self._validate_init_args(normal=normal, fields=fields, axis=axis) normal = self.sanitize_normal_vector(ds, normal) From 0eec9147c9b5a127be0c25ce28190fc2f62058a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Fri, 27 May 2022 22:34:22 +0200 Subject: [PATCH 32/32] cleanup --- yt/data_objects/construction_data_containers.py | 4 ++-- yt/visualization/plot_window.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/yt/data_objects/construction_data_containers.py b/yt/data_objects/construction_data_containers.py index ecc06d7fe90..edb15125d99 100644 --- a/yt/data_objects/construction_data_containers.py +++ b/yt/data_objects/construction_data_containers.py @@ -361,7 +361,7 @@ def _initialize_projected_units(self, fields, chunk): # for future field accesses. finfo.units = str(chunk[field].units) field_unit = Unit(finfo.output_units, registry=self.ds.unit_registry) - if self.method in ["min", "max", "mip"] or self._sum_only: + if self.method in ("min", "max") or self._sum_only: path_length_unit = Unit(registry=self.ds.unit_registry) else: ax_name = self.ds.coordinates.axis_name[self.axis] @@ -572,7 +572,7 @@ def _handle_chunk(self, chunk, fields, tree): chunk.ires.size, get_memory_usage() / 1024.0, ) - if self.method in ["min", "max", "mip"] or self._sum_only: + if self.method in ("min", "max") or self._sum_only: dl = self.ds.quan(1.0, "") else: ax_name = self.ds.coordinates.axis_name[self.axis] diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index c362d070c1a..9243374ddf0 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -2204,7 +2204,6 @@ class AxisAlignedProjectionPlot(ProjectionPlot, PWViewerMPL): "integrate" with a weight_field specified : weight the requested field by the weighting field and integrate along the line of sight. - "mip" : pick out the maximum value of the field in the line of sight. "max" : pick out the maximum value of the field in the line of sight. "min" : pick out the minimum value of the field in the line of sight.