Skip to content

Commit

Permalink
Merge pull request #4298 from neutrinoceros/manual_bps_4.1.4
Browse files Browse the repository at this point in the history
REL: Manual backports for 4.1.4
  • Loading branch information
matthewturk authored Jan 20, 2023
2 parents 9d80a07 + af19005 commit 4aaf1e2
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bleeding-edge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python (newest testable version)
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
# the '-dev' suffix allows to use alphas and betas if no final release is available yet
# this version should be upgraded as often as possible, typically once a year when numpy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

steps:
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repo (bare)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/type-checking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.7'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: install check-manifest
Expand Down
2 changes: 1 addition & 1 deletion doc/source/cookbook/multiplot_2x2.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
plot.cax = grid.cbar_axes[i]

# Finally, redraw the plot on the AxesGrid axes.
p._setup_plots()
p.render()

plt.savefig("multiplot_2x2.png")
2 changes: 1 addition & 1 deletion doc/source/cookbook/multiplot_2x2_coordaxes_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
plot.cax = grid.cbar_axes[1]

# Finally, redraw the plot.
p._setup_plots()
p.render()

plt.savefig("multiplot_2x2_coordaxes_slice.png")
2 changes: 1 addition & 1 deletion doc/source/cookbook/multiplot_2x2_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
plot.cax = grid.cbar_axes[i]

# Finally, this actually redraws the plot.
p._setup_plots()
p.render()

plt.savefig("multiplot_2x2_time_series.png")
4 changes: 2 additions & 2 deletions doc/source/cookbook/multiplot_phaseplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
plot.cax = grid.cbar_axes[i]

# Actually redraws the plot.
p._setup_plots()
p.render()

# Modify the axes properties **after** p._setup_plots() so that they
# Modify the axes properties **after** p.render() so that they
# are not overwritten.
plot.axes.xaxis.set_minor_locator(plt.LogLocator(base=10.0, subs=[2.0, 5.0, 8.0]))

Expand Down
2 changes: 1 addition & 1 deletion yt/frontends/flash/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def _parse_parameter_file(self):
dle = np.array([self.parameters[f"{ax}min"] for ax in "xyz"]).astype("float64")
dre = np.array([self.parameters[f"{ax}max"] for ax in "xyz"]).astype("float64")
if self.dimensionality < 3:
for d in [dimensionality] + list(range(3 - dimensionality)):
for d in range(self.dimensionality, 3):
if dle[d] == dre[d]:
mylog.warning(
"Identical domain left edge and right edges "
Expand Down
7 changes: 5 additions & 2 deletions yt/frontends/sdf/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ def _is_valid(cls, filename, *args, **kwargs):
# Grab a whole 4k page.
line = next(hreq.iter_content(4096))
elif os.path.isfile(sdf_header):
with open(sdf_header, encoding="ISO-8859-1") as f:
line = f.read(10).strip()
try:
with open(sdf_header, encoding="ISO-8859-1") as f:
line = f.read(10).strip()
except PermissionError:
return False
else:
return False
return line.startswith("# SDF")
2 changes: 1 addition & 1 deletion yt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def load(
yt.utilities.exceptions.YTAmbiguousDataType
If the data format matches more than one class of similar specilization levels.
"""
fn = os.fspath(fn)
fn = os.path.expanduser(fn)

if any(wildcard in fn for wildcard in "[]?!*"):
from yt.data_objects.time_series import DatasetSeries
Expand Down
20 changes: 11 additions & 9 deletions yt/visualization/base_plot_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
import warnings
from abc import ABC
from io import BytesIO
from typing import Optional, Tuple, Union
from typing import TYPE_CHECKING, Optional, Tuple, Union

import matplotlib
import numpy as np
from matplotlib.axis import Axis
from matplotlib.colors import LogNorm, Normalize, SymLogNorm
from matplotlib.figure import Figure
from matplotlib.ticker import LogFormatterMathtext
from packaging.version import Version

Expand All @@ -23,6 +21,10 @@
validate_image_name,
)

if TYPE_CHECKING:
from matplotlib.axis import Axis
from matplotlib.figure import Figure

BACKEND_SPECS = {
"GTK": ["backend_gtk", "FigureCanvasGTK", "FigureManagerGTK"],
"GTKAgg": ["backend_gtkagg", "FigureCanvasGTKAgg", None],
Expand Down Expand Up @@ -91,8 +93,8 @@ def __init__(
axrect,
*,
norm_handler: NormHandler,
figure: Optional[Figure] = None,
axes: Optional[Axis] = None,
figure: Optional["Figure"] = None,
axes: Optional["Axis"] = None,
):
"""Initialize PlotMPL class"""
import matplotlib.figure
Expand Down Expand Up @@ -198,7 +200,7 @@ def _set_font_properties(self, font_properties, font_color):
for label in self._get_labels():
label.set_fontproperties(font_properties)
if font_color is not None:
label.set_color(self.font_color)
label.set_color(font_color)

def _repr_png_(self):
from ._mpl_imports import FigureCanvasAgg
Expand All @@ -224,9 +226,9 @@ def __init__(
*,
norm_handler: NormHandler,
colorbar_handler: ColorbarHandler,
figure: Optional[Figure] = None,
axes: Optional[Axis] = None,
cax: Optional[Axis] = None,
figure: Optional["Figure"] = None,
axes: Optional["Axis"] = None,
cax: Optional["Axis"] = None,
):
"""Initialize ImagePlotMPL class object"""
self.colorbar_handler = colorbar_handler
Expand Down
16 changes: 16 additions & 0 deletions yt/visualization/tests/test_plotwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,19 @@ def test_invalid_swap_projection():
slc.set_mpl_projection("Robinson")
slc.swap_axes() # should raise mylog.warning and not toggle _swap_axes
assert slc._has_swapped_axes is False


def test_set_font():
# simply check that calling the set_font method doesn't raise an error
# https://github.com/yt-project/yt/issues/4263
ds = fake_amr_ds()
slc = SlicePlot(ds, "x", "Density")
slc.set_font(
{
"family": "sans-serif",
"style": "italic",
"weight": "bold",
"size": 24,
"color": "blue",
}
)

0 comments on commit 4aaf1e2

Please sign in to comment.