Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update code to Python 3.11#29840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
oscargus wants to merge1 commit intomatplotlib:mainfromoscargus:py311
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletionslib/matplotlib/_api/__init__.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
from typing import Any, TypeVar, overload
from typing_extensions import Self # < Py 3.11
from typing import Any, Self, TypeVar, overload

Check failure on line 2 in lib/matplotlib/_api/__init__.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Module "typing" has no attribute "Self" [attr-defined]Raw Output:lib/matplotlib/_api/__init__.pyi:2: error: Module "typing" has no attribute "Self" [attr-defined]

Check warning on line 2 in lib/matplotlib/_api/__init__.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Use `from typing_extensions import Self` insteadRaw Output:lib/matplotlib/_api/__init__.pyi:2: note: Use `from typing_extensions import Self` instead

Check warning on line 2 in lib/matplotlib/_api/__init__.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-moduleRaw Output:lib/matplotlib/_api/__init__.pyi:2: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module

from numpy.typing import NDArray

Expand Down
5 changes: 1 addition & 4 deletionslib/matplotlib/_api/deprecation.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
from collections.abc import Callable
import contextlib
from typing import Any, Literal, ParamSpec, TypedDict, TypeVar, overload
from typing_extensions import (
Unpack, # < Py 3.11
)
from typing import Any, Literal, ParamSpec, TypedDict, TypeVar, Unpack, overload

Check failure on line 3 in lib/matplotlib/_api/deprecation.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Module "typing" has no attribute "Unpack" [attr-defined]Raw Output:lib/matplotlib/_api/deprecation.pyi:3: error: Module "typing" has no attribute "Unpack" [attr-defined]

Check warning on line 3 in lib/matplotlib/_api/deprecation.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Use `from typing_extensions import Unpack` insteadRaw Output:lib/matplotlib/_api/deprecation.pyi:3: note: Use `from typing_extensions import Unpack` instead

Check warning on line 3 in lib/matplotlib/_api/deprecation.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-moduleRaw Output:lib/matplotlib/_api/deprecation.pyi:3: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module

_P = ParamSpec("_P")
_R = TypeVar("_R")
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1966,9 +1966,9 @@ class _MathStyle(enum.Enum):
""".split())
_delims = _left_delims | _right_delims | _ambi_delims

_small_greek =set([unicodedata.name(chr(i)).split()[-1].lower() for i in
_small_greek ={unicodedata.name(chr(i)).split()[-1].lower() for i in
range(ord('\N{GREEK SMALL LETTER ALPHA}'),
ord('\N{GREEK SMALL LETTER OMEGA}') + 1)])
ord('\N{GREEK SMALL LETTER OMEGA}') + 1)}
_latin_alphabets = set(string.ascii_letters)

def __init__(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4114,7 +4114,7 @@ def format_coord(self, x, y):
for ax in sorted(twins, key=attrgetter("zorder")):
data_x, data_y = ax.transData.inverted().transform(screen_xy)
xy_strs.append(
"({}, {})".format(ax.format_xdata(data_x),ax.format_ydata(data_y)))
f"({ax.format_xdata(data_x)}, {ax.format_ydata(data_y)})")
return "(x, y) = {}".format(" | ".join(xy_strs))

def minorticks_on(self):
Expand Down
3 changes: 1 addition & 2 deletionslib/matplotlib/axis.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
from collections.abc import Callable, Iterable, Sequence
import datetime
from typing import Any, Literal, overload
from typing_extensions import Self # < Py 3.11
from typing import Any, Literal, Self, overload

Check failure on line 3 in lib/matplotlib/axis.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Module "typing" has no attribute "Self" [attr-defined]Raw Output:lib/matplotlib/axis.pyi:3: error: Module "typing" has no attribute "Self" [attr-defined]

Check warning on line 3 in lib/matplotlib/axis.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Use `from typing_extensions import Self` insteadRaw Output:lib/matplotlib/axis.pyi:3: note: Use `from typing_extensions import Self` instead

Check warning on line 3 in lib/matplotlib/axis.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-moduleRaw Output:lib/matplotlib/axis.pyi:3: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module

import numpy as np
from numpy.typing import ArrayLike
Expand Down
11 changes: 6 additions & 5 deletionslib/matplotlib/backends/backend_pgf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,7 +121,7 @@ def _escape_and_apply_props(s, prop):
_log.warning("Ignoring unknown font: %s", family)

size = prop.get_size_in_points()
commands.append(r"\fontsize{%f}{%f}" %(size, size * 1.2))
commands.append(r"\fontsize{{{:f}}}{{{:f}}}".format(size, size * 1.2))

styles = {"normal": r"", "italic": r"\itshape", "oblique": r"\slshape"}
commands.append(styles[prop.get_style()])
Expand DownExpand Up@@ -416,7 +416,8 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans,
clip=clip):
x, y = point[0] * f, point[1] * f
_writeln(self.fh, r"\begin{pgfscope}")
_writeln(self.fh, r"\pgfsys@transformshift{%fin}{%fin}" % (x, y))
_writeln(self.fh,
r"\pgfsys@transformshift{{{:f}in}}{{{:f}in}}".format(x, y))
_writeln(self.fh, r"\pgfsys@useobject{currentmarker}{}")
_writeln(self.fh, r"\end{pgfscope}")

Expand DownExpand Up@@ -465,7 +466,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
ymin, ymax = f * ymin, f * ymax
repx, repy = math.ceil(xmax - xmin), math.ceil(ymax - ymin)
_writeln(self.fh,
r"\pgfsys@transformshift{%fin}{%fin}" %(xmin, ymin))
r"\pgfsys@transformshift{{{:f}in}}{{{:f}in}}".format(xmin, ymin))
for iy in range(repy):
for ix in range(repx):
_writeln(self.fh, r"\pgfsys@useobject{currentpattern}{}")
Expand DownExpand Up@@ -652,7 +653,7 @@ def draw_image(self, gc, x, y, im, transform=None):
f = 1. / self.dpi # from display coords to inch
if transform is None:
_writeln(self.fh,
r"\pgfsys@transformshift{%fin}{%fin}" %(x * f, y * f))
r"\pgfsys@transformshift{{{:f}in}}{{{:f}in}}".format(x * f, y * f))
w, h = w * f, h * f
else:
tr1, tr2, tr3, tr4, tr5, tr6 = transform.frozen().to_values()
Expand DownExpand Up@@ -718,7 +719,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
if angle != 0:
text_args.append("rotate=%f" % angle)

_writeln(self.fh, r"\pgftext[%s]{%s}" %(",".join(text_args), s))
_writeln(self.fh, r"\pgftext[{}]{{{}}}".format(",".join(text_args), s))
_writeln(self.fh, r"\end{pgfscope}")

def get_text_width_height_descent(self, s, prop, ismath):
Expand Down
14 changes: 7 additions & 7 deletionslib/matplotlib/backends/backend_ps.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,10 +151,10 @@ def _font_to_ps_type3(font_path, chars):
g = font.load_glyph(glyph_id, LoadFlags.NO_SCALE)
v, c = font.get_path()
entries.append(
"/%(name)s{%(bbox)s sc\n" % {
"name":font.get_glyph_name(glyph_id),
"bbox":" ".join(map(str, [g.horiAdvance, 0, *g.bbox])),
}
"/{name}{{{bbox} sc\n".format(
name=font.get_glyph_name(glyph_id),
bbox=" ".join(map(str, [g.horiAdvance, 0, *g.bbox])),
)
+ _path.convert_to_string(
# Convert back to TrueType's internal units (1/64's).
# (Other dimensions are already in these units.)
Expand DownExpand Up@@ -740,14 +740,14 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
'monospace': r'{\ttfamily %s}'}.get(
mpl.rcParams['font.family'][0], r'{\rmfamily %s}')
s = fontcmd % s
tex = r'\color[rgb]{%s} %s' %(color, s)
tex = r'\color[rgb]{{{}}} {}'.format(color, s)

# Stick to bottom-left alignment, so subtract descent from the text-normal
# direction since text is normally positioned by its baseline.
rangle = np.radians(angle + 90)
pos = _nums_to_str(x - bl * np.cos(rangle), y - bl * np.sin(rangle))
self.psfrag.append(
r'\psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}' %(
r'\psfrag{{{}}}[bl][bl][1][{:f}]{{\fontsize{{{:f}}}{{{:f}}}{}}}'.format(
thetext, angle, fontsize, fontsize*1.25, tex))

self._pswriter.write(f"""\
Expand DownExpand Up@@ -981,7 +981,7 @@ def _print_ps(
dsc_comments["CreationDate"] = (
datetime.datetime.fromtimestamp(
int(source_date_epoch),
datetime.timezone.utc).strftime("%a %b %d %H:%M:%S %Y")
datetime.UTC).strftime("%a %b %d %H:%M:%S %Y")
if source_date_epoch
else time.ctime())
dsc_comments = "\n".join(
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/backends/backend_svg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,7 +397,7 @@ def _write_metadata(self, metadata):
# See https://reproducible-builds.org/specs/source-date-epoch/
date = os.getenv("SOURCE_DATE_EPOCH")
if date:
date = datetime.datetime.fromtimestamp(int(date), datetime.timezone.utc)
date = datetime.datetime.fromtimestamp(int(date), datetime.UTC)
metadata['Date'] = date.replace(tzinfo=UTC).isoformat()
else:
metadata['Date'] = datetime.datetime.today().isoformat()
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/cbook.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,10 +14,10 @@ from typing import (
Generic,
IO,
Literal,
Sequence,
TypeVar,
overload,
)
from collections.abc import Sequence

_T = TypeVar("_T")

Expand Down
3 changes: 1 addition & 2 deletionslib/matplotlib/colors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1547,8 +1547,7 @@ def __getitem__(self, item):
return self._colormaps[item]

def __iter__(self):
for c in self._colormaps:
yield c
yield from self._colormaps

def __len__(self):
return len(self._colormaps)
Expand Down
6 changes: 3 additions & 3 deletionslib/matplotlib/dates.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -202,7 +202,7 @@


_log = logging.getLogger(__name__)
UTC = datetime.timezone.utc
UTC = datetime.UTC

Check failure on line 205 in lib/matplotlib/dates.py

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Module has no attribute "UTC" [attr-defined]Raw Output:lib/matplotlib/dates.py:205: error: Module has no attribute "UTC" [attr-defined]


def _get_tzinfo(tz=None):
Expand DownExpand Up@@ -1169,14 +1169,14 @@
except (ValueError, OverflowError):
# cap
start = datetime.datetime(1, 1, 1, 0, 0, 0,
tzinfo=datetime.timezone.utc)
tzinfo=datetime.UTC)

try:
stop = vmax + delta
except (ValueError, OverflowError):
# cap
stop = datetime.datetime(9999, 12, 31, 23, 59, 59,
tzinfo=datetime.timezone.utc)
tzinfo=datetime.UTC)

self.rule.set(dtstart=start, until=stop)

Expand Down
3 changes: 1 addition & 2 deletionslib/matplotlib/dviread.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,7 @@
from enum import Enum
from collections.abc import Generator

from typing import NamedTuple
from typing_extensions import Self # < Py 3.11
from typing import NamedTuple, Self

Check failure on line 7 in lib/matplotlib/dviread.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Module "typing" has no attribute "Self" [attr-defined]Raw Output:lib/matplotlib/dviread.pyi:7: error: Module "typing" has no attribute "Self" [attr-defined]

Check warning on line 7 in lib/matplotlib/dviread.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Use `from typing_extensions import Self` insteadRaw Output:lib/matplotlib/dviread.pyi:7: note: Use `from typing_extensions import Self` instead

Check warning on line 7 in lib/matplotlib/dviread.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-moduleRaw Output:lib/matplotlib/dviread.pyi:7: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module

class _dvistate(Enum):
pre = ...
Expand Down
3 changes: 1 addition & 2 deletionslib/matplotlib/sankey.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
from matplotlib.axes import Axes

from collections.abc import Callable, Iterable
from typing import Any
from typing_extensions import Self # < Py 3.11
from typing import Any, Self

Check failure on line 4 in lib/matplotlib/sankey.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Module "typing" has no attribute "Self" [attr-defined]Raw Output:lib/matplotlib/sankey.pyi:4: error: Module "typing" has no attribute "Self" [attr-defined]

Check warning on line 4 in lib/matplotlib/sankey.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶Use `from typing_extensions import Self` insteadRaw Output:lib/matplotlib/sankey.pyi:4: note: Use `from typing_extensions import Self` instead

Check warning on line 4 in lib/matplotlib/sankey.pyi

View workflow job for this annotation

GitHub Actions/ mypy

[mypy] reported by reviewdog 🐶See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-moduleRaw Output:lib/matplotlib/sankey.pyi:4: note: See https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-new-additions-to-the-typing-module

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/tests/test_api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@


if typing.TYPE_CHECKING:
fromtyping_extensions import Self
fromtyping import Self

T = TypeVar('T')

Expand Down
10 changes: 5 additions & 5 deletionslib/matplotlib/tests/test_dates.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -855,7 +855,7 @@ def _create_auto_date_locator(date1, date2, tz):
sts = [st.get_text() for st in ax.get_yticklabels()]
return sts, ax.yaxis.get_offset_text().get_text()

d1 = datetime.datetime(1997, 1, 1).replace(tzinfo=datetime.timezone.utc)
d1 = datetime.datetime(1997, 1, 1).replace(tzinfo=datetime.UTC)
results = ([datetime.timedelta(hours=40),
['03:00', '07:00', '11:00', '15:00', '19:00', '23:00',
'03:00', '07:00', '11:00', '15:00', '19:00'],
Expand DownExpand Up@@ -1310,8 +1310,8 @@ def test_DateLocator():
locator.create_dummy_axis()
# default values
assert locator.datalim_to_dt() == (
datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
datetime.datetime(1970, 1, 2, 0, 0, tzinfo=datetime.timezone.utc))
datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.UTC),
datetime.datetime(1970, 1, 2, 0, 0, tzinfo=datetime.UTC))

# Check default is UTC
assert locator.tz == mdates.UTC
Expand DownExpand Up@@ -1395,10 +1395,10 @@ def test_num2date_error(val):

def test_num2date_roundoff():
assert mdates.num2date(100000.0000578702) == datetime.datetime(
2243, 10, 17, 0, 0, 4, 999980, tzinfo=datetime.timezone.utc)
2243, 10, 17, 0, 0, 4, 999980, tzinfo=datetime.UTC)
# Slightly larger, steps of 20 microseconds
assert mdates.num2date(100000.0000578703) == datetime.datetime(
2243, 10, 17, 0, 0, 5, tzinfo=datetime.timezone.utc)
2243, 10, 17, 0, 0, 5, tzinfo=datetime.UTC)


def test_DateFormatter_settz():
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/tests/test_figure.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1349,7 +1349,7 @@ def test_subfigure():
fig.suptitle('Figure suptitle', fontsize='xx-large')

# below tests for the draw zorder of subfigures.
leg = fig.legend(handles=[plt.Line2D([0], [0], label='Line{}'.format(i))
leg = fig.legend(handles=[plt.Line2D([0], [0], label=f'Line{i}')
for i in range(5)], loc='center')
sub[0].set_zorder(leg.get_zorder() - 1)
sub[1].set_zorder(leg.get_zorder() + 1)
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/ticker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1086,7 +1086,7 @@

def _non_decade_format(self, sign_string, base, fx, usetex):
"""Return string for non-decade locations."""
return r'$\mathdefault{%s%s^{%.2f}}$' %(sign_string, base, fx)
return r'$\mathdefault{{{}{}^{{{:.2f}}}}}$'.format(sign_string, base, fx)

Check warning on line 1089 in lib/matplotlib/ticker.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/ticker.py#L1089

Added line #L1089 was not covered by tests

def __call__(self, x, pos=None):
# docstring inherited
Expand DownExpand Up@@ -1118,7 +1118,7 @@
base = '%s' % b

if abs(fx) < mpl.rcParams['axes.formatter.min_exponent']:
return r'$\mathdefault{%s%g}$' %(sign_string, x)
return r'$\mathdefault{{{}{:g}}}$'.format(sign_string, x)
elif not is_x_decade:
usetex = mpl.rcParams['text.usetex']
return self._non_decade_format(sign_string, base, fx, usetex)
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/typing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@
The ``typing`` module and type stub files are considered provisional and may change
at any time without a deprecation period.
"""
from collections.abc import Hashable, Sequence
from collections.abc importCallable,Hashable, Sequence
import pathlib
from typing import Any,Callable,Literal, TypeAlias, TypeVar, Union
from typing import Any, Literal, TypeAlias, TypeVar, Union

from . import path
from ._enums import JoinStyle, CapStyle
Expand Down
2 changes: 1 addition & 1 deletionlib/mpl_toolkits/mplot3d/axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4140,7 +4140,7 @@ def __eq__(self, other):
return (self.scalar == other.scalar) and (self.vector == other.vector).all

def __repr__(self):
return "_Quaternion({}, {})".format(repr(self.scalar),repr(self.vector))
returnf"_Quaternion({repr(self.scalar)}, {repr(self.vector)})"

@classmethod
def rotate_from_to(cls, r1, r2):
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp