Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50a1846

Browse files
committed
Merge remote-tracking branch 'upstream/main' into roll-angle-units
2 parents acd21eb + 31a2e1e commit 50a1846

File tree

15 files changed

+71
-52
lines changed

15 files changed

+71
-52
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ commands:
103103
- run:
104104
name: Install Python dependencies
105105
command: |
106-
python -m pip install --user meson-python numpy pybind11 setuptools-scm
106+
python -m pip install --user -r requirements/dev/build-requirements.txt
107107
python -m pip install --user \
108108
numpy<< parameters.numpy_version >> \
109109
-r requirements/doc/doc-requirements.txt

.github/workflows/cibuildwheel.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
CIBW_SKIP: "*-musllinux_aarch64"
106106
CIBW_TEST_COMMAND: >-
107107
python {package}/ci/check_version_number.py
108+
MACOSX_DEPLOYMENT_TARGET: "10.12"
108109
MPL_DISABLE_FH4: "yes"
109110
strategy:
110111
matrix:
@@ -115,16 +116,10 @@ jobs:
115116
cibw_archs: "aarch64"
116117
- os: windows-latest
117118
cibw_archs: "auto64"
118-
- os: macos-11
119+
- os: macos-12
119120
cibw_archs: "x86_64"
120-
# NOTE: macos_target can be moved back into global environment after
121-
# meson-python 0.16.0 is released.
122-
macos_target: "10.12"
123121
- os: macos-14
124122
cibw_archs: "arm64"
125-
# NOTE: macos_target can be moved back into global environment after
126-
# meson-python 0.16.0 is released.
127-
macos_target: "11.0"
128123

129124
steps:
130125
- name: Set up QEMU
@@ -146,7 +141,6 @@ jobs:
146141
env:
147142
CIBW_BUILD: "cp312-*"
148143
CIBW_ARCHS: ${{ matrix.cibw_archs }}
149-
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
150144

151145
- name: Build wheels for CPython 3.11
152146
uses: pypa/cibuildwheel@711a3d017d0729f3edde18545fee967f03d65f65 # v2.18.0
@@ -155,7 +149,6 @@ jobs:
155149
env:
156150
CIBW_BUILD: "cp311-*"
157151
CIBW_ARCHS: ${{ matrix.cibw_archs }}
158-
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
159152

160153
- name: Build wheels for CPython 3.10
161154
uses: pypa/cibuildwheel@711a3d017d0729f3edde18545fee967f03d65f65 # v2.18.0
@@ -164,7 +157,6 @@ jobs:
164157
env:
165158
CIBW_BUILD: "cp310-*"
166159
CIBW_ARCHS: ${{ matrix.cibw_archs }}
167-
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
168160

169161
- name: Build wheels for CPython 3.9
170162
uses: pypa/cibuildwheel@711a3d017d0729f3edde18545fee967f03d65f65 # v2.18.0
@@ -173,7 +165,6 @@ jobs:
173165
env:
174166
CIBW_BUILD: "cp39-*"
175167
CIBW_ARCHS: ${{ matrix.cibw_archs }}
176-
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
177168

178169
- name: Build wheels for PyPy
179170
uses: pypa/cibuildwheel@711a3d017d0729f3edde18545fee967f03d65f65 # v2.18.0
@@ -182,7 +173,6 @@ jobs:
182173
env:
183174
CIBW_BUILD: "pp39-*"
184175
CIBW_ARCHS: ${{ matrix.cibw_archs }}
185-
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}"
186176
if: matrix.cibw_archs != 'aarch64'
187177

188178
- uses: actions/upload-artifact@v4

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
uses: github/codeql-action/init@v3
3333
with:
3434
languages: ${{ matrix.language }}
35-
setup-python-dependencies: false
3635

3736
- name: Build compiled code
3837
if: matrix.language == 'c-cpp'

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ stages:
135135
136136
- bash: |
137137
python -m pip install --upgrade pip
138-
python -m pip install --upgrade meson-python numpy pybind11 setuptools-scm
138+
python -m pip install --upgrade -r requirements/dev/build-requirements.txt
139139
python -m pip install -r requirements/testing/all.txt -r requirements/testing/extra.txt
140140
displayName: 'Install dependencies with pip'
141141

doc/api/prev_api_changes/api_changes_3.5.0/development.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ In order to avoid conflicting with the use of :file:`setup.cfg` by
7777
``setup.cfg`` to ``mplsetup.cfg``. The :file:`setup.cfg.template` has been
7878
correspondingly been renamed to :file:`mplsetup.cfg.template`.
7979

80-
Note that the path to this configuration file can still be set via the
81-
:envvar:`MPLSETUPCFG` environment variable, which allows one to keep using the
82-
same file before and after this change.
80+
Note that the path to this configuration file can still be set via the ``MPLSETUPCFG``
81+
environment variable, which allows one to keep using the same file before and after this
82+
change.

doc/install/environment_variables_faq.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ Environment variables
2929
used to find a base directory in which the :file:`matplotlib` subdirectory is
3030
created.
3131

32-
.. envvar:: MPLSETUPCFG
33-
34-
This optional variable can be set to the full path of a :file:`mplsetup.cfg`
35-
configuration file used to customize the Matplotlib build. By default, a
36-
:file:`mplsetup.cfg` file in the root of the Matplotlib source tree will be
37-
read. Supported build options are listed in :file:`mplsetup.cfg.template`.
38-
3932
.. envvar:: PATH
4033

4134
The list of directories searched to find executable programs.

doc/install/index.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,20 @@ Before trying to install Matplotlib, please install the :ref:`dependencies`.
121121
To build from a tarball, download the latest *tar.gz* release
122122
file from `the PyPI files page <https://pypi.org/project/matplotlib/>`_.
123123

124-
We provide a `mplsetup.cfg`_ file which you can use to customize the build
125-
process. For example, which default backend to use, whether some of the
126-
optional libraries that Matplotlib ships with are installed, and so on. This
127-
file will be particularly useful to those packaging Matplotlib.
128-
129-
.. _mplsetup.cfg: https://raw.githubusercontent.com/matplotlib/matplotlib/main/mplsetup.cfg.template
130-
131124
If you are building your own Matplotlib wheels (or sdists) on Windows, note
132125
that any DLLs that you copy into the source tree will be packaged too.
133126

134-
135127
Configure build and behavior defaults
136128
=====================================
137129

138-
Aspects of the build and install process and some behaviorial defaults of the
139-
library can be configured via:
130+
We provide a `meson.options`_ file containing options with which you can use to
131+
customize the build process. For example, which default backend to use, whether some of
132+
the optional libraries that Matplotlib ships with are installed, and so on. These
133+
options will be particularly useful to those packaging Matplotlib.
134+
135+
.. _meson.options: https://github.com/matplotlib/matplotlib/blob/main/meson.options
136+
137+
Aspects of some behaviorial defaults of the library can be configured via:
140138

141139
.. toctree::
142140
:maxdepth: 2

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _restore_foreground_window_at_end():
4444
try:
4545
yield
4646
finally:
47-
if mpl.rcParams['tk.window_focus']:
47+
if foreground and mpl.rcParams['tk.window_focus']:
4848
_c_internal_utils.Win32_SetForegroundWindow(foreground)
4949

5050

lib/matplotlib/pyplot.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -983,30 +983,42 @@ def figure(
983983
`~matplotlib.rcParams` defines the default values, which can be modified
984984
in the matplotlibrc file.
985985
"""
986+
allnums = get_fignums()
987+
986988
if isinstance(num, FigureBase):
987989
# type narrowed to `Figure | SubFigure` by combination of input and isinstance
988990
if num.canvas.manager is None:
989991
raise ValueError("The passed figure is not managed by pyplot")
992+
elif any([figsize, dpi, facecolor, edgecolor, not frameon,
993+
kwargs]) and num.canvas.manager.num in allnums:
994+
_api.warn_external(
995+
"Ignoring specified arguments in this call "
996+
f"because figure with num: {num.canvas.manager.num} already exists")
990997
_pylab_helpers.Gcf.set_active(num.canvas.manager)
991998
return num.figure
992999

993-
allnums = get_fignums()
9941000
next_num = max(allnums) + 1 if allnums else 1
9951001
fig_label = ''
9961002
if num is None:
9971003
num = next_num
998-
elif isinstance(num, str):
999-
fig_label = num
1000-
all_labels = get_figlabels()
1001-
if fig_label not in all_labels:
1002-
if fig_label == 'all':
1003-
_api.warn_external("close('all') closes all existing figures.")
1004-
num = next_num
1005-
else:
1006-
inum = all_labels.index(fig_label)
1007-
num = allnums[inum]
10081004
else:
1009-
num = int(num) # crude validation of num argument
1005+
if any([figsize, dpi, facecolor, edgecolor, not frameon,
1006+
kwargs]) and num in allnums:
1007+
_api.warn_external(
1008+
"Ignoring specified arguments in this call "
1009+
f"because figure with num: {num} already exists")
1010+
if isinstance(num, str):
1011+
fig_label = num
1012+
all_labels = get_figlabels()
1013+
if fig_label not in all_labels:
1014+
if fig_label == 'all':
1015+
_api.warn_external("close('all') closes all existing figures.")
1016+
num = next_num
1017+
else:
1018+
inum = all_labels.index(fig_label)
1019+
num = allnums[inum]
1020+
else:
1021+
num = int(num) # crude validation of num argument
10101022

10111023
# Type of "num" has narrowed to int, but mypy can't quite see it
10121024
manager = _pylab_helpers.Gcf.get_fig_manager(num) # type: ignore[arg-type]

lib/matplotlib/tests/test_pyplot.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,22 @@ def test_figure_hook():
457457
fig = plt.figure()
458458

459459
assert fig._test_was_here
460+
461+
462+
def test_multiple_same_figure_calls():
463+
fig = mpl.pyplot.figure(1, figsize=(1, 2))
464+
with pytest.warns(UserWarning, match="Ignoring specified arguments in this call"):
465+
fig2 = mpl.pyplot.figure(1, figsize=(3, 4))
466+
with pytest.warns(UserWarning, match="Ignoring specified arguments in this call"):
467+
mpl.pyplot.figure(fig, figsize=(5, 6))
468+
assert fig is fig2
469+
fig3 = mpl.pyplot.figure(1) # Checks for false warnings
470+
assert fig is fig3
471+
472+
473+
def test_close_all_warning():
474+
fig1 = plt.figure()
475+
476+
# Check that the warning is issued when 'all' is passed to plt.figure
477+
with pytest.warns(UserWarning, match="closes all existing figures"):
478+
fig2 = plt.figure("all")

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ install = ['--tags=data,python-runtime,runtime']
9595
[tool.setuptools_scm]
9696
version_scheme = "release-branch-semver"
9797
local_scheme = "node-and-date"
98-
write_to = "lib/matplotlib/_version.py"
9998
parentdir_prefix_version = "matplotlib-"
10099
fallback_version = "0.0+UNKNOWN"
101100

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pybind11
2+
meson-python
3+
numpy
4+
setuptools-scm

requirements/dev/dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-r build-requirements.txt
12
-r ../doc/doc-requirements.txt
23
-r ../testing/all.txt
34
-r ../testing/extra.txt

src/_c_internal_utils.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ static py::object
111111
mpl_GetForegroundWindow(void)
112112
{
113113
#ifdef _WIN32
114-
return py::capsule(GetForegroundWindow(), "HWND");
114+
if (HWND hwnd = GetForegroundWindow()) {
115+
return py::capsule(hwnd, "HWND");
116+
} else {
117+
return py::none();
118+
}
115119
#else
116120
return py::none();
117121
#endif

src/checkdep_freetype2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifdef __has_include
22
#if !__has_include(<ft2build.h>)
33
#error "FreeType version 2.3 or higher is required. \
4-
You may unset the system_freetype entry in mplsetup.cfg to let Matplotlib download it."
4+
You may set the system-freetype Meson build option to false to let Matplotlib download it."
55
#endif
66
#endif
77

@@ -15,5 +15,5 @@ You may unset the system_freetype entry in mplsetup.cfg to let Matplotlib downlo
1515
XSTR(FREETYPE_MAJOR) "." XSTR(FREETYPE_MINOR) "." XSTR(FREETYPE_PATCH) ".")
1616
#if FREETYPE_MAJOR << 16 + FREETYPE_MINOR << 8 + FREETYPE_PATCH < 0x020300
1717
#error "FreeType version 2.3 or higher is required. \
18-
You may unset the system_freetype entry in mplsetup.cfg to let Matplotlib download it."
18+
You may set the system-freetype Meson build option to false to let Matplotlib download it."
1919
#endif

0 commit comments

Comments
 (0)