ZTWHHH commited on
Commit
7962470
·
verified ·
1 Parent(s): 1160da1

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/INSTALLER +1 -0
  2. evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/LICENSE +202 -0
  3. evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/METADATA +74 -0
  4. evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/WHEEL +6 -0
  5. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/__init__.py +10 -0
  6. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/__pycache__/axes_grid.cpython-310.pyc +0 -0
  7. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/__pycache__/mpl_axes.cpython-310.pyc +0 -0
  8. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/anchored_artists.py +462 -0
  9. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_divider.py +694 -0
  10. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_grid.py +563 -0
  11. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_rgb.py +157 -0
  12. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/inset_locator.py +561 -0
  13. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/__init__.py +10 -0
  14. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/__pycache__/conftest.cpython-310.pyc +0 -0
  15. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/__pycache__/test_axes_grid1.cpython-310.pyc +0 -0
  16. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py +792 -0
  17. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/__init__.cpython-310.pyc +0 -0
  18. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/angle_helper.cpython-310.pyc +0 -0
  19. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axes_divider.cpython-310.pyc +0 -0
  20. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axes_grid.cpython-310.pyc +0 -0
  21. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axes_rgb.cpython-310.pyc +0 -0
  22. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axisline_style.cpython-310.pyc +0 -0
  23. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axislines.cpython-310.pyc +0 -0
  24. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/floating_axes.cpython-310.pyc +0 -0
  25. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/grid_finder.cpython-310.pyc +0 -0
  26. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/grid_helper_curvelinear.cpython-310.pyc +0 -0
  27. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/parasite_axes.cpython-310.pyc +0 -0
  28. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/axislines.py +483 -0
  29. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  30. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/conftest.cpython-310.pyc +0 -0
  31. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_angle_helper.cpython-310.pyc +0 -0
  32. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_axislines.cpython-310.pyc +0 -0
  33. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_floating_axes.cpython-310.pyc +0 -0
  34. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_grid_helper_curvelinear.cpython-310.pyc +0 -0
  35. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/conftest.py +2 -0
  36. evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/test_grid_finder.py +34 -0
  37. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/__init__.cpython-310.pyc +0 -0
  38. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/add.cpython-310.pyc +0 -0
  39. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/comparison.cpython-310.pyc +0 -0
  40. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/intersection.cpython-310.pyc +0 -0
  41. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/issubset.cpython-310.pyc +0 -0
  42. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/power.cpython-310.pyc +0 -0
  43. evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/union.cpython-310.pyc +0 -0
  44. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__init__.py +27 -0
  45. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autoasync.cpython-310.pyc +0 -0
  46. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/automain.cpython-310.pyc +0 -0
  47. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/errors.cpython-310.pyc +0 -0
  48. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autoasync.py +142 -0
  49. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autocommand.py +70 -0
  50. falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/automain.py +59 -0
evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/METADATA ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: google-cloud-core
3
+ Version: 2.4.1
4
+ Summary: Google Cloud API client core library
5
+ Home-page: https://github.com/googleapis/python-cloud-core
6
+ Author: Google LLC
7
+ Author-email: googleapis-packages@google.com
8
+ License: Apache 2.0
9
+ Platform: Posix; MacOS X; Windows
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Operating System :: OS Independent
22
+ Classifier: Topic :: Internet
23
+ Requires-Python: >=3.7
24
+ License-File: LICENSE
25
+ Requires-Dist: google-api-core !=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.6
26
+ Requires-Dist: google-auth <3.0dev,>=1.25.0
27
+ Requires-Dist: importlib-metadata >1.0.0 ; python_version < "3.8"
28
+ Provides-Extra: grpc
29
+ Requires-Dist: grpcio <2.0dev,>=1.38.0 ; extra == 'grpc'
30
+ Requires-Dist: grpcio-status <2.0.dev0,>=1.38.0 ; extra == 'grpc'
31
+
32
+ Core Helpers for Google Cloud Python Client Library
33
+ ===================================================
34
+
35
+ |pypi| |versions|
36
+
37
+ This library is not meant to stand-alone. Instead it defines
38
+ common helpers (e.g. base ``Client`` classes) used by all of the
39
+ ``google-cloud-*`` packages.
40
+
41
+
42
+ - `Documentation`_
43
+
44
+ .. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-core.svg
45
+ :target: https://pypi.org/project/google-cloud-core/
46
+ .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-core.svg
47
+ :target: https://pypi.org/project/google-cloud-core/
48
+ .. _Documentation: https://cloud.google.com/python/docs/reference/google-cloud-core/latest
49
+
50
+ Quick Start
51
+ -----------
52
+
53
+ .. code-block:: console
54
+
55
+ $ pip install --upgrade google-cloud-core
56
+
57
+ For more information on setting up your Python development environment,
58
+ such as installing ``pip`` and ``virtualenv`` on your system, please refer
59
+ to `Python Development Environment Setup Guide`_ for Google Cloud Platform.
60
+
61
+ .. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup
62
+
63
+
64
+ Supported Python Versions
65
+ -------------------------
66
+ Python >= 3.7
67
+
68
+ Unsupported Python Versions
69
+ ---------------------------
70
+ Python == 2.7: the last version of this library which supported Python 2.7
71
+ is ``google.cloud.core 1.7.2``.
72
+
73
+ Python == 3.6: the last version of this library which supported Python 3.6
74
+ is ``google.cloud.core 2.3.1``.
evalkit_tf437/lib/python3.10/site-packages/google_cloud_core-2.4.1.dist-info/WHEEL ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.41.3)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from . import axes_size as Size
2
+ from .axes_divider import Divider, SubplotDivider, make_axes_locatable
3
+ from .axes_grid import AxesGrid, Grid, ImageGrid
4
+
5
+ from .parasite_axes import host_subplot, host_axes
6
+
7
+ __all__ = ["Size",
8
+ "Divider", "SubplotDivider", "make_axes_locatable",
9
+ "AxesGrid", "Grid", "ImageGrid",
10
+ "host_subplot", "host_axes"]
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/__pycache__/axes_grid.cpython-310.pyc ADDED
Binary file (17.4 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/__pycache__/mpl_axes.cpython-310.pyc ADDED
Binary file (5.24 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/anchored_artists.py ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from matplotlib import _api, transforms
2
+ from matplotlib.offsetbox import (AnchoredOffsetbox, AuxTransformBox,
3
+ DrawingArea, TextArea, VPacker)
4
+ from matplotlib.patches import (Rectangle, Ellipse, ArrowStyle,
5
+ FancyArrowPatch, PathPatch)
6
+ from matplotlib.text import TextPath
7
+
8
+ __all__ = ['AnchoredDrawingArea', 'AnchoredAuxTransformBox',
9
+ 'AnchoredEllipse', 'AnchoredSizeBar', 'AnchoredDirectionArrows']
10
+
11
+
12
+ class AnchoredDrawingArea(AnchoredOffsetbox):
13
+ def __init__(self, width, height, xdescent, ydescent,
14
+ loc, pad=0.4, borderpad=0.5, prop=None, frameon=True,
15
+ **kwargs):
16
+ """
17
+ An anchored container with a fixed size and fillable `.DrawingArea`.
18
+
19
+ Artists added to the *drawing_area* will have their coordinates
20
+ interpreted as pixels. Any transformations set on the artists will be
21
+ overridden.
22
+
23
+ Parameters
24
+ ----------
25
+ width, height : float
26
+ Width and height of the container, in pixels.
27
+ xdescent, ydescent : float
28
+ Descent of the container in the x- and y- direction, in pixels.
29
+ loc : str
30
+ Location of this artist. Valid locations are
31
+ 'upper left', 'upper center', 'upper right',
32
+ 'center left', 'center', 'center right',
33
+ 'lower left', 'lower center', 'lower right'.
34
+ For backward compatibility, numeric values are accepted as well.
35
+ See the parameter *loc* of `.Legend` for details.
36
+ pad : float, default: 0.4
37
+ Padding around the child objects, in fraction of the font size.
38
+ borderpad : float, default: 0.5
39
+ Border padding, in fraction of the font size.
40
+ prop : `~matplotlib.font_manager.FontProperties`, optional
41
+ Font property used as a reference for paddings.
42
+ frameon : bool, default: True
43
+ If True, draw a box around this artist.
44
+ **kwargs
45
+ Keyword arguments forwarded to `.AnchoredOffsetbox`.
46
+
47
+ Attributes
48
+ ----------
49
+ drawing_area : `~matplotlib.offsetbox.DrawingArea`
50
+ A container for artists to display.
51
+
52
+ Examples
53
+ --------
54
+ To display blue and red circles of different sizes in the upper right
55
+ of an Axes *ax*:
56
+
57
+ >>> ada = AnchoredDrawingArea(20, 20, 0, 0,
58
+ ... loc='upper right', frameon=False)
59
+ >>> ada.drawing_area.add_artist(Circle((10, 10), 10, fc="b"))
60
+ >>> ada.drawing_area.add_artist(Circle((30, 10), 5, fc="r"))
61
+ >>> ax.add_artist(ada)
62
+ """
63
+ self.da = DrawingArea(width, height, xdescent, ydescent)
64
+ self.drawing_area = self.da
65
+
66
+ super().__init__(
67
+ loc, pad=pad, borderpad=borderpad, child=self.da, prop=None,
68
+ frameon=frameon, **kwargs
69
+ )
70
+
71
+
72
+ class AnchoredAuxTransformBox(AnchoredOffsetbox):
73
+ def __init__(self, transform, loc,
74
+ pad=0.4, borderpad=0.5, prop=None, frameon=True, **kwargs):
75
+ """
76
+ An anchored container with transformed coordinates.
77
+
78
+ Artists added to the *drawing_area* are scaled according to the
79
+ coordinates of the transformation used. The dimensions of this artist
80
+ will scale to contain the artists added.
81
+
82
+ Parameters
83
+ ----------
84
+ transform : `~matplotlib.transforms.Transform`
85
+ The transformation object for the coordinate system in use, i.e.,
86
+ :attr:`matplotlib.axes.Axes.transData`.
87
+ loc : str
88
+ Location of this artist. Valid locations are
89
+ 'upper left', 'upper center', 'upper right',
90
+ 'center left', 'center', 'center right',
91
+ 'lower left', 'lower center', 'lower right'.
92
+ For backward compatibility, numeric values are accepted as well.
93
+ See the parameter *loc* of `.Legend` for details.
94
+ pad : float, default: 0.4
95
+ Padding around the child objects, in fraction of the font size.
96
+ borderpad : float, default: 0.5
97
+ Border padding, in fraction of the font size.
98
+ prop : `~matplotlib.font_manager.FontProperties`, optional
99
+ Font property used as a reference for paddings.
100
+ frameon : bool, default: True
101
+ If True, draw a box around this artist.
102
+ **kwargs
103
+ Keyword arguments forwarded to `.AnchoredOffsetbox`.
104
+
105
+ Attributes
106
+ ----------
107
+ drawing_area : `~matplotlib.offsetbox.AuxTransformBox`
108
+ A container for artists to display.
109
+
110
+ Examples
111
+ --------
112
+ To display an ellipse in the upper left, with a width of 0.1 and
113
+ height of 0.4 in data coordinates:
114
+
115
+ >>> box = AnchoredAuxTransformBox(ax.transData, loc='upper left')
116
+ >>> el = Ellipse((0, 0), width=0.1, height=0.4, angle=30)
117
+ >>> box.drawing_area.add_artist(el)
118
+ >>> ax.add_artist(box)
119
+ """
120
+ self.drawing_area = AuxTransformBox(transform)
121
+
122
+ super().__init__(loc, pad=pad, borderpad=borderpad,
123
+ child=self.drawing_area, prop=prop, frameon=frameon,
124
+ **kwargs)
125
+
126
+
127
+ @_api.deprecated("3.8")
128
+ class AnchoredEllipse(AnchoredOffsetbox):
129
+ def __init__(self, transform, width, height, angle, loc,
130
+ pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs):
131
+ """
132
+ Draw an anchored ellipse of a given size.
133
+
134
+ Parameters
135
+ ----------
136
+ transform : `~matplotlib.transforms.Transform`
137
+ The transformation object for the coordinate system in use, i.e.,
138
+ :attr:`matplotlib.axes.Axes.transData`.
139
+ width, height : float
140
+ Width and height of the ellipse, given in coordinates of
141
+ *transform*.
142
+ angle : float
143
+ Rotation of the ellipse, in degrees, anti-clockwise.
144
+ loc : str
145
+ Location of the ellipse. Valid locations are
146
+ 'upper left', 'upper center', 'upper right',
147
+ 'center left', 'center', 'center right',
148
+ 'lower left', 'lower center', 'lower right'.
149
+ For backward compatibility, numeric values are accepted as well.
150
+ See the parameter *loc* of `.Legend` for details.
151
+ pad : float, default: 0.1
152
+ Padding around the ellipse, in fraction of the font size.
153
+ borderpad : float, default: 0.1
154
+ Border padding, in fraction of the font size.
155
+ frameon : bool, default: True
156
+ If True, draw a box around the ellipse.
157
+ prop : `~matplotlib.font_manager.FontProperties`, optional
158
+ Font property used as a reference for paddings.
159
+ **kwargs
160
+ Keyword arguments forwarded to `.AnchoredOffsetbox`.
161
+
162
+ Attributes
163
+ ----------
164
+ ellipse : `~matplotlib.patches.Ellipse`
165
+ Ellipse patch drawn.
166
+ """
167
+ self._box = AuxTransformBox(transform)
168
+ self.ellipse = Ellipse((0, 0), width, height, angle=angle)
169
+ self._box.add_artist(self.ellipse)
170
+
171
+ super().__init__(loc, pad=pad, borderpad=borderpad, child=self._box,
172
+ prop=prop, frameon=frameon, **kwargs)
173
+
174
+
175
+ class AnchoredSizeBar(AnchoredOffsetbox):
176
+ def __init__(self, transform, size, label, loc,
177
+ pad=0.1, borderpad=0.1, sep=2,
178
+ frameon=True, size_vertical=0, color='black',
179
+ label_top=False, fontproperties=None, fill_bar=None,
180
+ **kwargs):
181
+ """
182
+ Draw a horizontal scale bar with a center-aligned label underneath.
183
+
184
+ Parameters
185
+ ----------
186
+ transform : `~matplotlib.transforms.Transform`
187
+ The transformation object for the coordinate system in use, i.e.,
188
+ :attr:`matplotlib.axes.Axes.transData`.
189
+ size : float
190
+ Horizontal length of the size bar, given in coordinates of
191
+ *transform*.
192
+ label : str
193
+ Label to display.
194
+ loc : str
195
+ Location of the size bar. Valid locations are
196
+ 'upper left', 'upper center', 'upper right',
197
+ 'center left', 'center', 'center right',
198
+ 'lower left', 'lower center', 'lower right'.
199
+ For backward compatibility, numeric values are accepted as well.
200
+ See the parameter *loc* of `.Legend` for details.
201
+ pad : float, default: 0.1
202
+ Padding around the label and size bar, in fraction of the font
203
+ size.
204
+ borderpad : float, default: 0.1
205
+ Border padding, in fraction of the font size.
206
+ sep : float, default: 2
207
+ Separation between the label and the size bar, in points.
208
+ frameon : bool, default: True
209
+ If True, draw a box around the horizontal bar and label.
210
+ size_vertical : float, default: 0
211
+ Vertical length of the size bar, given in coordinates of
212
+ *transform*.
213
+ color : str, default: 'black'
214
+ Color for the size bar and label.
215
+ label_top : bool, default: False
216
+ If True, the label will be over the size bar.
217
+ fontproperties : `~matplotlib.font_manager.FontProperties`, optional
218
+ Font properties for the label text.
219
+ fill_bar : bool, optional
220
+ If True and if *size_vertical* is nonzero, the size bar will
221
+ be filled in with the color specified by the size bar.
222
+ Defaults to True if *size_vertical* is greater than
223
+ zero and False otherwise.
224
+ **kwargs
225
+ Keyword arguments forwarded to `.AnchoredOffsetbox`.
226
+
227
+ Attributes
228
+ ----------
229
+ size_bar : `~matplotlib.offsetbox.AuxTransformBox`
230
+ Container for the size bar.
231
+ txt_label : `~matplotlib.offsetbox.TextArea`
232
+ Container for the label of the size bar.
233
+
234
+ Notes
235
+ -----
236
+ If *prop* is passed as a keyword argument, but *fontproperties* is
237
+ not, then *prop* is assumed to be the intended *fontproperties*.
238
+ Using both *prop* and *fontproperties* is not supported.
239
+
240
+ Examples
241
+ --------
242
+ >>> import matplotlib.pyplot as plt
243
+ >>> import numpy as np
244
+ >>> from mpl_toolkits.axes_grid1.anchored_artists import (
245
+ ... AnchoredSizeBar)
246
+ >>> fig, ax = plt.subplots()
247
+ >>> ax.imshow(np.random.random((10, 10)))
248
+ >>> bar = AnchoredSizeBar(ax.transData, 3, '3 data units', 4)
249
+ >>> ax.add_artist(bar)
250
+ >>> fig.show()
251
+
252
+ Using all the optional parameters
253
+
254
+ >>> import matplotlib.font_manager as fm
255
+ >>> fontprops = fm.FontProperties(size=14, family='monospace')
256
+ >>> bar = AnchoredSizeBar(ax.transData, 3, '3 units', 4, pad=0.5,
257
+ ... sep=5, borderpad=0.5, frameon=False,
258
+ ... size_vertical=0.5, color='white',
259
+ ... fontproperties=fontprops)
260
+ """
261
+ if fill_bar is None:
262
+ fill_bar = size_vertical > 0
263
+
264
+ self.size_bar = AuxTransformBox(transform)
265
+ self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical,
266
+ fill=fill_bar, facecolor=color,
267
+ edgecolor=color))
268
+
269
+ if fontproperties is None and 'prop' in kwargs:
270
+ fontproperties = kwargs.pop('prop')
271
+
272
+ if fontproperties is None:
273
+ textprops = {'color': color}
274
+ else:
275
+ textprops = {'color': color, 'fontproperties': fontproperties}
276
+
277
+ self.txt_label = TextArea(label, textprops=textprops)
278
+
279
+ if label_top:
280
+ _box_children = [self.txt_label, self.size_bar]
281
+ else:
282
+ _box_children = [self.size_bar, self.txt_label]
283
+
284
+ self._box = VPacker(children=_box_children,
285
+ align="center",
286
+ pad=0, sep=sep)
287
+
288
+ super().__init__(loc, pad=pad, borderpad=borderpad, child=self._box,
289
+ prop=fontproperties, frameon=frameon, **kwargs)
290
+
291
+
292
+ class AnchoredDirectionArrows(AnchoredOffsetbox):
293
+ def __init__(self, transform, label_x, label_y, length=0.15,
294
+ fontsize=0.08, loc='upper left', angle=0, aspect_ratio=1,
295
+ pad=0.4, borderpad=0.4, frameon=False, color='w', alpha=1,
296
+ sep_x=0.01, sep_y=0, fontproperties=None, back_length=0.15,
297
+ head_width=10, head_length=15, tail_width=2,
298
+ text_props=None, arrow_props=None,
299
+ **kwargs):
300
+ """
301
+ Draw two perpendicular arrows to indicate directions.
302
+
303
+ Parameters
304
+ ----------
305
+ transform : `~matplotlib.transforms.Transform`
306
+ The transformation object for the coordinate system in use, i.e.,
307
+ :attr:`matplotlib.axes.Axes.transAxes`.
308
+ label_x, label_y : str
309
+ Label text for the x and y arrows
310
+ length : float, default: 0.15
311
+ Length of the arrow, given in coordinates of *transform*.
312
+ fontsize : float, default: 0.08
313
+ Size of label strings, given in coordinates of *transform*.
314
+ loc : str, default: 'upper left'
315
+ Location of the arrow. Valid locations are
316
+ 'upper left', 'upper center', 'upper right',
317
+ 'center left', 'center', 'center right',
318
+ 'lower left', 'lower center', 'lower right'.
319
+ For backward compatibility, numeric values are accepted as well.
320
+ See the parameter *loc* of `.Legend` for details.
321
+ angle : float, default: 0
322
+ The angle of the arrows in degrees.
323
+ aspect_ratio : float, default: 1
324
+ The ratio of the length of arrow_x and arrow_y.
325
+ Negative numbers can be used to change the direction.
326
+ pad : float, default: 0.4
327
+ Padding around the labels and arrows, in fraction of the font size.
328
+ borderpad : float, default: 0.4
329
+ Border padding, in fraction of the font size.
330
+ frameon : bool, default: False
331
+ If True, draw a box around the arrows and labels.
332
+ color : str, default: 'white'
333
+ Color for the arrows and labels.
334
+ alpha : float, default: 1
335
+ Alpha values of the arrows and labels
336
+ sep_x, sep_y : float, default: 0.01 and 0 respectively
337
+ Separation between the arrows and labels in coordinates of
338
+ *transform*.
339
+ fontproperties : `~matplotlib.font_manager.FontProperties`, optional
340
+ Font properties for the label text.
341
+ back_length : float, default: 0.15
342
+ Fraction of the arrow behind the arrow crossing.
343
+ head_width : float, default: 10
344
+ Width of arrow head, sent to `.ArrowStyle`.
345
+ head_length : float, default: 15
346
+ Length of arrow head, sent to `.ArrowStyle`.
347
+ tail_width : float, default: 2
348
+ Width of arrow tail, sent to `.ArrowStyle`.
349
+ text_props, arrow_props : dict
350
+ Properties of the text and arrows, passed to `.TextPath` and
351
+ `.FancyArrowPatch`.
352
+ **kwargs
353
+ Keyword arguments forwarded to `.AnchoredOffsetbox`.
354
+
355
+ Attributes
356
+ ----------
357
+ arrow_x, arrow_y : `~matplotlib.patches.FancyArrowPatch`
358
+ Arrow x and y
359
+ text_path_x, text_path_y : `~matplotlib.text.TextPath`
360
+ Path for arrow labels
361
+ p_x, p_y : `~matplotlib.patches.PathPatch`
362
+ Patch for arrow labels
363
+ box : `~matplotlib.offsetbox.AuxTransformBox`
364
+ Container for the arrows and labels.
365
+
366
+ Notes
367
+ -----
368
+ If *prop* is passed as a keyword argument, but *fontproperties* is
369
+ not, then *prop* is assumed to be the intended *fontproperties*.
370
+ Using both *prop* and *fontproperties* is not supported.
371
+
372
+ Examples
373
+ --------
374
+ >>> import matplotlib.pyplot as plt
375
+ >>> import numpy as np
376
+ >>> from mpl_toolkits.axes_grid1.anchored_artists import (
377
+ ... AnchoredDirectionArrows)
378
+ >>> fig, ax = plt.subplots()
379
+ >>> ax.imshow(np.random.random((10, 10)))
380
+ >>> arrows = AnchoredDirectionArrows(ax.transAxes, '111', '110')
381
+ >>> ax.add_artist(arrows)
382
+ >>> fig.show()
383
+
384
+ Using several of the optional parameters, creating downward pointing
385
+ arrow and high contrast text labels.
386
+
387
+ >>> import matplotlib.font_manager as fm
388
+ >>> fontprops = fm.FontProperties(family='monospace')
389
+ >>> arrows = AnchoredDirectionArrows(ax.transAxes, 'East', 'South',
390
+ ... loc='lower left', color='k',
391
+ ... aspect_ratio=-1, sep_x=0.02,
392
+ ... sep_y=-0.01,
393
+ ... text_props={'ec':'w', 'fc':'k'},
394
+ ... fontproperties=fontprops)
395
+ """
396
+ if arrow_props is None:
397
+ arrow_props = {}
398
+
399
+ if text_props is None:
400
+ text_props = {}
401
+
402
+ arrowstyle = ArrowStyle("Simple",
403
+ head_width=head_width,
404
+ head_length=head_length,
405
+ tail_width=tail_width)
406
+
407
+ if fontproperties is None and 'prop' in kwargs:
408
+ fontproperties = kwargs.pop('prop')
409
+
410
+ if 'color' not in arrow_props:
411
+ arrow_props['color'] = color
412
+
413
+ if 'alpha' not in arrow_props:
414
+ arrow_props['alpha'] = alpha
415
+
416
+ if 'color' not in text_props:
417
+ text_props['color'] = color
418
+
419
+ if 'alpha' not in text_props:
420
+ text_props['alpha'] = alpha
421
+
422
+ t_start = transform
423
+ t_end = t_start + transforms.Affine2D().rotate_deg(angle)
424
+
425
+ self.box = AuxTransformBox(t_end)
426
+
427
+ length_x = length
428
+ length_y = length*aspect_ratio
429
+
430
+ self.arrow_x = FancyArrowPatch(
431
+ (0, back_length*length_y),
432
+ (length_x, back_length*length_y),
433
+ arrowstyle=arrowstyle,
434
+ shrinkA=0.0,
435
+ shrinkB=0.0,
436
+ **arrow_props)
437
+
438
+ self.arrow_y = FancyArrowPatch(
439
+ (back_length*length_x, 0),
440
+ (back_length*length_x, length_y),
441
+ arrowstyle=arrowstyle,
442
+ shrinkA=0.0,
443
+ shrinkB=0.0,
444
+ **arrow_props)
445
+
446
+ self.box.add_artist(self.arrow_x)
447
+ self.box.add_artist(self.arrow_y)
448
+
449
+ text_path_x = TextPath((
450
+ length_x+sep_x, back_length*length_y+sep_y), label_x,
451
+ size=fontsize, prop=fontproperties)
452
+ self.p_x = PathPatch(text_path_x, transform=t_start, **text_props)
453
+ self.box.add_artist(self.p_x)
454
+
455
+ text_path_y = TextPath((
456
+ length_x*back_length+sep_x, length_y*(1-back_length)+sep_y),
457
+ label_y, size=fontsize, prop=fontproperties)
458
+ self.p_y = PathPatch(text_path_y, **text_props)
459
+ self.box.add_artist(self.p_y)
460
+
461
+ super().__init__(loc, pad=pad, borderpad=borderpad, child=self.box,
462
+ frameon=frameon, **kwargs)
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_divider.py ADDED
@@ -0,0 +1,694 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Helper classes to adjust the positions of multiple axes at drawing time.
3
+ """
4
+
5
+ import functools
6
+
7
+ import numpy as np
8
+
9
+ import matplotlib as mpl
10
+ from matplotlib import _api
11
+ from matplotlib.gridspec import SubplotSpec
12
+ import matplotlib.transforms as mtransforms
13
+ from . import axes_size as Size
14
+
15
+
16
+ class Divider:
17
+ """
18
+ An Axes positioning class.
19
+
20
+ The divider is initialized with lists of horizontal and vertical sizes
21
+ (:mod:`mpl_toolkits.axes_grid1.axes_size`) based on which a given
22
+ rectangular area will be divided.
23
+
24
+ The `new_locator` method then creates a callable object
25
+ that can be used as the *axes_locator* of the axes.
26
+ """
27
+
28
+ def __init__(self, fig, pos, horizontal, vertical,
29
+ aspect=None, anchor="C"):
30
+ """
31
+ Parameters
32
+ ----------
33
+ fig : Figure
34
+ pos : tuple of 4 floats
35
+ Position of the rectangle that will be divided.
36
+ horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
37
+ Sizes for horizontal division.
38
+ vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
39
+ Sizes for vertical division.
40
+ aspect : bool, optional
41
+ Whether overall rectangular area is reduced so that the relative
42
+ part of the horizontal and vertical scales have the same scale.
43
+ anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', \
44
+ 'NW', 'W'}, default: 'C'
45
+ Placement of the reduced rectangle, when *aspect* is True.
46
+ """
47
+
48
+ self._fig = fig
49
+ self._pos = pos
50
+ self._horizontal = horizontal
51
+ self._vertical = vertical
52
+ self._anchor = anchor
53
+ self.set_anchor(anchor)
54
+ self._aspect = aspect
55
+ self._xrefindex = 0
56
+ self._yrefindex = 0
57
+ self._locator = None
58
+
59
+ def get_horizontal_sizes(self, renderer):
60
+ return np.array([s.get_size(renderer) for s in self.get_horizontal()])
61
+
62
+ def get_vertical_sizes(self, renderer):
63
+ return np.array([s.get_size(renderer) for s in self.get_vertical()])
64
+
65
+ def set_position(self, pos):
66
+ """
67
+ Set the position of the rectangle.
68
+
69
+ Parameters
70
+ ----------
71
+ pos : tuple of 4 floats
72
+ position of the rectangle that will be divided
73
+ """
74
+ self._pos = pos
75
+
76
+ def get_position(self):
77
+ """Return the position of the rectangle."""
78
+ return self._pos
79
+
80
+ def set_anchor(self, anchor):
81
+ """
82
+ Parameters
83
+ ----------
84
+ anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', \
85
+ 'NW', 'W'}
86
+ Either an (*x*, *y*) pair of relative coordinates (0 is left or
87
+ bottom, 1 is right or top), 'C' (center), or a cardinal direction
88
+ ('SW', southwest, is bottom left, etc.).
89
+
90
+ See Also
91
+ --------
92
+ .Axes.set_anchor
93
+ """
94
+ if isinstance(anchor, str):
95
+ _api.check_in_list(mtransforms.Bbox.coefs, anchor=anchor)
96
+ elif not isinstance(anchor, (tuple, list)) or len(anchor) != 2:
97
+ raise TypeError("anchor must be str or 2-tuple")
98
+ self._anchor = anchor
99
+
100
+ def get_anchor(self):
101
+ """Return the anchor."""
102
+ return self._anchor
103
+
104
+ def get_subplotspec(self):
105
+ return None
106
+
107
+ def set_horizontal(self, h):
108
+ """
109
+ Parameters
110
+ ----------
111
+ h : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
112
+ sizes for horizontal division
113
+ """
114
+ self._horizontal = h
115
+
116
+ def get_horizontal(self):
117
+ """Return horizontal sizes."""
118
+ return self._horizontal
119
+
120
+ def set_vertical(self, v):
121
+ """
122
+ Parameters
123
+ ----------
124
+ v : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`
125
+ sizes for vertical division
126
+ """
127
+ self._vertical = v
128
+
129
+ def get_vertical(self):
130
+ """Return vertical sizes."""
131
+ return self._vertical
132
+
133
+ def set_aspect(self, aspect=False):
134
+ """
135
+ Parameters
136
+ ----------
137
+ aspect : bool
138
+ """
139
+ self._aspect = aspect
140
+
141
+ def get_aspect(self):
142
+ """Return aspect."""
143
+ return self._aspect
144
+
145
+ def set_locator(self, _locator):
146
+ self._locator = _locator
147
+
148
+ def get_locator(self):
149
+ return self._locator
150
+
151
+ def get_position_runtime(self, ax, renderer):
152
+ if self._locator is None:
153
+ return self.get_position()
154
+ else:
155
+ return self._locator(ax, renderer).bounds
156
+
157
+ @staticmethod
158
+ def _calc_k(sizes, total):
159
+ # sizes is a (n, 2) array of (rel_size, abs_size); this method finds
160
+ # the k factor such that sum(rel_size * k + abs_size) == total.
161
+ rel_sum, abs_sum = sizes.sum(0)
162
+ return (total - abs_sum) / rel_sum if rel_sum else 0
163
+
164
+ @staticmethod
165
+ def _calc_offsets(sizes, k):
166
+ # Apply k factors to (n, 2) sizes array of (rel_size, abs_size); return
167
+ # the resulting cumulative offset positions.
168
+ return np.cumsum([0, *(sizes @ [k, 1])])
169
+
170
+ def new_locator(self, nx, ny, nx1=None, ny1=None):
171
+ """
172
+ Return an axes locator callable for the specified cell.
173
+
174
+ Parameters
175
+ ----------
176
+ nx, nx1 : int
177
+ Integers specifying the column-position of the
178
+ cell. When *nx1* is None, a single *nx*-th column is
179
+ specified. Otherwise, location of columns spanning between *nx*
180
+ to *nx1* (but excluding *nx1*-th column) is specified.
181
+ ny, ny1 : int
182
+ Same as *nx* and *nx1*, but for row positions.
183
+ """
184
+ if nx1 is None:
185
+ nx1 = nx + 1
186
+ if ny1 is None:
187
+ ny1 = ny + 1
188
+ # append_size("left") adds a new size at the beginning of the
189
+ # horizontal size lists; this shift transforms e.g.
190
+ # new_locator(nx=2, ...) into effectively new_locator(nx=3, ...). To
191
+ # take that into account, instead of recording nx, we record
192
+ # nx-self._xrefindex, where _xrefindex is shifted by 1 by each
193
+ # append_size("left"), and re-add self._xrefindex back to nx in
194
+ # _locate, when the actual axes position is computed. Ditto for y.
195
+ xref = self._xrefindex
196
+ yref = self._yrefindex
197
+ locator = functools.partial(
198
+ self._locate, nx - xref, ny - yref, nx1 - xref, ny1 - yref)
199
+ locator.get_subplotspec = self.get_subplotspec
200
+ return locator
201
+
202
+ @_api.deprecated(
203
+ "3.8", alternative="divider.new_locator(...)(ax, renderer)")
204
+ def locate(self, nx, ny, nx1=None, ny1=None, axes=None, renderer=None):
205
+ """
206
+ Implementation of ``divider.new_locator().__call__``.
207
+
208
+ Parameters
209
+ ----------
210
+ nx, nx1 : int
211
+ Integers specifying the column-position of the cell. When *nx1* is
212
+ None, a single *nx*-th column is specified. Otherwise, the
213
+ location of columns spanning between *nx* to *nx1* (but excluding
214
+ *nx1*-th column) is specified.
215
+ ny, ny1 : int
216
+ Same as *nx* and *nx1*, but for row positions.
217
+ axes
218
+ renderer
219
+ """
220
+ xref = self._xrefindex
221
+ yref = self._yrefindex
222
+ return self._locate(
223
+ nx - xref, (nx + 1 if nx1 is None else nx1) - xref,
224
+ ny - yref, (ny + 1 if ny1 is None else ny1) - yref,
225
+ axes, renderer)
226
+
227
+ def _locate(self, nx, ny, nx1, ny1, axes, renderer):
228
+ """
229
+ Implementation of ``divider.new_locator().__call__``.
230
+
231
+ The axes locator callable returned by ``new_locator()`` is created as
232
+ a `functools.partial` of this method with *nx*, *ny*, *nx1*, and *ny1*
233
+ specifying the requested cell.
234
+ """
235
+ nx += self._xrefindex
236
+ nx1 += self._xrefindex
237
+ ny += self._yrefindex
238
+ ny1 += self._yrefindex
239
+
240
+ fig_w, fig_h = self._fig.bbox.size / self._fig.dpi
241
+ x, y, w, h = self.get_position_runtime(axes, renderer)
242
+
243
+ hsizes = self.get_horizontal_sizes(renderer)
244
+ vsizes = self.get_vertical_sizes(renderer)
245
+ k_h = self._calc_k(hsizes, fig_w * w)
246
+ k_v = self._calc_k(vsizes, fig_h * h)
247
+
248
+ if self.get_aspect():
249
+ k = min(k_h, k_v)
250
+ ox = self._calc_offsets(hsizes, k)
251
+ oy = self._calc_offsets(vsizes, k)
252
+
253
+ ww = (ox[-1] - ox[0]) / fig_w
254
+ hh = (oy[-1] - oy[0]) / fig_h
255
+ pb = mtransforms.Bbox.from_bounds(x, y, w, h)
256
+ pb1 = mtransforms.Bbox.from_bounds(x, y, ww, hh)
257
+ x0, y0 = pb1.anchored(self.get_anchor(), pb).p0
258
+
259
+ else:
260
+ ox = self._calc_offsets(hsizes, k_h)
261
+ oy = self._calc_offsets(vsizes, k_v)
262
+ x0, y0 = x, y
263
+
264
+ if nx1 is None:
265
+ nx1 = -1
266
+ if ny1 is None:
267
+ ny1 = -1
268
+
269
+ x1, w1 = x0 + ox[nx] / fig_w, (ox[nx1] - ox[nx]) / fig_w
270
+ y1, h1 = y0 + oy[ny] / fig_h, (oy[ny1] - oy[ny]) / fig_h
271
+
272
+ return mtransforms.Bbox.from_bounds(x1, y1, w1, h1)
273
+
274
+ def append_size(self, position, size):
275
+ _api.check_in_list(["left", "right", "bottom", "top"],
276
+ position=position)
277
+ if position == "left":
278
+ self._horizontal.insert(0, size)
279
+ self._xrefindex += 1
280
+ elif position == "right":
281
+ self._horizontal.append(size)
282
+ elif position == "bottom":
283
+ self._vertical.insert(0, size)
284
+ self._yrefindex += 1
285
+ else: # 'top'
286
+ self._vertical.append(size)
287
+
288
+ def add_auto_adjustable_area(self, use_axes, pad=0.1, adjust_dirs=None):
289
+ """
290
+ Add auto-adjustable padding around *use_axes* to take their decorations
291
+ (title, labels, ticks, ticklabels) into account during layout.
292
+
293
+ Parameters
294
+ ----------
295
+ use_axes : `~matplotlib.axes.Axes` or list of `~matplotlib.axes.Axes`
296
+ The Axes whose decorations are taken into account.
297
+ pad : float, default: 0.1
298
+ Additional padding in inches.
299
+ adjust_dirs : list of {"left", "right", "bottom", "top"}, optional
300
+ The sides where padding is added; defaults to all four sides.
301
+ """
302
+ if adjust_dirs is None:
303
+ adjust_dirs = ["left", "right", "bottom", "top"]
304
+ for d in adjust_dirs:
305
+ self.append_size(d, Size._AxesDecorationsSize(use_axes, d) + pad)
306
+
307
+
308
+ @_api.deprecated("3.8")
309
+ class AxesLocator:
310
+ """
311
+ A callable object which returns the position and size of a given
312
+ `.AxesDivider` cell.
313
+ """
314
+
315
+ def __init__(self, axes_divider, nx, ny, nx1=None, ny1=None):
316
+ """
317
+ Parameters
318
+ ----------
319
+ axes_divider : `~mpl_toolkits.axes_grid1.axes_divider.AxesDivider`
320
+ nx, nx1 : int
321
+ Integers specifying the column-position of the
322
+ cell. When *nx1* is None, a single *nx*-th column is
323
+ specified. Otherwise, location of columns spanning between *nx*
324
+ to *nx1* (but excluding *nx1*-th column) is specified.
325
+ ny, ny1 : int
326
+ Same as *nx* and *nx1*, but for row positions.
327
+ """
328
+ self._axes_divider = axes_divider
329
+
330
+ _xrefindex = axes_divider._xrefindex
331
+ _yrefindex = axes_divider._yrefindex
332
+
333
+ self._nx, self._ny = nx - _xrefindex, ny - _yrefindex
334
+
335
+ if nx1 is None:
336
+ nx1 = len(self._axes_divider)
337
+ if ny1 is None:
338
+ ny1 = len(self._axes_divider[0])
339
+
340
+ self._nx1 = nx1 - _xrefindex
341
+ self._ny1 = ny1 - _yrefindex
342
+
343
+ def __call__(self, axes, renderer):
344
+
345
+ _xrefindex = self._axes_divider._xrefindex
346
+ _yrefindex = self._axes_divider._yrefindex
347
+
348
+ return self._axes_divider.locate(self._nx + _xrefindex,
349
+ self._ny + _yrefindex,
350
+ self._nx1 + _xrefindex,
351
+ self._ny1 + _yrefindex,
352
+ axes,
353
+ renderer)
354
+
355
+ def get_subplotspec(self):
356
+ return self._axes_divider.get_subplotspec()
357
+
358
+
359
+ class SubplotDivider(Divider):
360
+ """
361
+ The Divider class whose rectangle area is specified as a subplot geometry.
362
+ """
363
+
364
+ def __init__(self, fig, *args, horizontal=None, vertical=None,
365
+ aspect=None, anchor='C'):
366
+ """
367
+ Parameters
368
+ ----------
369
+ fig : `~matplotlib.figure.Figure`
370
+
371
+ *args : tuple (*nrows*, *ncols*, *index*) or int
372
+ The array of subplots in the figure has dimensions ``(nrows,
373
+ ncols)``, and *index* is the index of the subplot being created.
374
+ *index* starts at 1 in the upper left corner and increases to the
375
+ right.
376
+
377
+ If *nrows*, *ncols*, and *index* are all single digit numbers, then
378
+ *args* can be passed as a single 3-digit number (e.g. 234 for
379
+ (2, 3, 4)).
380
+ horizontal : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional
381
+ Sizes for horizontal division.
382
+ vertical : list of :mod:`~mpl_toolkits.axes_grid1.axes_size`, optional
383
+ Sizes for vertical division.
384
+ aspect : bool, optional
385
+ Whether overall rectangular area is reduced so that the relative
386
+ part of the horizontal and vertical scales have the same scale.
387
+ anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', 'N', \
388
+ 'NW', 'W'}, default: 'C'
389
+ Placement of the reduced rectangle, when *aspect* is True.
390
+ """
391
+ self.figure = fig
392
+ super().__init__(fig, [0, 0, 1, 1],
393
+ horizontal=horizontal or [], vertical=vertical or [],
394
+ aspect=aspect, anchor=anchor)
395
+ self.set_subplotspec(SubplotSpec._from_subplot_args(fig, args))
396
+
397
+ def get_position(self):
398
+ """Return the bounds of the subplot box."""
399
+ return self.get_subplotspec().get_position(self.figure).bounds
400
+
401
+ def get_subplotspec(self):
402
+ """Get the SubplotSpec instance."""
403
+ return self._subplotspec
404
+
405
+ def set_subplotspec(self, subplotspec):
406
+ """Set the SubplotSpec instance."""
407
+ self._subplotspec = subplotspec
408
+ self.set_position(subplotspec.get_position(self.figure))
409
+
410
+
411
+ class AxesDivider(Divider):
412
+ """
413
+ Divider based on the preexisting axes.
414
+ """
415
+
416
+ def __init__(self, axes, xref=None, yref=None):
417
+ """
418
+ Parameters
419
+ ----------
420
+ axes : :class:`~matplotlib.axes.Axes`
421
+ xref
422
+ yref
423
+ """
424
+ self._axes = axes
425
+ if xref is None:
426
+ self._xref = Size.AxesX(axes)
427
+ else:
428
+ self._xref = xref
429
+ if yref is None:
430
+ self._yref = Size.AxesY(axes)
431
+ else:
432
+ self._yref = yref
433
+
434
+ super().__init__(fig=axes.get_figure(), pos=None,
435
+ horizontal=[self._xref], vertical=[self._yref],
436
+ aspect=None, anchor="C")
437
+
438
+ def _get_new_axes(self, *, axes_class=None, **kwargs):
439
+ axes = self._axes
440
+ if axes_class is None:
441
+ axes_class = type(axes)
442
+ return axes_class(axes.get_figure(), axes.get_position(original=True),
443
+ **kwargs)
444
+
445
+ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
446
+ """
447
+ Helper method for ``append_axes("left")`` and ``append_axes("right")``.
448
+
449
+ See the documentation of `append_axes` for more details.
450
+
451
+ :meta private:
452
+ """
453
+ if pad is None:
454
+ pad = mpl.rcParams["figure.subplot.wspace"] * self._xref
455
+ pos = "left" if pack_start else "right"
456
+ if pad:
457
+ if not isinstance(pad, Size._Base):
458
+ pad = Size.from_any(pad, fraction_ref=self._xref)
459
+ self.append_size(pos, pad)
460
+ if not isinstance(size, Size._Base):
461
+ size = Size.from_any(size, fraction_ref=self._xref)
462
+ self.append_size(pos, size)
463
+ locator = self.new_locator(
464
+ nx=0 if pack_start else len(self._horizontal) - 1,
465
+ ny=self._yrefindex)
466
+ ax = self._get_new_axes(**kwargs)
467
+ ax.set_axes_locator(locator)
468
+ return ax
469
+
470
+ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
471
+ """
472
+ Helper method for ``append_axes("top")`` and ``append_axes("bottom")``.
473
+
474
+ See the documentation of `append_axes` for more details.
475
+
476
+ :meta private:
477
+ """
478
+ if pad is None:
479
+ pad = mpl.rcParams["figure.subplot.hspace"] * self._yref
480
+ pos = "bottom" if pack_start else "top"
481
+ if pad:
482
+ if not isinstance(pad, Size._Base):
483
+ pad = Size.from_any(pad, fraction_ref=self._yref)
484
+ self.append_size(pos, pad)
485
+ if not isinstance(size, Size._Base):
486
+ size = Size.from_any(size, fraction_ref=self._yref)
487
+ self.append_size(pos, size)
488
+ locator = self.new_locator(
489
+ nx=self._xrefindex,
490
+ ny=0 if pack_start else len(self._vertical) - 1)
491
+ ax = self._get_new_axes(**kwargs)
492
+ ax.set_axes_locator(locator)
493
+ return ax
494
+
495
+ def append_axes(self, position, size, pad=None, *, axes_class=None,
496
+ **kwargs):
497
+ """
498
+ Add a new axes on a given side of the main axes.
499
+
500
+ Parameters
501
+ ----------
502
+ position : {"left", "right", "bottom", "top"}
503
+ Where the new axes is positioned relative to the main axes.
504
+ size : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
505
+ The axes width or height. float or str arguments are interpreted
506
+ as ``axes_size.from_any(size, AxesX(<main_axes>))`` for left or
507
+ right axes, and likewise with ``AxesY`` for bottom or top axes.
508
+ pad : :mod:`~mpl_toolkits.axes_grid1.axes_size` or float or str
509
+ Padding between the axes. float or str arguments are interpreted
510
+ as for *size*. Defaults to :rc:`figure.subplot.wspace` times the
511
+ main Axes width (left or right axes) or :rc:`figure.subplot.hspace`
512
+ times the main Axes height (bottom or top axes).
513
+ axes_class : subclass type of `~.axes.Axes`, optional
514
+ The type of the new axes. Defaults to the type of the main axes.
515
+ **kwargs
516
+ All extra keywords arguments are passed to the created axes.
517
+ """
518
+ create_axes, pack_start = _api.check_getitem({
519
+ "left": (self.new_horizontal, True),
520
+ "right": (self.new_horizontal, False),
521
+ "bottom": (self.new_vertical, True),
522
+ "top": (self.new_vertical, False),
523
+ }, position=position)
524
+ ax = create_axes(
525
+ size, pad, pack_start=pack_start, axes_class=axes_class, **kwargs)
526
+ self._fig.add_axes(ax)
527
+ return ax
528
+
529
+ def get_aspect(self):
530
+ if self._aspect is None:
531
+ aspect = self._axes.get_aspect()
532
+ if aspect == "auto":
533
+ return False
534
+ else:
535
+ return True
536
+ else:
537
+ return self._aspect
538
+
539
+ def get_position(self):
540
+ if self._pos is None:
541
+ bbox = self._axes.get_position(original=True)
542
+ return bbox.bounds
543
+ else:
544
+ return self._pos
545
+
546
+ def get_anchor(self):
547
+ if self._anchor is None:
548
+ return self._axes.get_anchor()
549
+ else:
550
+ return self._anchor
551
+
552
+ def get_subplotspec(self):
553
+ return self._axes.get_subplotspec()
554
+
555
+
556
+ # Helper for HBoxDivider/VBoxDivider.
557
+ # The variable names are written for a horizontal layout, but the calculations
558
+ # work identically for vertical layouts.
559
+ def _locate(x, y, w, h, summed_widths, equal_heights, fig_w, fig_h, anchor):
560
+
561
+ total_width = fig_w * w
562
+ max_height = fig_h * h
563
+
564
+ # Determine the k factors.
565
+ n = len(equal_heights)
566
+ eq_rels, eq_abss = equal_heights.T
567
+ sm_rels, sm_abss = summed_widths.T
568
+ A = np.diag([*eq_rels, 0])
569
+ A[:n, -1] = -1
570
+ A[-1, :-1] = sm_rels
571
+ B = [*(-eq_abss), total_width - sm_abss.sum()]
572
+ # A @ K = B: This finds factors {k_0, ..., k_{N-1}, H} so that
573
+ # eq_rel_i * k_i + eq_abs_i = H for all i: all axes have the same height
574
+ # sum(sm_rel_i * k_i + sm_abs_i) = total_width: fixed total width
575
+ # (foo_rel_i * k_i + foo_abs_i will end up being the size of foo.)
576
+ *karray, height = np.linalg.solve(A, B)
577
+ if height > max_height: # Additionally, upper-bound the height.
578
+ karray = (max_height - eq_abss) / eq_rels
579
+
580
+ # Compute the offsets corresponding to these factors.
581
+ ox = np.cumsum([0, *(sm_rels * karray + sm_abss)])
582
+ ww = (ox[-1] - ox[0]) / fig_w
583
+ h0_rel, h0_abs = equal_heights[0]
584
+ hh = (karray[0]*h0_rel + h0_abs) / fig_h
585
+ pb = mtransforms.Bbox.from_bounds(x, y, w, h)
586
+ pb1 = mtransforms.Bbox.from_bounds(x, y, ww, hh)
587
+ x0, y0 = pb1.anchored(anchor, pb).p0
588
+
589
+ return x0, y0, ox, hh
590
+
591
+
592
+ class HBoxDivider(SubplotDivider):
593
+ """
594
+ A `.SubplotDivider` for laying out axes horizontally, while ensuring that
595
+ they have equal heights.
596
+
597
+ Examples
598
+ --------
599
+ .. plot:: gallery/axes_grid1/demo_axes_hbox_divider.py
600
+ """
601
+
602
+ def new_locator(self, nx, nx1=None):
603
+ """
604
+ Create an axes locator callable for the specified cell.
605
+
606
+ Parameters
607
+ ----------
608
+ nx, nx1 : int
609
+ Integers specifying the column-position of the
610
+ cell. When *nx1* is None, a single *nx*-th column is
611
+ specified. Otherwise, location of columns spanning between *nx*
612
+ to *nx1* (but excluding *nx1*-th column) is specified.
613
+ """
614
+ return super().new_locator(nx, 0, nx1, 0)
615
+
616
+ def _locate(self, nx, ny, nx1, ny1, axes, renderer):
617
+ # docstring inherited
618
+ nx += self._xrefindex
619
+ nx1 += self._xrefindex
620
+ fig_w, fig_h = self._fig.bbox.size / self._fig.dpi
621
+ x, y, w, h = self.get_position_runtime(axes, renderer)
622
+ summed_ws = self.get_horizontal_sizes(renderer)
623
+ equal_hs = self.get_vertical_sizes(renderer)
624
+ x0, y0, ox, hh = _locate(
625
+ x, y, w, h, summed_ws, equal_hs, fig_w, fig_h, self.get_anchor())
626
+ if nx1 is None:
627
+ nx1 = -1
628
+ x1, w1 = x0 + ox[nx] / fig_w, (ox[nx1] - ox[nx]) / fig_w
629
+ y1, h1 = y0, hh
630
+ return mtransforms.Bbox.from_bounds(x1, y1, w1, h1)
631
+
632
+
633
+ class VBoxDivider(SubplotDivider):
634
+ """
635
+ A `.SubplotDivider` for laying out axes vertically, while ensuring that
636
+ they have equal widths.
637
+ """
638
+
639
+ def new_locator(self, ny, ny1=None):
640
+ """
641
+ Create an axes locator callable for the specified cell.
642
+
643
+ Parameters
644
+ ----------
645
+ ny, ny1 : int
646
+ Integers specifying the row-position of the
647
+ cell. When *ny1* is None, a single *ny*-th row is
648
+ specified. Otherwise, location of rows spanning between *ny*
649
+ to *ny1* (but excluding *ny1*-th row) is specified.
650
+ """
651
+ return super().new_locator(0, ny, 0, ny1)
652
+
653
+ def _locate(self, nx, ny, nx1, ny1, axes, renderer):
654
+ # docstring inherited
655
+ ny += self._yrefindex
656
+ ny1 += self._yrefindex
657
+ fig_w, fig_h = self._fig.bbox.size / self._fig.dpi
658
+ x, y, w, h = self.get_position_runtime(axes, renderer)
659
+ summed_hs = self.get_vertical_sizes(renderer)
660
+ equal_ws = self.get_horizontal_sizes(renderer)
661
+ y0, x0, oy, ww = _locate(
662
+ y, x, h, w, summed_hs, equal_ws, fig_h, fig_w, self.get_anchor())
663
+ if ny1 is None:
664
+ ny1 = -1
665
+ x1, w1 = x0, ww
666
+ y1, h1 = y0 + oy[ny] / fig_h, (oy[ny1] - oy[ny]) / fig_h
667
+ return mtransforms.Bbox.from_bounds(x1, y1, w1, h1)
668
+
669
+
670
+ def make_axes_locatable(axes):
671
+ divider = AxesDivider(axes)
672
+ locator = divider.new_locator(nx=0, ny=0)
673
+ axes.set_axes_locator(locator)
674
+
675
+ return divider
676
+
677
+
678
+ def make_axes_area_auto_adjustable(
679
+ ax, use_axes=None, pad=0.1, adjust_dirs=None):
680
+ """
681
+ Add auto-adjustable padding around *ax* to take its decorations (title,
682
+ labels, ticks, ticklabels) into account during layout, using
683
+ `.Divider.add_auto_adjustable_area`.
684
+
685
+ By default, padding is determined from the decorations of *ax*.
686
+ Pass *use_axes* to consider the decorations of other Axes instead.
687
+ """
688
+ if adjust_dirs is None:
689
+ adjust_dirs = ["left", "right", "bottom", "top"]
690
+ divider = make_axes_locatable(ax)
691
+ if use_axes is None:
692
+ use_axes = ax
693
+ divider.add_auto_adjustable_area(use_axes=use_axes, pad=pad,
694
+ adjust_dirs=adjust_dirs)
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_grid.py ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numbers import Number
2
+ import functools
3
+ from types import MethodType
4
+
5
+ import numpy as np
6
+
7
+ from matplotlib import _api, cbook
8
+ from matplotlib.gridspec import SubplotSpec
9
+
10
+ from .axes_divider import Size, SubplotDivider, Divider
11
+ from .mpl_axes import Axes, SimpleAxisArtist
12
+
13
+
14
+ class CbarAxesBase:
15
+ def __init__(self, *args, orientation, **kwargs):
16
+ self.orientation = orientation
17
+ super().__init__(*args, **kwargs)
18
+
19
+ def colorbar(self, mappable, **kwargs):
20
+ return self.figure.colorbar(
21
+ mappable, cax=self, location=self.orientation, **kwargs)
22
+
23
+ @_api.deprecated("3.8", alternative="ax.tick_params and colorbar.set_label")
24
+ def toggle_label(self, b):
25
+ axis = self.axis[self.orientation]
26
+ axis.toggle(ticklabels=b, label=b)
27
+
28
+
29
+ _cbaraxes_class_factory = cbook._make_class_factory(CbarAxesBase, "Cbar{}")
30
+
31
+
32
+ class Grid:
33
+ """
34
+ A grid of Axes.
35
+
36
+ In Matplotlib, the Axes location (and size) is specified in normalized
37
+ figure coordinates. This may not be ideal for images that needs to be
38
+ displayed with a given aspect ratio; for example, it is difficult to
39
+ display multiple images of a same size with some fixed padding between
40
+ them. AxesGrid can be used in such case.
41
+
42
+ Attributes
43
+ ----------
44
+ axes_all : list of Axes
45
+ A flat list of Axes. Note that you can also access this directly
46
+ from the grid. The following is equivalent ::
47
+
48
+ grid[i] == grid.axes_all[i]
49
+ len(grid) == len(grid.axes_all)
50
+
51
+ axes_column : list of list of Axes
52
+ A 2D list of Axes where the first index is the column. This results
53
+ in the usage pattern ``grid.axes_column[col][row]``.
54
+ axes_row : list of list of Axes
55
+ A 2D list of Axes where the first index is the row. This results
56
+ in the usage pattern ``grid.axes_row[row][col]``.
57
+ axes_llc : Axes
58
+ The Axes in the lower left corner.
59
+ ngrids : int
60
+ Number of Axes in the grid.
61
+ """
62
+
63
+ _defaultAxesClass = Axes
64
+
65
+ def __init__(self, fig,
66
+ rect,
67
+ nrows_ncols,
68
+ ngrids=None,
69
+ direction="row",
70
+ axes_pad=0.02,
71
+ *,
72
+ share_all=False,
73
+ share_x=True,
74
+ share_y=True,
75
+ label_mode="L",
76
+ axes_class=None,
77
+ aspect=False,
78
+ ):
79
+ """
80
+ Parameters
81
+ ----------
82
+ fig : `.Figure`
83
+ The parent figure.
84
+ rect : (float, float, float, float), (int, int, int), int, or \
85
+ `~.SubplotSpec`
86
+ The axes position, as a ``(left, bottom, width, height)`` tuple,
87
+ as a three-digit subplot position code (e.g., ``(1, 2, 1)`` or
88
+ ``121``), or as a `~.SubplotSpec`.
89
+ nrows_ncols : (int, int)
90
+ Number of rows and columns in the grid.
91
+ ngrids : int or None, default: None
92
+ If not None, only the first *ngrids* axes in the grid are created.
93
+ direction : {"row", "column"}, default: "row"
94
+ Whether axes are created in row-major ("row by row") or
95
+ column-major order ("column by column"). This also affects the
96
+ order in which axes are accessed using indexing (``grid[index]``).
97
+ axes_pad : float or (float, float), default: 0.02
98
+ Padding or (horizontal padding, vertical padding) between axes, in
99
+ inches.
100
+ share_all : bool, default: False
101
+ Whether all axes share their x- and y-axis. Overrides *share_x*
102
+ and *share_y*.
103
+ share_x : bool, default: True
104
+ Whether all axes of a column share their x-axis.
105
+ share_y : bool, default: True
106
+ Whether all axes of a row share their y-axis.
107
+ label_mode : {"L", "1", "all", "keep"}, default: "L"
108
+ Determines which axes will get tick labels:
109
+
110
+ - "L": All axes on the left column get vertical tick labels;
111
+ all axes on the bottom row get horizontal tick labels.
112
+ - "1": Only the bottom left axes is labelled.
113
+ - "all": All axes are labelled.
114
+ - "keep": Do not do anything.
115
+
116
+ axes_class : subclass of `matplotlib.axes.Axes`, default: `.mpl_axes.Axes`
117
+ The type of Axes to create.
118
+ aspect : bool, default: False
119
+ Whether the axes aspect ratio follows the aspect ratio of the data
120
+ limits.
121
+ """
122
+ self._nrows, self._ncols = nrows_ncols
123
+
124
+ if ngrids is None:
125
+ ngrids = self._nrows * self._ncols
126
+ else:
127
+ if not 0 < ngrids <= self._nrows * self._ncols:
128
+ raise ValueError(
129
+ "ngrids must be positive and not larger than nrows*ncols")
130
+
131
+ self.ngrids = ngrids
132
+
133
+ self._horiz_pad_size, self._vert_pad_size = map(
134
+ Size.Fixed, np.broadcast_to(axes_pad, 2))
135
+
136
+ _api.check_in_list(["column", "row"], direction=direction)
137
+ self._direction = direction
138
+
139
+ if axes_class is None:
140
+ axes_class = self._defaultAxesClass
141
+ elif isinstance(axes_class, (list, tuple)):
142
+ cls, kwargs = axes_class
143
+ axes_class = functools.partial(cls, **kwargs)
144
+
145
+ kw = dict(horizontal=[], vertical=[], aspect=aspect)
146
+ if isinstance(rect, (Number, SubplotSpec)):
147
+ self._divider = SubplotDivider(fig, rect, **kw)
148
+ elif len(rect) == 3:
149
+ self._divider = SubplotDivider(fig, *rect, **kw)
150
+ elif len(rect) == 4:
151
+ self._divider = Divider(fig, rect, **kw)
152
+ else:
153
+ raise TypeError("Incorrect rect format")
154
+
155
+ rect = self._divider.get_position()
156
+
157
+ axes_array = np.full((self._nrows, self._ncols), None, dtype=object)
158
+ for i in range(self.ngrids):
159
+ col, row = self._get_col_row(i)
160
+ if share_all:
161
+ sharex = sharey = axes_array[0, 0]
162
+ else:
163
+ sharex = axes_array[0, col] if share_x else None
164
+ sharey = axes_array[row, 0] if share_y else None
165
+ axes_array[row, col] = axes_class(
166
+ fig, rect, sharex=sharex, sharey=sharey)
167
+ self.axes_all = axes_array.ravel(
168
+ order="C" if self._direction == "row" else "F").tolist()
169
+ self.axes_column = axes_array.T.tolist()
170
+ self.axes_row = axes_array.tolist()
171
+ self.axes_llc = self.axes_column[0][-1]
172
+
173
+ self._init_locators()
174
+
175
+ for ax in self.axes_all:
176
+ fig.add_axes(ax)
177
+
178
+ self.set_label_mode(label_mode)
179
+
180
+ def _init_locators(self):
181
+ self._divider.set_horizontal(
182
+ [Size.Scaled(1), self._horiz_pad_size] * (self._ncols-1) + [Size.Scaled(1)])
183
+ self._divider.set_vertical(
184
+ [Size.Scaled(1), self._vert_pad_size] * (self._nrows-1) + [Size.Scaled(1)])
185
+ for i in range(self.ngrids):
186
+ col, row = self._get_col_row(i)
187
+ self.axes_all[i].set_axes_locator(
188
+ self._divider.new_locator(nx=2 * col, ny=2 * (self._nrows - 1 - row)))
189
+
190
+ def _get_col_row(self, n):
191
+ if self._direction == "column":
192
+ col, row = divmod(n, self._nrows)
193
+ else:
194
+ row, col = divmod(n, self._ncols)
195
+
196
+ return col, row
197
+
198
+ # Good to propagate __len__ if we have __getitem__
199
+ def __len__(self):
200
+ return len(self.axes_all)
201
+
202
+ def __getitem__(self, i):
203
+ return self.axes_all[i]
204
+
205
+ def get_geometry(self):
206
+ """
207
+ Return the number of rows and columns of the grid as (nrows, ncols).
208
+ """
209
+ return self._nrows, self._ncols
210
+
211
+ def set_axes_pad(self, axes_pad):
212
+ """
213
+ Set the padding between the axes.
214
+
215
+ Parameters
216
+ ----------
217
+ axes_pad : (float, float)
218
+ The padding (horizontal pad, vertical pad) in inches.
219
+ """
220
+ self._horiz_pad_size.fixed_size = axes_pad[0]
221
+ self._vert_pad_size.fixed_size = axes_pad[1]
222
+
223
+ def get_axes_pad(self):
224
+ """
225
+ Return the axes padding.
226
+
227
+ Returns
228
+ -------
229
+ hpad, vpad
230
+ Padding (horizontal pad, vertical pad) in inches.
231
+ """
232
+ return (self._horiz_pad_size.fixed_size,
233
+ self._vert_pad_size.fixed_size)
234
+
235
+ def set_aspect(self, aspect):
236
+ """Set the aspect of the SubplotDivider."""
237
+ self._divider.set_aspect(aspect)
238
+
239
+ def get_aspect(self):
240
+ """Return the aspect of the SubplotDivider."""
241
+ return self._divider.get_aspect()
242
+
243
+ def set_label_mode(self, mode):
244
+ """
245
+ Define which axes have tick labels.
246
+
247
+ Parameters
248
+ ----------
249
+ mode : {"L", "1", "all", "keep"}
250
+ The label mode:
251
+
252
+ - "L": All axes on the left column get vertical tick labels;
253
+ all axes on the bottom row get horizontal tick labels.
254
+ - "1": Only the bottom left axes is labelled.
255
+ - "all": All axes are labelled.
256
+ - "keep": Do not do anything.
257
+ """
258
+ _api.check_in_list(["all", "L", "1", "keep"], mode=mode)
259
+ is_last_row, is_first_col = (
260
+ np.mgrid[:self._nrows, :self._ncols] == [[[self._nrows - 1]], [[0]]])
261
+ if mode == "all":
262
+ bottom = left = np.full((self._nrows, self._ncols), True)
263
+ elif mode == "L":
264
+ bottom = is_last_row
265
+ left = is_first_col
266
+ elif mode == "1":
267
+ bottom = left = is_last_row & is_first_col
268
+ else:
269
+ return
270
+ for i in range(self._nrows):
271
+ for j in range(self._ncols):
272
+ ax = self.axes_row[i][j]
273
+ if isinstance(ax.axis, MethodType):
274
+ bottom_axis = SimpleAxisArtist(ax.xaxis, 1, ax.spines["bottom"])
275
+ left_axis = SimpleAxisArtist(ax.yaxis, 1, ax.spines["left"])
276
+ else:
277
+ bottom_axis = ax.axis["bottom"]
278
+ left_axis = ax.axis["left"]
279
+ bottom_axis.toggle(ticklabels=bottom[i, j], label=bottom[i, j])
280
+ left_axis.toggle(ticklabels=left[i, j], label=left[i, j])
281
+
282
+ def get_divider(self):
283
+ return self._divider
284
+
285
+ def set_axes_locator(self, locator):
286
+ self._divider.set_locator(locator)
287
+
288
+ def get_axes_locator(self):
289
+ return self._divider.get_locator()
290
+
291
+
292
+ class ImageGrid(Grid):
293
+ """
294
+ A grid of Axes for Image display.
295
+
296
+ This class is a specialization of `~.axes_grid1.axes_grid.Grid` for displaying a
297
+ grid of images. In particular, it forces all axes in a column to share their x-axis
298
+ and all axes in a row to share their y-axis. It further provides helpers to add
299
+ colorbars to some or all axes.
300
+ """
301
+
302
+ def __init__(self, fig,
303
+ rect,
304
+ nrows_ncols,
305
+ ngrids=None,
306
+ direction="row",
307
+ axes_pad=0.02,
308
+ *,
309
+ share_all=False,
310
+ aspect=True,
311
+ label_mode="L",
312
+ cbar_mode=None,
313
+ cbar_location="right",
314
+ cbar_pad=None,
315
+ cbar_size="5%",
316
+ cbar_set_cax=True,
317
+ axes_class=None,
318
+ ):
319
+ """
320
+ Parameters
321
+ ----------
322
+ fig : `.Figure`
323
+ The parent figure.
324
+ rect : (float, float, float, float) or int
325
+ The axes position, as a ``(left, bottom, width, height)`` tuple or
326
+ as a three-digit subplot position code (e.g., "121").
327
+ nrows_ncols : (int, int)
328
+ Number of rows and columns in the grid.
329
+ ngrids : int or None, default: None
330
+ If not None, only the first *ngrids* axes in the grid are created.
331
+ direction : {"row", "column"}, default: "row"
332
+ Whether axes are created in row-major ("row by row") or
333
+ column-major order ("column by column"). This also affects the
334
+ order in which axes are accessed using indexing (``grid[index]``).
335
+ axes_pad : float or (float, float), default: 0.02in
336
+ Padding or (horizontal padding, vertical padding) between axes, in
337
+ inches.
338
+ share_all : bool, default: False
339
+ Whether all axes share their x- and y-axis. Note that in any case,
340
+ all axes in a column share their x-axis and all axes in a row share
341
+ their y-axis.
342
+ aspect : bool, default: True
343
+ Whether the axes aspect ratio follows the aspect ratio of the data
344
+ limits.
345
+ label_mode : {"L", "1", "all"}, default: "L"
346
+ Determines which axes will get tick labels:
347
+
348
+ - "L": All axes on the left column get vertical tick labels;
349
+ all axes on the bottom row get horizontal tick labels.
350
+ - "1": Only the bottom left axes is labelled.
351
+ - "all": all axes are labelled.
352
+
353
+ cbar_mode : {"each", "single", "edge", None}, default: None
354
+ Whether to create a colorbar for "each" axes, a "single" colorbar
355
+ for the entire grid, colorbars only for axes on the "edge"
356
+ determined by *cbar_location*, or no colorbars. The colorbars are
357
+ stored in the :attr:`cbar_axes` attribute.
358
+ cbar_location : {"left", "right", "bottom", "top"}, default: "right"
359
+ cbar_pad : float, default: None
360
+ Padding between the image axes and the colorbar axes.
361
+ cbar_size : size specification (see `.Size.from_any`), default: "5%"
362
+ Colorbar size.
363
+ cbar_set_cax : bool, default: True
364
+ If True, each axes in the grid has a *cax* attribute that is bound
365
+ to associated *cbar_axes*.
366
+ axes_class : subclass of `matplotlib.axes.Axes`, default: None
367
+ """
368
+ _api.check_in_list(["each", "single", "edge", None],
369
+ cbar_mode=cbar_mode)
370
+ _api.check_in_list(["left", "right", "bottom", "top"],
371
+ cbar_location=cbar_location)
372
+ self._colorbar_mode = cbar_mode
373
+ self._colorbar_location = cbar_location
374
+ self._colorbar_pad = cbar_pad
375
+ self._colorbar_size = cbar_size
376
+ # The colorbar axes are created in _init_locators().
377
+
378
+ super().__init__(
379
+ fig, rect, nrows_ncols, ngrids,
380
+ direction=direction, axes_pad=axes_pad,
381
+ share_all=share_all, share_x=True, share_y=True, aspect=aspect,
382
+ label_mode=label_mode, axes_class=axes_class)
383
+
384
+ for ax in self.cbar_axes:
385
+ fig.add_axes(ax)
386
+
387
+ if cbar_set_cax:
388
+ if self._colorbar_mode == "single":
389
+ for ax in self.axes_all:
390
+ ax.cax = self.cbar_axes[0]
391
+ elif self._colorbar_mode == "edge":
392
+ for index, ax in enumerate(self.axes_all):
393
+ col, row = self._get_col_row(index)
394
+ if self._colorbar_location in ("left", "right"):
395
+ ax.cax = self.cbar_axes[row]
396
+ else:
397
+ ax.cax = self.cbar_axes[col]
398
+ else:
399
+ for ax, cax in zip(self.axes_all, self.cbar_axes):
400
+ ax.cax = cax
401
+
402
+ def _init_locators(self):
403
+ # Slightly abusing this method to inject colorbar creation into init.
404
+
405
+ if self._colorbar_pad is None:
406
+ # horizontal or vertical arrangement?
407
+ if self._colorbar_location in ("left", "right"):
408
+ self._colorbar_pad = self._horiz_pad_size.fixed_size
409
+ else:
410
+ self._colorbar_pad = self._vert_pad_size.fixed_size
411
+ self.cbar_axes = [
412
+ _cbaraxes_class_factory(self._defaultAxesClass)(
413
+ self.axes_all[0].figure, self._divider.get_position(),
414
+ orientation=self._colorbar_location)
415
+ for _ in range(self.ngrids)]
416
+
417
+ cb_mode = self._colorbar_mode
418
+ cb_location = self._colorbar_location
419
+
420
+ h = []
421
+ v = []
422
+
423
+ h_ax_pos = []
424
+ h_cb_pos = []
425
+ if cb_mode == "single" and cb_location in ("left", "bottom"):
426
+ if cb_location == "left":
427
+ sz = self._nrows * Size.AxesX(self.axes_llc)
428
+ h.append(Size.from_any(self._colorbar_size, sz))
429
+ h.append(Size.from_any(self._colorbar_pad, sz))
430
+ locator = self._divider.new_locator(nx=0, ny=0, ny1=-1)
431
+ elif cb_location == "bottom":
432
+ sz = self._ncols * Size.AxesY(self.axes_llc)
433
+ v.append(Size.from_any(self._colorbar_size, sz))
434
+ v.append(Size.from_any(self._colorbar_pad, sz))
435
+ locator = self._divider.new_locator(nx=0, nx1=-1, ny=0)
436
+ for i in range(self.ngrids):
437
+ self.cbar_axes[i].set_visible(False)
438
+ self.cbar_axes[0].set_axes_locator(locator)
439
+ self.cbar_axes[0].set_visible(True)
440
+
441
+ for col, ax in enumerate(self.axes_row[0]):
442
+ if h:
443
+ h.append(self._horiz_pad_size)
444
+
445
+ if ax:
446
+ sz = Size.AxesX(ax, aspect="axes", ref_ax=self.axes_all[0])
447
+ else:
448
+ sz = Size.AxesX(self.axes_all[0],
449
+ aspect="axes", ref_ax=self.axes_all[0])
450
+
451
+ if (cb_location == "left"
452
+ and (cb_mode == "each"
453
+ or (cb_mode == "edge" and col == 0))):
454
+ h_cb_pos.append(len(h))
455
+ h.append(Size.from_any(self._colorbar_size, sz))
456
+ h.append(Size.from_any(self._colorbar_pad, sz))
457
+
458
+ h_ax_pos.append(len(h))
459
+ h.append(sz)
460
+
461
+ if (cb_location == "right"
462
+ and (cb_mode == "each"
463
+ or (cb_mode == "edge" and col == self._ncols - 1))):
464
+ h.append(Size.from_any(self._colorbar_pad, sz))
465
+ h_cb_pos.append(len(h))
466
+ h.append(Size.from_any(self._colorbar_size, sz))
467
+
468
+ v_ax_pos = []
469
+ v_cb_pos = []
470
+ for row, ax in enumerate(self.axes_column[0][::-1]):
471
+ if v:
472
+ v.append(self._vert_pad_size)
473
+
474
+ if ax:
475
+ sz = Size.AxesY(ax, aspect="axes", ref_ax=self.axes_all[0])
476
+ else:
477
+ sz = Size.AxesY(self.axes_all[0],
478
+ aspect="axes", ref_ax=self.axes_all[0])
479
+
480
+ if (cb_location == "bottom"
481
+ and (cb_mode == "each"
482
+ or (cb_mode == "edge" and row == 0))):
483
+ v_cb_pos.append(len(v))
484
+ v.append(Size.from_any(self._colorbar_size, sz))
485
+ v.append(Size.from_any(self._colorbar_pad, sz))
486
+
487
+ v_ax_pos.append(len(v))
488
+ v.append(sz)
489
+
490
+ if (cb_location == "top"
491
+ and (cb_mode == "each"
492
+ or (cb_mode == "edge" and row == self._nrows - 1))):
493
+ v.append(Size.from_any(self._colorbar_pad, sz))
494
+ v_cb_pos.append(len(v))
495
+ v.append(Size.from_any(self._colorbar_size, sz))
496
+
497
+ for i in range(self.ngrids):
498
+ col, row = self._get_col_row(i)
499
+ locator = self._divider.new_locator(nx=h_ax_pos[col],
500
+ ny=v_ax_pos[self._nrows-1-row])
501
+ self.axes_all[i].set_axes_locator(locator)
502
+
503
+ if cb_mode == "each":
504
+ if cb_location in ("right", "left"):
505
+ locator = self._divider.new_locator(
506
+ nx=h_cb_pos[col], ny=v_ax_pos[self._nrows - 1 - row])
507
+
508
+ elif cb_location in ("top", "bottom"):
509
+ locator = self._divider.new_locator(
510
+ nx=h_ax_pos[col], ny=v_cb_pos[self._nrows - 1 - row])
511
+
512
+ self.cbar_axes[i].set_axes_locator(locator)
513
+ elif cb_mode == "edge":
514
+ if (cb_location == "left" and col == 0
515
+ or cb_location == "right" and col == self._ncols - 1):
516
+ locator = self._divider.new_locator(
517
+ nx=h_cb_pos[0], ny=v_ax_pos[self._nrows - 1 - row])
518
+ self.cbar_axes[row].set_axes_locator(locator)
519
+ elif (cb_location == "bottom" and row == self._nrows - 1
520
+ or cb_location == "top" and row == 0):
521
+ locator = self._divider.new_locator(nx=h_ax_pos[col],
522
+ ny=v_cb_pos[0])
523
+ self.cbar_axes[col].set_axes_locator(locator)
524
+
525
+ if cb_mode == "single":
526
+ if cb_location == "right":
527
+ sz = self._nrows * Size.AxesX(self.axes_llc)
528
+ h.append(Size.from_any(self._colorbar_pad, sz))
529
+ h.append(Size.from_any(self._colorbar_size, sz))
530
+ locator = self._divider.new_locator(nx=-2, ny=0, ny1=-1)
531
+ elif cb_location == "top":
532
+ sz = self._ncols * Size.AxesY(self.axes_llc)
533
+ v.append(Size.from_any(self._colorbar_pad, sz))
534
+ v.append(Size.from_any(self._colorbar_size, sz))
535
+ locator = self._divider.new_locator(nx=0, nx1=-1, ny=-2)
536
+ if cb_location in ("right", "top"):
537
+ for i in range(self.ngrids):
538
+ self.cbar_axes[i].set_visible(False)
539
+ self.cbar_axes[0].set_axes_locator(locator)
540
+ self.cbar_axes[0].set_visible(True)
541
+ elif cb_mode == "each":
542
+ for i in range(self.ngrids):
543
+ self.cbar_axes[i].set_visible(True)
544
+ elif cb_mode == "edge":
545
+ if cb_location in ("right", "left"):
546
+ count = self._nrows
547
+ else:
548
+ count = self._ncols
549
+ for i in range(count):
550
+ self.cbar_axes[i].set_visible(True)
551
+ for j in range(i + 1, self.ngrids):
552
+ self.cbar_axes[j].set_visible(False)
553
+ else:
554
+ for i in range(self.ngrids):
555
+ self.cbar_axes[i].set_visible(False)
556
+ self.cbar_axes[i].set_position([1., 1., 0.001, 0.001],
557
+ which="active")
558
+
559
+ self._divider.set_horizontal(h)
560
+ self._divider.set_vertical(v)
561
+
562
+
563
+ AxesGrid = ImageGrid
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/axes_rgb.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from types import MethodType
2
+
3
+ import numpy as np
4
+
5
+ from .axes_divider import make_axes_locatable, Size
6
+ from .mpl_axes import Axes, SimpleAxisArtist
7
+
8
+
9
+ def make_rgb_axes(ax, pad=0.01, axes_class=None, **kwargs):
10
+ """
11
+ Parameters
12
+ ----------
13
+ ax : `~matplotlib.axes.Axes`
14
+ Axes instance to create the RGB Axes in.
15
+ pad : float, optional
16
+ Fraction of the Axes height to pad.
17
+ axes_class : `matplotlib.axes.Axes` or None, optional
18
+ Axes class to use for the R, G, and B Axes. If None, use
19
+ the same class as *ax*.
20
+ **kwargs
21
+ Forwarded to *axes_class* init for the R, G, and B Axes.
22
+ """
23
+
24
+ divider = make_axes_locatable(ax)
25
+
26
+ pad_size = pad * Size.AxesY(ax)
27
+
28
+ xsize = ((1-2*pad)/3) * Size.AxesX(ax)
29
+ ysize = ((1-2*pad)/3) * Size.AxesY(ax)
30
+
31
+ divider.set_horizontal([Size.AxesX(ax), pad_size, xsize])
32
+ divider.set_vertical([ysize, pad_size, ysize, pad_size, ysize])
33
+
34
+ ax.set_axes_locator(divider.new_locator(0, 0, ny1=-1))
35
+
36
+ ax_rgb = []
37
+ if axes_class is None:
38
+ axes_class = type(ax)
39
+
40
+ for ny in [4, 2, 0]:
41
+ ax1 = axes_class(ax.get_figure(), ax.get_position(original=True),
42
+ sharex=ax, sharey=ax, **kwargs)
43
+ locator = divider.new_locator(nx=2, ny=ny)
44
+ ax1.set_axes_locator(locator)
45
+ for t in ax1.yaxis.get_ticklabels() + ax1.xaxis.get_ticklabels():
46
+ t.set_visible(False)
47
+ try:
48
+ for axis in ax1.axis.values():
49
+ axis.major_ticklabels.set_visible(False)
50
+ except AttributeError:
51
+ pass
52
+
53
+ ax_rgb.append(ax1)
54
+
55
+ fig = ax.get_figure()
56
+ for ax1 in ax_rgb:
57
+ fig.add_axes(ax1)
58
+
59
+ return ax_rgb
60
+
61
+
62
+ class RGBAxes:
63
+ """
64
+ 4-panel `~.Axes.imshow` (RGB, R, G, B).
65
+
66
+ Layout::
67
+
68
+ ┌───────────────┬─────┐
69
+ │ │ R │
70
+ │ ├─────┤
71
+ │ RGB │ G │
72
+ │ ├─────┤
73
+ │ │ B │
74
+ └───────────────┴─────┘
75
+
76
+ Subclasses can override the ``_defaultAxesClass`` attribute.
77
+ By default RGBAxes uses `.mpl_axes.Axes`.
78
+
79
+ Attributes
80
+ ----------
81
+ RGB : ``_defaultAxesClass``
82
+ The Axes object for the three-channel `~.Axes.imshow`.
83
+ R : ``_defaultAxesClass``
84
+ The Axes object for the red channel `~.Axes.imshow`.
85
+ G : ``_defaultAxesClass``
86
+ The Axes object for the green channel `~.Axes.imshow`.
87
+ B : ``_defaultAxesClass``
88
+ The Axes object for the blue channel `~.Axes.imshow`.
89
+ """
90
+
91
+ _defaultAxesClass = Axes
92
+
93
+ def __init__(self, *args, pad=0, **kwargs):
94
+ """
95
+ Parameters
96
+ ----------
97
+ pad : float, default: 0
98
+ Fraction of the Axes height to put as padding.
99
+ axes_class : `~matplotlib.axes.Axes`
100
+ Axes class to use. If not provided, ``_defaultAxesClass`` is used.
101
+ *args
102
+ Forwarded to *axes_class* init for the RGB Axes
103
+ **kwargs
104
+ Forwarded to *axes_class* init for the RGB, R, G, and B Axes
105
+ """
106
+ axes_class = kwargs.pop("axes_class", self._defaultAxesClass)
107
+ self.RGB = ax = axes_class(*args, **kwargs)
108
+ ax.get_figure().add_axes(ax)
109
+ self.R, self.G, self.B = make_rgb_axes(
110
+ ax, pad=pad, axes_class=axes_class, **kwargs)
111
+ # Set the line color and ticks for the axes.
112
+ for ax1 in [self.RGB, self.R, self.G, self.B]:
113
+ if isinstance(ax1.axis, MethodType):
114
+ ad = Axes.AxisDict(self)
115
+ ad.update(
116
+ bottom=SimpleAxisArtist(ax1.xaxis, 1, ax1.spines["bottom"]),
117
+ top=SimpleAxisArtist(ax1.xaxis, 2, ax1.spines["top"]),
118
+ left=SimpleAxisArtist(ax1.yaxis, 1, ax1.spines["left"]),
119
+ right=SimpleAxisArtist(ax1.yaxis, 2, ax1.spines["right"]))
120
+ else:
121
+ ad = ax1.axis
122
+ ad[:].line.set_color("w")
123
+ ad[:].major_ticks.set_markeredgecolor("w")
124
+
125
+ def imshow_rgb(self, r, g, b, **kwargs):
126
+ """
127
+ Create the four images {rgb, r, g, b}.
128
+
129
+ Parameters
130
+ ----------
131
+ r, g, b : array-like
132
+ The red, green, and blue arrays.
133
+ **kwargs
134
+ Forwarded to `~.Axes.imshow` calls for the four images.
135
+
136
+ Returns
137
+ -------
138
+ rgb : `~matplotlib.image.AxesImage`
139
+ r : `~matplotlib.image.AxesImage`
140
+ g : `~matplotlib.image.AxesImage`
141
+ b : `~matplotlib.image.AxesImage`
142
+ """
143
+ if not (r.shape == g.shape == b.shape):
144
+ raise ValueError(
145
+ f'Input shapes ({r.shape}, {g.shape}, {b.shape}) do not match')
146
+ RGB = np.dstack([r, g, b])
147
+ R = np.zeros_like(RGB)
148
+ R[:, :, 0] = r
149
+ G = np.zeros_like(RGB)
150
+ G[:, :, 1] = g
151
+ B = np.zeros_like(RGB)
152
+ B[:, :, 2] = b
153
+ im_rgb = self.RGB.imshow(RGB, **kwargs)
154
+ im_r = self.R.imshow(R, **kwargs)
155
+ im_g = self.G.imshow(G, **kwargs)
156
+ im_b = self.B.imshow(B, **kwargs)
157
+ return im_rgb, im_r, im_g, im_b
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/inset_locator.py ADDED
@@ -0,0 +1,561 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A collection of functions and objects for creating or placing inset axes.
3
+ """
4
+
5
+ from matplotlib import _api, _docstring
6
+ from matplotlib.offsetbox import AnchoredOffsetbox
7
+ from matplotlib.patches import Patch, Rectangle
8
+ from matplotlib.path import Path
9
+ from matplotlib.transforms import Bbox, BboxTransformTo
10
+ from matplotlib.transforms import IdentityTransform, TransformedBbox
11
+
12
+ from . import axes_size as Size
13
+ from .parasite_axes import HostAxes
14
+
15
+
16
+ @_api.deprecated("3.8", alternative="Axes.inset_axes")
17
+ class InsetPosition:
18
+ @_docstring.dedent_interpd
19
+ def __init__(self, parent, lbwh):
20
+ """
21
+ An object for positioning an inset axes.
22
+
23
+ This is created by specifying the normalized coordinates in the axes,
24
+ instead of the figure.
25
+
26
+ Parameters
27
+ ----------
28
+ parent : `~matplotlib.axes.Axes`
29
+ Axes to use for normalizing coordinates.
30
+
31
+ lbwh : iterable of four floats
32
+ The left edge, bottom edge, width, and height of the inset axes, in
33
+ units of the normalized coordinate of the *parent* axes.
34
+
35
+ See Also
36
+ --------
37
+ :meth:`matplotlib.axes.Axes.set_axes_locator`
38
+
39
+ Examples
40
+ --------
41
+ The following bounds the inset axes to a box with 20%% of the parent
42
+ axes height and 40%% of the width. The size of the axes specified
43
+ ([0, 0, 1, 1]) ensures that the axes completely fills the bounding box:
44
+
45
+ >>> parent_axes = plt.gca()
46
+ >>> ax_ins = plt.axes([0, 0, 1, 1])
47
+ >>> ip = InsetPosition(parent_axes, [0.5, 0.1, 0.4, 0.2])
48
+ >>> ax_ins.set_axes_locator(ip)
49
+ """
50
+ self.parent = parent
51
+ self.lbwh = lbwh
52
+
53
+ def __call__(self, ax, renderer):
54
+ bbox_parent = self.parent.get_position(original=False)
55
+ trans = BboxTransformTo(bbox_parent)
56
+ bbox_inset = Bbox.from_bounds(*self.lbwh)
57
+ bb = TransformedBbox(bbox_inset, trans)
58
+ return bb
59
+
60
+
61
+ class AnchoredLocatorBase(AnchoredOffsetbox):
62
+ def __init__(self, bbox_to_anchor, offsetbox, loc,
63
+ borderpad=0.5, bbox_transform=None):
64
+ super().__init__(
65
+ loc, pad=0., child=None, borderpad=borderpad,
66
+ bbox_to_anchor=bbox_to_anchor, bbox_transform=bbox_transform
67
+ )
68
+
69
+ def draw(self, renderer):
70
+ raise RuntimeError("No draw method should be called")
71
+
72
+ def __call__(self, ax, renderer):
73
+ if renderer is None:
74
+ renderer = ax.figure._get_renderer()
75
+ self.axes = ax
76
+ bbox = self.get_window_extent(renderer)
77
+ px, py = self.get_offset(bbox.width, bbox.height, 0, 0, renderer)
78
+ bbox_canvas = Bbox.from_bounds(px, py, bbox.width, bbox.height)
79
+ tr = ax.figure.transSubfigure.inverted()
80
+ return TransformedBbox(bbox_canvas, tr)
81
+
82
+
83
+ class AnchoredSizeLocator(AnchoredLocatorBase):
84
+ def __init__(self, bbox_to_anchor, x_size, y_size, loc,
85
+ borderpad=0.5, bbox_transform=None):
86
+ super().__init__(
87
+ bbox_to_anchor, None, loc,
88
+ borderpad=borderpad, bbox_transform=bbox_transform
89
+ )
90
+
91
+ self.x_size = Size.from_any(x_size)
92
+ self.y_size = Size.from_any(y_size)
93
+
94
+ def get_bbox(self, renderer):
95
+ bbox = self.get_bbox_to_anchor()
96
+ dpi = renderer.points_to_pixels(72.)
97
+
98
+ r, a = self.x_size.get_size(renderer)
99
+ width = bbox.width * r + a * dpi
100
+ r, a = self.y_size.get_size(renderer)
101
+ height = bbox.height * r + a * dpi
102
+
103
+ fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
104
+ pad = self.pad * fontsize
105
+
106
+ return Bbox.from_bounds(0, 0, width, height).padded(pad)
107
+
108
+
109
+ class AnchoredZoomLocator(AnchoredLocatorBase):
110
+ def __init__(self, parent_axes, zoom, loc,
111
+ borderpad=0.5,
112
+ bbox_to_anchor=None,
113
+ bbox_transform=None):
114
+ self.parent_axes = parent_axes
115
+ self.zoom = zoom
116
+ if bbox_to_anchor is None:
117
+ bbox_to_anchor = parent_axes.bbox
118
+ super().__init__(
119
+ bbox_to_anchor, None, loc, borderpad=borderpad,
120
+ bbox_transform=bbox_transform)
121
+
122
+ def get_bbox(self, renderer):
123
+ bb = self.parent_axes.transData.transform_bbox(self.axes.viewLim)
124
+ fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
125
+ pad = self.pad * fontsize
126
+ return (
127
+ Bbox.from_bounds(
128
+ 0, 0, abs(bb.width * self.zoom), abs(bb.height * self.zoom))
129
+ .padded(pad))
130
+
131
+
132
+ class BboxPatch(Patch):
133
+ @_docstring.dedent_interpd
134
+ def __init__(self, bbox, **kwargs):
135
+ """
136
+ Patch showing the shape bounded by a Bbox.
137
+
138
+ Parameters
139
+ ----------
140
+ bbox : `~matplotlib.transforms.Bbox`
141
+ Bbox to use for the extents of this patch.
142
+
143
+ **kwargs
144
+ Patch properties. Valid arguments include:
145
+
146
+ %(Patch:kwdoc)s
147
+ """
148
+ if "transform" in kwargs:
149
+ raise ValueError("transform should not be set")
150
+
151
+ kwargs["transform"] = IdentityTransform()
152
+ super().__init__(**kwargs)
153
+ self.bbox = bbox
154
+
155
+ def get_path(self):
156
+ # docstring inherited
157
+ x0, y0, x1, y1 = self.bbox.extents
158
+ return Path._create_closed([(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
159
+
160
+
161
+ class BboxConnector(Patch):
162
+ @staticmethod
163
+ def get_bbox_edge_pos(bbox, loc):
164
+ """
165
+ Return the ``(x, y)`` coordinates of corner *loc* of *bbox*; parameters
166
+ behave as documented for the `.BboxConnector` constructor.
167
+ """
168
+ x0, y0, x1, y1 = bbox.extents
169
+ if loc == 1:
170
+ return x1, y1
171
+ elif loc == 2:
172
+ return x0, y1
173
+ elif loc == 3:
174
+ return x0, y0
175
+ elif loc == 4:
176
+ return x1, y0
177
+
178
+ @staticmethod
179
+ def connect_bbox(bbox1, bbox2, loc1, loc2=None):
180
+ """
181
+ Construct a `.Path` connecting corner *loc1* of *bbox1* to corner
182
+ *loc2* of *bbox2*, where parameters behave as documented as for the
183
+ `.BboxConnector` constructor.
184
+ """
185
+ if isinstance(bbox1, Rectangle):
186
+ bbox1 = TransformedBbox(Bbox.unit(), bbox1.get_transform())
187
+ if isinstance(bbox2, Rectangle):
188
+ bbox2 = TransformedBbox(Bbox.unit(), bbox2.get_transform())
189
+ if loc2 is None:
190
+ loc2 = loc1
191
+ x1, y1 = BboxConnector.get_bbox_edge_pos(bbox1, loc1)
192
+ x2, y2 = BboxConnector.get_bbox_edge_pos(bbox2, loc2)
193
+ return Path([[x1, y1], [x2, y2]])
194
+
195
+ @_docstring.dedent_interpd
196
+ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
197
+ """
198
+ Connect two bboxes with a straight line.
199
+
200
+ Parameters
201
+ ----------
202
+ bbox1, bbox2 : `~matplotlib.transforms.Bbox`
203
+ Bounding boxes to connect.
204
+
205
+ loc1, loc2 : {1, 2, 3, 4}
206
+ Corner of *bbox1* and *bbox2* to draw the line. Valid values are::
207
+
208
+ 'upper right' : 1,
209
+ 'upper left' : 2,
210
+ 'lower left' : 3,
211
+ 'lower right' : 4
212
+
213
+ *loc2* is optional and defaults to *loc1*.
214
+
215
+ **kwargs
216
+ Patch properties for the line drawn. Valid arguments include:
217
+
218
+ %(Patch:kwdoc)s
219
+ """
220
+ if "transform" in kwargs:
221
+ raise ValueError("transform should not be set")
222
+
223
+ kwargs["transform"] = IdentityTransform()
224
+ kwargs.setdefault(
225
+ "fill", bool({'fc', 'facecolor', 'color'}.intersection(kwargs)))
226
+ super().__init__(**kwargs)
227
+ self.bbox1 = bbox1
228
+ self.bbox2 = bbox2
229
+ self.loc1 = loc1
230
+ self.loc2 = loc2
231
+
232
+ def get_path(self):
233
+ # docstring inherited
234
+ return self.connect_bbox(self.bbox1, self.bbox2,
235
+ self.loc1, self.loc2)
236
+
237
+
238
+ class BboxConnectorPatch(BboxConnector):
239
+ @_docstring.dedent_interpd
240
+ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
241
+ """
242
+ Connect two bboxes with a quadrilateral.
243
+
244
+ The quadrilateral is specified by two lines that start and end at
245
+ corners of the bboxes. The four sides of the quadrilateral are defined
246
+ by the two lines given, the line between the two corners specified in
247
+ *bbox1* and the line between the two corners specified in *bbox2*.
248
+
249
+ Parameters
250
+ ----------
251
+ bbox1, bbox2 : `~matplotlib.transforms.Bbox`
252
+ Bounding boxes to connect.
253
+
254
+ loc1a, loc2a, loc1b, loc2b : {1, 2, 3, 4}
255
+ The first line connects corners *loc1a* of *bbox1* and *loc2a* of
256
+ *bbox2*; the second line connects corners *loc1b* of *bbox1* and
257
+ *loc2b* of *bbox2*. Valid values are::
258
+
259
+ 'upper right' : 1,
260
+ 'upper left' : 2,
261
+ 'lower left' : 3,
262
+ 'lower right' : 4
263
+
264
+ **kwargs
265
+ Patch properties for the line drawn:
266
+
267
+ %(Patch:kwdoc)s
268
+ """
269
+ if "transform" in kwargs:
270
+ raise ValueError("transform should not be set")
271
+ super().__init__(bbox1, bbox2, loc1a, loc2a, **kwargs)
272
+ self.loc1b = loc1b
273
+ self.loc2b = loc2b
274
+
275
+ def get_path(self):
276
+ # docstring inherited
277
+ path1 = self.connect_bbox(self.bbox1, self.bbox2, self.loc1, self.loc2)
278
+ path2 = self.connect_bbox(self.bbox2, self.bbox1,
279
+ self.loc2b, self.loc1b)
280
+ path_merged = [*path1.vertices, *path2.vertices, path1.vertices[0]]
281
+ return Path(path_merged)
282
+
283
+
284
+ def _add_inset_axes(parent_axes, axes_class, axes_kwargs, axes_locator):
285
+ """Helper function to add an inset axes and disable navigation in it."""
286
+ if axes_class is None:
287
+ axes_class = HostAxes
288
+ if axes_kwargs is None:
289
+ axes_kwargs = {}
290
+ inset_axes = axes_class(
291
+ parent_axes.figure, parent_axes.get_position(),
292
+ **{"navigate": False, **axes_kwargs, "axes_locator": axes_locator})
293
+ return parent_axes.figure.add_axes(inset_axes)
294
+
295
+
296
+ @_docstring.dedent_interpd
297
+ def inset_axes(parent_axes, width, height, loc='upper right',
298
+ bbox_to_anchor=None, bbox_transform=None,
299
+ axes_class=None, axes_kwargs=None,
300
+ borderpad=0.5):
301
+ """
302
+ Create an inset axes with a given width and height.
303
+
304
+ Both sizes used can be specified either in inches or percentage.
305
+ For example,::
306
+
307
+ inset_axes(parent_axes, width='40%%', height='30%%', loc='lower left')
308
+
309
+ creates in inset axes in the lower left corner of *parent_axes* which spans
310
+ over 30%% in height and 40%% in width of the *parent_axes*. Since the usage
311
+ of `.inset_axes` may become slightly tricky when exceeding such standard
312
+ cases, it is recommended to read :doc:`the examples
313
+ </gallery/axes_grid1/inset_locator_demo>`.
314
+
315
+ Notes
316
+ -----
317
+ The meaning of *bbox_to_anchor* and *bbox_to_transform* is interpreted
318
+ differently from that of legend. The value of bbox_to_anchor
319
+ (or the return value of its get_points method; the default is
320
+ *parent_axes.bbox*) is transformed by the bbox_transform (the default
321
+ is Identity transform) and then interpreted as points in the pixel
322
+ coordinate (which is dpi dependent).
323
+
324
+ Thus, following three calls are identical and creates an inset axes
325
+ with respect to the *parent_axes*::
326
+
327
+ axins = inset_axes(parent_axes, "30%%", "40%%")
328
+ axins = inset_axes(parent_axes, "30%%", "40%%",
329
+ bbox_to_anchor=parent_axes.bbox)
330
+ axins = inset_axes(parent_axes, "30%%", "40%%",
331
+ bbox_to_anchor=(0, 0, 1, 1),
332
+ bbox_transform=parent_axes.transAxes)
333
+
334
+ Parameters
335
+ ----------
336
+ parent_axes : `matplotlib.axes.Axes`
337
+ Axes to place the inset axes.
338
+
339
+ width, height : float or str
340
+ Size of the inset axes to create. If a float is provided, it is
341
+ the size in inches, e.g. *width=1.3*. If a string is provided, it is
342
+ the size in relative units, e.g. *width='40%%'*. By default, i.e. if
343
+ neither *bbox_to_anchor* nor *bbox_transform* are specified, those
344
+ are relative to the parent_axes. Otherwise, they are to be understood
345
+ relative to the bounding box provided via *bbox_to_anchor*.
346
+
347
+ loc : str, default: 'upper right'
348
+ Location to place the inset axes. Valid locations are
349
+ 'upper left', 'upper center', 'upper right',
350
+ 'center left', 'center', 'center right',
351
+ 'lower left', 'lower center', 'lower right'.
352
+ For backward compatibility, numeric values are accepted as well.
353
+ See the parameter *loc* of `.Legend` for details.
354
+
355
+ bbox_to_anchor : tuple or `~matplotlib.transforms.BboxBase`, optional
356
+ Bbox that the inset axes will be anchored to. If None,
357
+ a tuple of (0, 0, 1, 1) is used if *bbox_transform* is set
358
+ to *parent_axes.transAxes* or *parent_axes.figure.transFigure*.
359
+ Otherwise, *parent_axes.bbox* is used. If a tuple, can be either
360
+ [left, bottom, width, height], or [left, bottom].
361
+ If the kwargs *width* and/or *height* are specified in relative units,
362
+ the 2-tuple [left, bottom] cannot be used. Note that,
363
+ unless *bbox_transform* is set, the units of the bounding box
364
+ are interpreted in the pixel coordinate. When using *bbox_to_anchor*
365
+ with tuple, it almost always makes sense to also specify
366
+ a *bbox_transform*. This might often be the axes transform
367
+ *parent_axes.transAxes*.
368
+
369
+ bbox_transform : `~matplotlib.transforms.Transform`, optional
370
+ Transformation for the bbox that contains the inset axes.
371
+ If None, a `.transforms.IdentityTransform` is used. The value
372
+ of *bbox_to_anchor* (or the return value of its get_points method)
373
+ is transformed by the *bbox_transform* and then interpreted
374
+ as points in the pixel coordinate (which is dpi dependent).
375
+ You may provide *bbox_to_anchor* in some normalized coordinate,
376
+ and give an appropriate transform (e.g., *parent_axes.transAxes*).
377
+
378
+ axes_class : `~matplotlib.axes.Axes` type, default: `.HostAxes`
379
+ The type of the newly created inset axes.
380
+
381
+ axes_kwargs : dict, optional
382
+ Keyword arguments to pass to the constructor of the inset axes.
383
+ Valid arguments include:
384
+
385
+ %(Axes:kwdoc)s
386
+
387
+ borderpad : float, default: 0.5
388
+ Padding between inset axes and the bbox_to_anchor.
389
+ The units are axes font size, i.e. for a default font size of 10 points
390
+ *borderpad = 0.5* is equivalent to a padding of 5 points.
391
+
392
+ Returns
393
+ -------
394
+ inset_axes : *axes_class*
395
+ Inset axes object created.
396
+ """
397
+
398
+ if (bbox_transform in [parent_axes.transAxes, parent_axes.figure.transFigure]
399
+ and bbox_to_anchor is None):
400
+ _api.warn_external("Using the axes or figure transform requires a "
401
+ "bounding box in the respective coordinates. "
402
+ "Using bbox_to_anchor=(0, 0, 1, 1) now.")
403
+ bbox_to_anchor = (0, 0, 1, 1)
404
+ if bbox_to_anchor is None:
405
+ bbox_to_anchor = parent_axes.bbox
406
+ if (isinstance(bbox_to_anchor, tuple) and
407
+ (isinstance(width, str) or isinstance(height, str))):
408
+ if len(bbox_to_anchor) != 4:
409
+ raise ValueError("Using relative units for width or height "
410
+ "requires to provide a 4-tuple or a "
411
+ "`Bbox` instance to `bbox_to_anchor.")
412
+ return _add_inset_axes(
413
+ parent_axes, axes_class, axes_kwargs,
414
+ AnchoredSizeLocator(
415
+ bbox_to_anchor, width, height, loc=loc,
416
+ bbox_transform=bbox_transform, borderpad=borderpad))
417
+
418
+
419
+ @_docstring.dedent_interpd
420
+ def zoomed_inset_axes(parent_axes, zoom, loc='upper right',
421
+ bbox_to_anchor=None, bbox_transform=None,
422
+ axes_class=None, axes_kwargs=None,
423
+ borderpad=0.5):
424
+ """
425
+ Create an anchored inset axes by scaling a parent axes. For usage, also see
426
+ :doc:`the examples </gallery/axes_grid1/inset_locator_demo2>`.
427
+
428
+ Parameters
429
+ ----------
430
+ parent_axes : `~matplotlib.axes.Axes`
431
+ Axes to place the inset axes.
432
+
433
+ zoom : float
434
+ Scaling factor of the data axes. *zoom* > 1 will enlarge the
435
+ coordinates (i.e., "zoomed in"), while *zoom* < 1 will shrink the
436
+ coordinates (i.e., "zoomed out").
437
+
438
+ loc : str, default: 'upper right'
439
+ Location to place the inset axes. Valid locations are
440
+ 'upper left', 'upper center', 'upper right',
441
+ 'center left', 'center', 'center right',
442
+ 'lower left', 'lower center', 'lower right'.
443
+ For backward compatibility, numeric values are accepted as well.
444
+ See the parameter *loc* of `.Legend` for details.
445
+
446
+ bbox_to_anchor : tuple or `~matplotlib.transforms.BboxBase`, optional
447
+ Bbox that the inset axes will be anchored to. If None,
448
+ *parent_axes.bbox* is used. If a tuple, can be either
449
+ [left, bottom, width, height], or [left, bottom].
450
+ If the kwargs *width* and/or *height* are specified in relative units,
451
+ the 2-tuple [left, bottom] cannot be used. Note that
452
+ the units of the bounding box are determined through the transform
453
+ in use. When using *bbox_to_anchor* it almost always makes sense to
454
+ also specify a *bbox_transform*. This might often be the axes transform
455
+ *parent_axes.transAxes*.
456
+
457
+ bbox_transform : `~matplotlib.transforms.Transform`, optional
458
+ Transformation for the bbox that contains the inset axes.
459
+ If None, a `.transforms.IdentityTransform` is used (i.e. pixel
460
+ coordinates). This is useful when not providing any argument to
461
+ *bbox_to_anchor*. When using *bbox_to_anchor* it almost always makes
462
+ sense to also specify a *bbox_transform*. This might often be the
463
+ axes transform *parent_axes.transAxes*. Inversely, when specifying
464
+ the axes- or figure-transform here, be aware that not specifying
465
+ *bbox_to_anchor* will use *parent_axes.bbox*, the units of which are
466
+ in display (pixel) coordinates.
467
+
468
+ axes_class : `~matplotlib.axes.Axes` type, default: `.HostAxes`
469
+ The type of the newly created inset axes.
470
+
471
+ axes_kwargs : dict, optional
472
+ Keyword arguments to pass to the constructor of the inset axes.
473
+ Valid arguments include:
474
+
475
+ %(Axes:kwdoc)s
476
+
477
+ borderpad : float, default: 0.5
478
+ Padding between inset axes and the bbox_to_anchor.
479
+ The units are axes font size, i.e. for a default font size of 10 points
480
+ *borderpad = 0.5* is equivalent to a padding of 5 points.
481
+
482
+ Returns
483
+ -------
484
+ inset_axes : *axes_class*
485
+ Inset axes object created.
486
+ """
487
+
488
+ return _add_inset_axes(
489
+ parent_axes, axes_class, axes_kwargs,
490
+ AnchoredZoomLocator(
491
+ parent_axes, zoom=zoom, loc=loc,
492
+ bbox_to_anchor=bbox_to_anchor, bbox_transform=bbox_transform,
493
+ borderpad=borderpad))
494
+
495
+
496
+ class _TransformedBboxWithCallback(TransformedBbox):
497
+ """
498
+ Variant of `.TransformBbox` which calls *callback* before returning points.
499
+
500
+ Used by `.mark_inset` to unstale the parent axes' viewlim as needed.
501
+ """
502
+
503
+ def __init__(self, *args, callback, **kwargs):
504
+ super().__init__(*args, **kwargs)
505
+ self._callback = callback
506
+
507
+ def get_points(self):
508
+ self._callback()
509
+ return super().get_points()
510
+
511
+
512
+ @_docstring.dedent_interpd
513
+ def mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs):
514
+ """
515
+ Draw a box to mark the location of an area represented by an inset axes.
516
+
517
+ This function draws a box in *parent_axes* at the bounding box of
518
+ *inset_axes*, and shows a connection with the inset axes by drawing lines
519
+ at the corners, giving a "zoomed in" effect.
520
+
521
+ Parameters
522
+ ----------
523
+ parent_axes : `~matplotlib.axes.Axes`
524
+ Axes which contains the area of the inset axes.
525
+
526
+ inset_axes : `~matplotlib.axes.Axes`
527
+ The inset axes.
528
+
529
+ loc1, loc2 : {1, 2, 3, 4}
530
+ Corners to use for connecting the inset axes and the area in the
531
+ parent axes.
532
+
533
+ **kwargs
534
+ Patch properties for the lines and box drawn:
535
+
536
+ %(Patch:kwdoc)s
537
+
538
+ Returns
539
+ -------
540
+ pp : `~matplotlib.patches.Patch`
541
+ The patch drawn to represent the area of the inset axes.
542
+
543
+ p1, p2 : `~matplotlib.patches.Patch`
544
+ The patches connecting two corners of the inset axes and its area.
545
+ """
546
+ rect = _TransformedBboxWithCallback(
547
+ inset_axes.viewLim, parent_axes.transData,
548
+ callback=parent_axes._unstale_viewLim)
549
+
550
+ kwargs.setdefault("fill", bool({'fc', 'facecolor', 'color'}.intersection(kwargs)))
551
+ pp = BboxPatch(rect, **kwargs)
552
+ parent_axes.add_patch(pp)
553
+
554
+ p1 = BboxConnector(inset_axes.bbox, rect, loc1=loc1, **kwargs)
555
+ inset_axes.add_patch(p1)
556
+ p1.set_clip_on(False)
557
+ p2 = BboxConnector(inset_axes.bbox, rect, loc1=loc2, **kwargs)
558
+ inset_axes.add_patch(p2)
559
+ p2.set_clip_on(False)
560
+
561
+ return pp, p1, p2
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+
4
+ # Check that the test directories exist
5
+ if not (Path(__file__).parent / "baseline_images").exists():
6
+ raise OSError(
7
+ 'The baseline image directory does not exist. '
8
+ 'This is most likely because the test data is not installed. '
9
+ 'You may need to install matplotlib from source to get the '
10
+ 'test data.')
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/__pycache__/conftest.cpython-310.pyc ADDED
Binary file (313 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/__pycache__/test_axes_grid1.cpython-310.pyc ADDED
Binary file (24.3 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py ADDED
@@ -0,0 +1,792 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from itertools import product
2
+ import io
3
+ import platform
4
+
5
+ import matplotlib as mpl
6
+ import matplotlib.pyplot as plt
7
+ import matplotlib.ticker as mticker
8
+ from matplotlib import cbook
9
+ from matplotlib.backend_bases import MouseEvent
10
+ from matplotlib.colors import LogNorm
11
+ from matplotlib.patches import Circle, Ellipse
12
+ from matplotlib.transforms import Bbox, TransformedBbox
13
+ from matplotlib.testing.decorators import (
14
+ check_figures_equal, image_comparison, remove_ticks_and_titles)
15
+
16
+ from mpl_toolkits.axes_grid1 import (
17
+ axes_size as Size,
18
+ host_subplot, make_axes_locatable,
19
+ Grid, AxesGrid, ImageGrid)
20
+ from mpl_toolkits.axes_grid1.anchored_artists import (
21
+ AnchoredAuxTransformBox, AnchoredDrawingArea, AnchoredEllipse,
22
+ AnchoredDirectionArrows, AnchoredSizeBar)
23
+ from mpl_toolkits.axes_grid1.axes_divider import (
24
+ Divider, HBoxDivider, make_axes_area_auto_adjustable, SubplotDivider,
25
+ VBoxDivider)
26
+ from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
27
+ from mpl_toolkits.axes_grid1.inset_locator import (
28
+ zoomed_inset_axes, mark_inset, inset_axes, BboxConnectorPatch,
29
+ InsetPosition)
30
+ import mpl_toolkits.axes_grid1.mpl_axes
31
+ import pytest
32
+
33
+ import numpy as np
34
+ from numpy.testing import assert_array_equal, assert_array_almost_equal
35
+
36
+
37
+ def test_divider_append_axes():
38
+ fig, ax = plt.subplots()
39
+ divider = make_axes_locatable(ax)
40
+ axs = {
41
+ "main": ax,
42
+ "top": divider.append_axes("top", 1.2, pad=0.1, sharex=ax),
43
+ "bottom": divider.append_axes("bottom", 1.2, pad=0.1, sharex=ax),
44
+ "left": divider.append_axes("left", 1.2, pad=0.1, sharey=ax),
45
+ "right": divider.append_axes("right", 1.2, pad=0.1, sharey=ax),
46
+ }
47
+ fig.canvas.draw()
48
+ bboxes = {k: axs[k].get_window_extent() for k in axs}
49
+ dpi = fig.dpi
50
+ assert bboxes["top"].height == pytest.approx(1.2 * dpi)
51
+ assert bboxes["bottom"].height == pytest.approx(1.2 * dpi)
52
+ assert bboxes["left"].width == pytest.approx(1.2 * dpi)
53
+ assert bboxes["right"].width == pytest.approx(1.2 * dpi)
54
+ assert bboxes["top"].y0 - bboxes["main"].y1 == pytest.approx(0.1 * dpi)
55
+ assert bboxes["main"].y0 - bboxes["bottom"].y1 == pytest.approx(0.1 * dpi)
56
+ assert bboxes["main"].x0 - bboxes["left"].x1 == pytest.approx(0.1 * dpi)
57
+ assert bboxes["right"].x0 - bboxes["main"].x1 == pytest.approx(0.1 * dpi)
58
+ assert bboxes["left"].y0 == bboxes["main"].y0 == bboxes["right"].y0
59
+ assert bboxes["left"].y1 == bboxes["main"].y1 == bboxes["right"].y1
60
+ assert bboxes["top"].x0 == bboxes["main"].x0 == bboxes["bottom"].x0
61
+ assert bboxes["top"].x1 == bboxes["main"].x1 == bboxes["bottom"].x1
62
+
63
+
64
+ # Update style when regenerating the test image
65
+ @image_comparison(['twin_axes_empty_and_removed'], extensions=["png"], tol=1,
66
+ style=('classic', '_classic_test_patch'))
67
+ def test_twin_axes_empty_and_removed():
68
+ # Purely cosmetic font changes (avoid overlap)
69
+ mpl.rcParams.update(
70
+ {"font.size": 8, "xtick.labelsize": 8, "ytick.labelsize": 8})
71
+ generators = ["twinx", "twiny", "twin"]
72
+ modifiers = ["", "host invisible", "twin removed", "twin invisible",
73
+ "twin removed\nhost invisible"]
74
+ # Unmodified host subplot at the beginning for reference
75
+ h = host_subplot(len(modifiers)+1, len(generators), 2)
76
+ h.text(0.5, 0.5, "host_subplot",
77
+ horizontalalignment="center", verticalalignment="center")
78
+ # Host subplots with various modifications (twin*, visibility) applied
79
+ for i, (mod, gen) in enumerate(product(modifiers, generators),
80
+ len(generators) + 1):
81
+ h = host_subplot(len(modifiers)+1, len(generators), i)
82
+ t = getattr(h, gen)()
83
+ if "twin invisible" in mod:
84
+ t.axis[:].set_visible(False)
85
+ if "twin removed" in mod:
86
+ t.remove()
87
+ if "host invisible" in mod:
88
+ h.axis[:].set_visible(False)
89
+ h.text(0.5, 0.5, gen + ("\n" + mod if mod else ""),
90
+ horizontalalignment="center", verticalalignment="center")
91
+ plt.subplots_adjust(wspace=0.5, hspace=1)
92
+
93
+
94
+ def test_twin_axes_both_with_units():
95
+ host = host_subplot(111)
96
+ with pytest.warns(mpl.MatplotlibDeprecationWarning):
97
+ host.plot_date([0, 1, 2], [0, 1, 2], xdate=False, ydate=True)
98
+ twin = host.twinx()
99
+ twin.plot(["a", "b", "c"])
100
+ assert host.get_yticklabels()[0].get_text() == "00:00:00"
101
+ assert twin.get_yticklabels()[0].get_text() == "a"
102
+
103
+
104
+ def test_axesgrid_colorbar_log_smoketest():
105
+ fig = plt.figure()
106
+ grid = AxesGrid(fig, 111, # modified to be only subplot
107
+ nrows_ncols=(1, 1),
108
+ ngrids=1,
109
+ label_mode="L",
110
+ cbar_location="top",
111
+ cbar_mode="single",
112
+ )
113
+
114
+ Z = 10000 * np.random.rand(10, 10)
115
+ im = grid[0].imshow(Z, interpolation="nearest", norm=LogNorm())
116
+
117
+ grid.cbar_axes[0].colorbar(im)
118
+
119
+
120
+ def test_inset_colorbar_tight_layout_smoketest():
121
+ fig, ax = plt.subplots(1, 1)
122
+ pts = ax.scatter([0, 1], [0, 1], c=[1, 5])
123
+
124
+ cax = inset_axes(ax, width="3%", height="70%")
125
+ plt.colorbar(pts, cax=cax)
126
+
127
+ with pytest.warns(UserWarning, match="This figure includes Axes"):
128
+ # Will warn, but not raise an error
129
+ plt.tight_layout()
130
+
131
+
132
+ @image_comparison(['inset_locator.png'], style='default', remove_text=True)
133
+ def test_inset_locator():
134
+ fig, ax = plt.subplots(figsize=[5, 4])
135
+
136
+ # prepare the demo image
137
+ # Z is a 15x15 array
138
+ Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
139
+ extent = (-3, 4, -4, 3)
140
+ Z2 = np.zeros((150, 150))
141
+ ny, nx = Z.shape
142
+ Z2[30:30+ny, 30:30+nx] = Z
143
+
144
+ ax.imshow(Z2, extent=extent, interpolation="nearest",
145
+ origin="lower")
146
+
147
+ axins = zoomed_inset_axes(ax, zoom=6, loc='upper right')
148
+ axins.imshow(Z2, extent=extent, interpolation="nearest",
149
+ origin="lower")
150
+ axins.yaxis.get_major_locator().set_params(nbins=7)
151
+ axins.xaxis.get_major_locator().set_params(nbins=7)
152
+ # sub region of the original image
153
+ x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
154
+ axins.set_xlim(x1, x2)
155
+ axins.set_ylim(y1, y2)
156
+
157
+ plt.xticks(visible=False)
158
+ plt.yticks(visible=False)
159
+
160
+ # draw a bbox of the region of the inset axes in the parent axes and
161
+ # connecting lines between the bbox and the inset axes area
162
+ mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
163
+
164
+ asb = AnchoredSizeBar(ax.transData,
165
+ 0.5,
166
+ '0.5',
167
+ loc='lower center',
168
+ pad=0.1, borderpad=0.5, sep=5,
169
+ frameon=False)
170
+ ax.add_artist(asb)
171
+
172
+
173
+ @image_comparison(['inset_axes.png'], style='default', remove_text=True)
174
+ def test_inset_axes():
175
+ fig, ax = plt.subplots(figsize=[5, 4])
176
+
177
+ # prepare the demo image
178
+ # Z is a 15x15 array
179
+ Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
180
+ extent = (-3, 4, -4, 3)
181
+ Z2 = np.zeros((150, 150))
182
+ ny, nx = Z.shape
183
+ Z2[30:30+ny, 30:30+nx] = Z
184
+
185
+ ax.imshow(Z2, extent=extent, interpolation="nearest",
186
+ origin="lower")
187
+
188
+ # creating our inset axes with a bbox_transform parameter
189
+ axins = inset_axes(ax, width=1., height=1., bbox_to_anchor=(1, 1),
190
+ bbox_transform=ax.transAxes)
191
+
192
+ axins.imshow(Z2, extent=extent, interpolation="nearest",
193
+ origin="lower")
194
+ axins.yaxis.get_major_locator().set_params(nbins=7)
195
+ axins.xaxis.get_major_locator().set_params(nbins=7)
196
+ # sub region of the original image
197
+ x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
198
+ axins.set_xlim(x1, x2)
199
+ axins.set_ylim(y1, y2)
200
+
201
+ plt.xticks(visible=False)
202
+ plt.yticks(visible=False)
203
+
204
+ # draw a bbox of the region of the inset axes in the parent axes and
205
+ # connecting lines between the bbox and the inset axes area
206
+ mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
207
+
208
+ asb = AnchoredSizeBar(ax.transData,
209
+ 0.5,
210
+ '0.5',
211
+ loc='lower center',
212
+ pad=0.1, borderpad=0.5, sep=5,
213
+ frameon=False)
214
+ ax.add_artist(asb)
215
+
216
+
217
+ def test_inset_axes_complete():
218
+ dpi = 100
219
+ figsize = (6, 5)
220
+ fig, ax = plt.subplots(figsize=figsize, dpi=dpi)
221
+ fig.subplots_adjust(.1, .1, .9, .9)
222
+
223
+ ins = inset_axes(ax, width=2., height=2., borderpad=0)
224
+ fig.canvas.draw()
225
+ assert_array_almost_equal(
226
+ ins.get_position().extents,
227
+ [(0.9*figsize[0]-2.)/figsize[0], (0.9*figsize[1]-2.)/figsize[1],
228
+ 0.9, 0.9])
229
+
230
+ ins = inset_axes(ax, width="40%", height="30%", borderpad=0)
231
+ fig.canvas.draw()
232
+ assert_array_almost_equal(
233
+ ins.get_position().extents, [.9-.8*.4, .9-.8*.3, 0.9, 0.9])
234
+
235
+ ins = inset_axes(ax, width=1., height=1.2, bbox_to_anchor=(200, 100),
236
+ loc=3, borderpad=0)
237
+ fig.canvas.draw()
238
+ assert_array_almost_equal(
239
+ ins.get_position().extents,
240
+ [200/dpi/figsize[0], 100/dpi/figsize[1],
241
+ (200/dpi+1)/figsize[0], (100/dpi+1.2)/figsize[1]])
242
+
243
+ ins1 = inset_axes(ax, width="35%", height="60%", loc=3, borderpad=1)
244
+ ins2 = inset_axes(ax, width="100%", height="100%",
245
+ bbox_to_anchor=(0, 0, .35, .60),
246
+ bbox_transform=ax.transAxes, loc=3, borderpad=1)
247
+ fig.canvas.draw()
248
+ assert_array_equal(ins1.get_position().extents,
249
+ ins2.get_position().extents)
250
+
251
+ with pytest.raises(ValueError):
252
+ ins = inset_axes(ax, width="40%", height="30%",
253
+ bbox_to_anchor=(0.4, 0.5))
254
+
255
+ with pytest.warns(UserWarning):
256
+ ins = inset_axes(ax, width="40%", height="30%",
257
+ bbox_transform=ax.transAxes)
258
+
259
+
260
+ def test_inset_axes_tight():
261
+ # gh-26287 found that inset_axes raised with bbox_inches=tight
262
+ fig, ax = plt.subplots()
263
+ inset_axes(ax, width=1.3, height=0.9)
264
+
265
+ f = io.BytesIO()
266
+ fig.savefig(f, bbox_inches="tight")
267
+
268
+
269
+ @image_comparison(['fill_facecolor.png'], remove_text=True, style='mpl20')
270
+ def test_fill_facecolor():
271
+ fig, ax = plt.subplots(1, 5)
272
+ fig.set_size_inches(5, 5)
273
+ for i in range(1, 4):
274
+ ax[i].yaxis.set_visible(False)
275
+ ax[4].yaxis.tick_right()
276
+ bbox = Bbox.from_extents(0, 0.4, 1, 0.6)
277
+
278
+ # fill with blue by setting 'fc' field
279
+ bbox1 = TransformedBbox(bbox, ax[0].transData)
280
+ bbox2 = TransformedBbox(bbox, ax[1].transData)
281
+ # set color to BboxConnectorPatch
282
+ p = BboxConnectorPatch(
283
+ bbox1, bbox2, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
284
+ ec="r", fc="b")
285
+ p.set_clip_on(False)
286
+ ax[0].add_patch(p)
287
+ # set color to marked area
288
+ axins = zoomed_inset_axes(ax[0], 1, loc='upper right')
289
+ axins.set_xlim(0, 0.2)
290
+ axins.set_ylim(0, 0.2)
291
+ plt.gca().axes.xaxis.set_ticks([])
292
+ plt.gca().axes.yaxis.set_ticks([])
293
+ mark_inset(ax[0], axins, loc1=2, loc2=4, fc="b", ec="0.5")
294
+
295
+ # fill with yellow by setting 'facecolor' field
296
+ bbox3 = TransformedBbox(bbox, ax[1].transData)
297
+ bbox4 = TransformedBbox(bbox, ax[2].transData)
298
+ # set color to BboxConnectorPatch
299
+ p = BboxConnectorPatch(
300
+ bbox3, bbox4, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
301
+ ec="r", facecolor="y")
302
+ p.set_clip_on(False)
303
+ ax[1].add_patch(p)
304
+ # set color to marked area
305
+ axins = zoomed_inset_axes(ax[1], 1, loc='upper right')
306
+ axins.set_xlim(0, 0.2)
307
+ axins.set_ylim(0, 0.2)
308
+ plt.gca().axes.xaxis.set_ticks([])
309
+ plt.gca().axes.yaxis.set_ticks([])
310
+ mark_inset(ax[1], axins, loc1=2, loc2=4, facecolor="y", ec="0.5")
311
+
312
+ # fill with green by setting 'color' field
313
+ bbox5 = TransformedBbox(bbox, ax[2].transData)
314
+ bbox6 = TransformedBbox(bbox, ax[3].transData)
315
+ # set color to BboxConnectorPatch
316
+ p = BboxConnectorPatch(
317
+ bbox5, bbox6, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
318
+ ec="r", color="g")
319
+ p.set_clip_on(False)
320
+ ax[2].add_patch(p)
321
+ # set color to marked area
322
+ axins = zoomed_inset_axes(ax[2], 1, loc='upper right')
323
+ axins.set_xlim(0, 0.2)
324
+ axins.set_ylim(0, 0.2)
325
+ plt.gca().axes.xaxis.set_ticks([])
326
+ plt.gca().axes.yaxis.set_ticks([])
327
+ mark_inset(ax[2], axins, loc1=2, loc2=4, color="g", ec="0.5")
328
+
329
+ # fill with green but color won't show if set fill to False
330
+ bbox7 = TransformedBbox(bbox, ax[3].transData)
331
+ bbox8 = TransformedBbox(bbox, ax[4].transData)
332
+ # BboxConnectorPatch won't show green
333
+ p = BboxConnectorPatch(
334
+ bbox7, bbox8, loc1a=1, loc2a=2, loc1b=4, loc2b=3,
335
+ ec="r", fc="g", fill=False)
336
+ p.set_clip_on(False)
337
+ ax[3].add_patch(p)
338
+ # marked area won't show green
339
+ axins = zoomed_inset_axes(ax[3], 1, loc='upper right')
340
+ axins.set_xlim(0, 0.2)
341
+ axins.set_ylim(0, 0.2)
342
+ axins.xaxis.set_ticks([])
343
+ axins.yaxis.set_ticks([])
344
+ mark_inset(ax[3], axins, loc1=2, loc2=4, fc="g", ec="0.5", fill=False)
345
+
346
+
347
+ # Update style when regenerating the test image
348
+ @image_comparison(['zoomed_axes.png', 'inverted_zoomed_axes.png'],
349
+ style=('classic', '_classic_test_patch'),
350
+ tol=0.02 if platform.machine() == 'arm64' else 0)
351
+ def test_zooming_with_inverted_axes():
352
+ fig, ax = plt.subplots()
353
+ ax.plot([1, 2, 3], [1, 2, 3])
354
+ ax.axis([1, 3, 1, 3])
355
+ inset_ax = zoomed_inset_axes(ax, zoom=2.5, loc='lower right')
356
+ inset_ax.axis([1.1, 1.4, 1.1, 1.4])
357
+
358
+ fig, ax = plt.subplots()
359
+ ax.plot([1, 2, 3], [1, 2, 3])
360
+ ax.axis([3, 1, 3, 1])
361
+ inset_ax = zoomed_inset_axes(ax, zoom=2.5, loc='lower right')
362
+ inset_ax.axis([1.4, 1.1, 1.4, 1.1])
363
+
364
+
365
+ # Update style when regenerating the test image
366
+ @image_comparison(['anchored_direction_arrows.png'],
367
+ tol=0 if platform.machine() == 'x86_64' else 0.01,
368
+ style=('classic', '_classic_test_patch'))
369
+ def test_anchored_direction_arrows():
370
+ fig, ax = plt.subplots()
371
+ ax.imshow(np.zeros((10, 10)), interpolation='nearest')
372
+
373
+ simple_arrow = AnchoredDirectionArrows(ax.transAxes, 'X', 'Y')
374
+ ax.add_artist(simple_arrow)
375
+
376
+
377
+ # Update style when regenerating the test image
378
+ @image_comparison(['anchored_direction_arrows_many_args.png'],
379
+ style=('classic', '_classic_test_patch'))
380
+ def test_anchored_direction_arrows_many_args():
381
+ fig, ax = plt.subplots()
382
+ ax.imshow(np.ones((10, 10)))
383
+
384
+ direction_arrows = AnchoredDirectionArrows(
385
+ ax.transAxes, 'A', 'B', loc='upper right', color='red',
386
+ aspect_ratio=-0.5, pad=0.6, borderpad=2, frameon=True, alpha=0.7,
387
+ sep_x=-0.06, sep_y=-0.08, back_length=0.1, head_width=9,
388
+ head_length=10, tail_width=5)
389
+ ax.add_artist(direction_arrows)
390
+
391
+
392
+ def test_axes_locatable_position():
393
+ fig, ax = plt.subplots()
394
+ divider = make_axes_locatable(ax)
395
+ with mpl.rc_context({"figure.subplot.wspace": 0.02}):
396
+ cax = divider.append_axes('right', size='5%')
397
+ fig.canvas.draw()
398
+ assert np.isclose(cax.get_position(original=False).width,
399
+ 0.03621495327102808)
400
+
401
+
402
+ @image_comparison(['image_grid_each_left_label_mode_all.png'], style='mpl20',
403
+ savefig_kwarg={'bbox_inches': 'tight'})
404
+ def test_image_grid_each_left_label_mode_all():
405
+ imdata = np.arange(100).reshape((10, 10))
406
+
407
+ fig = plt.figure(1, (3, 3))
408
+ grid = ImageGrid(fig, (1, 1, 1), nrows_ncols=(3, 2), axes_pad=(0.5, 0.3),
409
+ cbar_mode="each", cbar_location="left", cbar_size="15%",
410
+ label_mode="all")
411
+ # 3-tuple rect => SubplotDivider
412
+ assert isinstance(grid.get_divider(), SubplotDivider)
413
+ assert grid.get_axes_pad() == (0.5, 0.3)
414
+ assert grid.get_aspect() # True by default for ImageGrid
415
+ for ax, cax in zip(grid, grid.cbar_axes):
416
+ im = ax.imshow(imdata, interpolation='none')
417
+ cax.colorbar(im)
418
+
419
+
420
+ @image_comparison(['image_grid_single_bottom_label_mode_1.png'], style='mpl20',
421
+ savefig_kwarg={'bbox_inches': 'tight'})
422
+ def test_image_grid_single_bottom():
423
+ imdata = np.arange(100).reshape((10, 10))
424
+
425
+ fig = plt.figure(1, (2.5, 1.5))
426
+ grid = ImageGrid(fig, (0, 0, 1, 1), nrows_ncols=(1, 3),
427
+ axes_pad=(0.2, 0.15), cbar_mode="single",
428
+ cbar_location="bottom", cbar_size="10%", label_mode="1")
429
+ # 4-tuple rect => Divider, isinstance will give True for SubplotDivider
430
+ assert type(grid.get_divider()) is Divider
431
+ for i in range(3):
432
+ im = grid[i].imshow(imdata, interpolation='none')
433
+ grid.cbar_axes[0].colorbar(im)
434
+
435
+
436
+ def test_image_grid_label_mode_invalid():
437
+ fig = plt.figure()
438
+ with pytest.raises(ValueError, match="'foo' is not a valid value for mode"):
439
+ ImageGrid(fig, (0, 0, 1, 1), (2, 1), label_mode="foo")
440
+
441
+
442
+ @image_comparison(['image_grid.png'],
443
+ remove_text=True, style='mpl20',
444
+ savefig_kwarg={'bbox_inches': 'tight'})
445
+ def test_image_grid():
446
+ # test that image grid works with bbox_inches=tight.
447
+ im = np.arange(100).reshape((10, 10))
448
+
449
+ fig = plt.figure(1, (4, 4))
450
+ grid = ImageGrid(fig, 111, nrows_ncols=(2, 2), axes_pad=0.1)
451
+ assert grid.get_axes_pad() == (0.1, 0.1)
452
+ for i in range(4):
453
+ grid[i].imshow(im, interpolation='nearest')
454
+
455
+
456
+ def test_gettightbbox():
457
+ fig, ax = plt.subplots(figsize=(8, 6))
458
+
459
+ l, = ax.plot([1, 2, 3], [0, 1, 0])
460
+
461
+ ax_zoom = zoomed_inset_axes(ax, 4)
462
+ ax_zoom.plot([1, 2, 3], [0, 1, 0])
463
+
464
+ mark_inset(ax, ax_zoom, loc1=1, loc2=3, fc="none", ec='0.3')
465
+
466
+ remove_ticks_and_titles(fig)
467
+ bbox = fig.get_tightbbox(fig.canvas.get_renderer())
468
+ np.testing.assert_array_almost_equal(bbox.extents,
469
+ [-17.7, -13.9, 7.2, 5.4])
470
+
471
+
472
+ @pytest.mark.parametrize("click_on", ["big", "small"])
473
+ @pytest.mark.parametrize("big_on_axes,small_on_axes", [
474
+ ("gca", "gca"),
475
+ ("host", "host"),
476
+ ("host", "parasite"),
477
+ ("parasite", "host"),
478
+ ("parasite", "parasite")
479
+ ])
480
+ def test_picking_callbacks_overlap(big_on_axes, small_on_axes, click_on):
481
+ """Test pick events on normal, host or parasite axes."""
482
+ # Two rectangles are drawn and "clicked on", a small one and a big one
483
+ # enclosing the small one. The axis on which they are drawn as well as the
484
+ # rectangle that is clicked on are varied.
485
+ # In each case we expect that both rectangles are picked if we click on the
486
+ # small one and only the big one is picked if we click on the big one.
487
+ # Also tests picking on normal axes ("gca") as a control.
488
+ big = plt.Rectangle((0.25, 0.25), 0.5, 0.5, picker=5)
489
+ small = plt.Rectangle((0.4, 0.4), 0.2, 0.2, facecolor="r", picker=5)
490
+ # Machinery for "receiving" events
491
+ received_events = []
492
+ def on_pick(event):
493
+ received_events.append(event)
494
+ plt.gcf().canvas.mpl_connect('pick_event', on_pick)
495
+ # Shortcut
496
+ rectangles_on_axes = (big_on_axes, small_on_axes)
497
+ # Axes setup
498
+ axes = {"gca": None, "host": None, "parasite": None}
499
+ if "gca" in rectangles_on_axes:
500
+ axes["gca"] = plt.gca()
501
+ if "host" in rectangles_on_axes or "parasite" in rectangles_on_axes:
502
+ axes["host"] = host_subplot(111)
503
+ axes["parasite"] = axes["host"].twin()
504
+ # Add rectangles to axes
505
+ axes[big_on_axes].add_patch(big)
506
+ axes[small_on_axes].add_patch(small)
507
+ # Simulate picking with click mouse event
508
+ if click_on == "big":
509
+ click_axes = axes[big_on_axes]
510
+ axes_coords = (0.3, 0.3)
511
+ else:
512
+ click_axes = axes[small_on_axes]
513
+ axes_coords = (0.5, 0.5)
514
+ # In reality mouse events never happen on parasite axes, only host axes
515
+ if click_axes is axes["parasite"]:
516
+ click_axes = axes["host"]
517
+ (x, y) = click_axes.transAxes.transform(axes_coords)
518
+ m = MouseEvent("button_press_event", click_axes.figure.canvas, x, y,
519
+ button=1)
520
+ click_axes.pick(m)
521
+ # Checks
522
+ expected_n_events = 2 if click_on == "small" else 1
523
+ assert len(received_events) == expected_n_events
524
+ event_rects = [event.artist for event in received_events]
525
+ assert big in event_rects
526
+ if click_on == "small":
527
+ assert small in event_rects
528
+
529
+
530
+ @image_comparison(['anchored_artists.png'], remove_text=True, style='mpl20')
531
+ def test_anchored_artists():
532
+ fig, ax = plt.subplots(figsize=(3, 3))
533
+ ada = AnchoredDrawingArea(40, 20, 0, 0, loc='upper right', pad=0.,
534
+ frameon=False)
535
+ p1 = Circle((10, 10), 10)
536
+ ada.drawing_area.add_artist(p1)
537
+ p2 = Circle((30, 10), 5, fc="r")
538
+ ada.drawing_area.add_artist(p2)
539
+ ax.add_artist(ada)
540
+
541
+ box = AnchoredAuxTransformBox(ax.transData, loc='upper left')
542
+ el = Ellipse((0, 0), width=0.1, height=0.4, angle=30, color='cyan')
543
+ box.drawing_area.add_artist(el)
544
+ ax.add_artist(box)
545
+
546
+ # Manually construct the ellipse instead, once the deprecation elapses.
547
+ with pytest.warns(mpl.MatplotlibDeprecationWarning):
548
+ ae = AnchoredEllipse(ax.transData, width=0.1, height=0.25, angle=-60,
549
+ loc='lower left', pad=0.5, borderpad=0.4,
550
+ frameon=True)
551
+ ax.add_artist(ae)
552
+
553
+ asb = AnchoredSizeBar(ax.transData, 0.2, r"0.2 units", loc='lower right',
554
+ pad=0.3, borderpad=0.4, sep=4, fill_bar=True,
555
+ frameon=False, label_top=True, prop={'size': 20},
556
+ size_vertical=0.05, color='green')
557
+ ax.add_artist(asb)
558
+
559
+
560
+ def test_hbox_divider():
561
+ arr1 = np.arange(20).reshape((4, 5))
562
+ arr2 = np.arange(20).reshape((5, 4))
563
+
564
+ fig, (ax1, ax2) = plt.subplots(1, 2)
565
+ ax1.imshow(arr1)
566
+ ax2.imshow(arr2)
567
+
568
+ pad = 0.5 # inches.
569
+ divider = HBoxDivider(
570
+ fig, 111, # Position of combined axes.
571
+ horizontal=[Size.AxesX(ax1), Size.Fixed(pad), Size.AxesX(ax2)],
572
+ vertical=[Size.AxesY(ax1), Size.Scaled(1), Size.AxesY(ax2)])
573
+ ax1.set_axes_locator(divider.new_locator(0))
574
+ ax2.set_axes_locator(divider.new_locator(2))
575
+
576
+ fig.canvas.draw()
577
+ p1 = ax1.get_position()
578
+ p2 = ax2.get_position()
579
+ assert p1.height == p2.height
580
+ assert p2.width / p1.width == pytest.approx((4 / 5) ** 2)
581
+
582
+
583
+ def test_vbox_divider():
584
+ arr1 = np.arange(20).reshape((4, 5))
585
+ arr2 = np.arange(20).reshape((5, 4))
586
+
587
+ fig, (ax1, ax2) = plt.subplots(1, 2)
588
+ ax1.imshow(arr1)
589
+ ax2.imshow(arr2)
590
+
591
+ pad = 0.5 # inches.
592
+ divider = VBoxDivider(
593
+ fig, 111, # Position of combined axes.
594
+ horizontal=[Size.AxesX(ax1), Size.Scaled(1), Size.AxesX(ax2)],
595
+ vertical=[Size.AxesY(ax1), Size.Fixed(pad), Size.AxesY(ax2)])
596
+ ax1.set_axes_locator(divider.new_locator(0))
597
+ ax2.set_axes_locator(divider.new_locator(2))
598
+
599
+ fig.canvas.draw()
600
+ p1 = ax1.get_position()
601
+ p2 = ax2.get_position()
602
+ assert p1.width == p2.width
603
+ assert p1.height / p2.height == pytest.approx((4 / 5) ** 2)
604
+
605
+
606
+ def test_axes_class_tuple():
607
+ fig = plt.figure()
608
+ axes_class = (mpl_toolkits.axes_grid1.mpl_axes.Axes, {})
609
+ gr = AxesGrid(fig, 111, nrows_ncols=(1, 1), axes_class=axes_class)
610
+
611
+
612
+ def test_grid_axes_lists():
613
+ """Test Grid axes_all, axes_row and axes_column relationship."""
614
+ fig = plt.figure()
615
+ grid = Grid(fig, 111, (2, 3), direction="row")
616
+ assert_array_equal(grid, grid.axes_all)
617
+ assert_array_equal(grid.axes_row, np.transpose(grid.axes_column))
618
+ assert_array_equal(grid, np.ravel(grid.axes_row), "row")
619
+ assert grid.get_geometry() == (2, 3)
620
+ grid = Grid(fig, 111, (2, 3), direction="column")
621
+ assert_array_equal(grid, np.ravel(grid.axes_column), "column")
622
+
623
+
624
+ @pytest.mark.parametrize('direction', ('row', 'column'))
625
+ def test_grid_axes_position(direction):
626
+ """Test positioning of the axes in Grid."""
627
+ fig = plt.figure()
628
+ grid = Grid(fig, 111, (2, 2), direction=direction)
629
+ loc = [ax.get_axes_locator() for ax in np.ravel(grid.axes_row)]
630
+ # Test nx.
631
+ assert loc[1].args[0] > loc[0].args[0]
632
+ assert loc[0].args[0] == loc[2].args[0]
633
+ assert loc[3].args[0] == loc[1].args[0]
634
+ # Test ny.
635
+ assert loc[2].args[1] < loc[0].args[1]
636
+ assert loc[0].args[1] == loc[1].args[1]
637
+ assert loc[3].args[1] == loc[2].args[1]
638
+
639
+
640
+ @pytest.mark.parametrize('rect, ngrids, error, message', (
641
+ ((1, 1), None, TypeError, "Incorrect rect format"),
642
+ (111, -1, ValueError, "ngrids must be positive"),
643
+ (111, 7, ValueError, "ngrids must be positive"),
644
+ ))
645
+ def test_grid_errors(rect, ngrids, error, message):
646
+ fig = plt.figure()
647
+ with pytest.raises(error, match=message):
648
+ Grid(fig, rect, (2, 3), ngrids=ngrids)
649
+
650
+
651
+ @pytest.mark.parametrize('anchor, error, message', (
652
+ (None, TypeError, "anchor must be str"),
653
+ ("CC", ValueError, "'CC' is not a valid value for anchor"),
654
+ ((1, 1, 1), TypeError, "anchor must be str"),
655
+ ))
656
+ def test_divider_errors(anchor, error, message):
657
+ fig = plt.figure()
658
+ with pytest.raises(error, match=message):
659
+ Divider(fig, [0, 0, 1, 1], [Size.Fixed(1)], [Size.Fixed(1)],
660
+ anchor=anchor)
661
+
662
+
663
+ @check_figures_equal(extensions=["png"])
664
+ def test_mark_inset_unstales_viewlim(fig_test, fig_ref):
665
+ inset, full = fig_test.subplots(1, 2)
666
+ full.plot([0, 5], [0, 5])
667
+ inset.set(xlim=(1, 2), ylim=(1, 2))
668
+ # Check that mark_inset unstales full's viewLim before drawing the marks.
669
+ mark_inset(full, inset, 1, 4)
670
+
671
+ inset, full = fig_ref.subplots(1, 2)
672
+ full.plot([0, 5], [0, 5])
673
+ inset.set(xlim=(1, 2), ylim=(1, 2))
674
+ mark_inset(full, inset, 1, 4)
675
+ # Manually unstale the full's viewLim.
676
+ fig_ref.canvas.draw()
677
+
678
+
679
+ def test_auto_adjustable():
680
+ fig = plt.figure()
681
+ ax = fig.add_axes([0, 0, 1, 1])
682
+ pad = 0.1
683
+ make_axes_area_auto_adjustable(ax, pad=pad)
684
+ fig.canvas.draw()
685
+ tbb = ax.get_tightbbox()
686
+ assert tbb.x0 == pytest.approx(pad * fig.dpi)
687
+ assert tbb.x1 == pytest.approx(fig.bbox.width - pad * fig.dpi)
688
+ assert tbb.y0 == pytest.approx(pad * fig.dpi)
689
+ assert tbb.y1 == pytest.approx(fig.bbox.height - pad * fig.dpi)
690
+
691
+
692
+ # Update style when regenerating the test image
693
+ @image_comparison(['rgb_axes.png'], remove_text=True,
694
+ style=('classic', '_classic_test_patch'))
695
+ def test_rgb_axes():
696
+ fig = plt.figure()
697
+ ax = RGBAxes(fig, (0.1, 0.1, 0.8, 0.8), pad=0.1)
698
+ rng = np.random.default_rng(19680801)
699
+ r = rng.random((5, 5))
700
+ g = rng.random((5, 5))
701
+ b = rng.random((5, 5))
702
+ ax.imshow_rgb(r, g, b, interpolation='none')
703
+
704
+
705
+ # Update style when regenerating the test image
706
+ @image_comparison(['insetposition.png'], remove_text=True,
707
+ style=('classic', '_classic_test_patch'))
708
+ def test_insetposition():
709
+ fig, ax = plt.subplots(figsize=(2, 2))
710
+ ax_ins = plt.axes([0, 0, 1, 1])
711
+ with pytest.warns(mpl.MatplotlibDeprecationWarning):
712
+ ip = InsetPosition(ax, [0.2, 0.25, 0.5, 0.4])
713
+ ax_ins.set_axes_locator(ip)
714
+
715
+
716
+ # The original version of this test relied on mpl_toolkits's slightly different
717
+ # colorbar implementation; moving to matplotlib's own colorbar implementation
718
+ # caused the small image comparison error.
719
+ @image_comparison(['imagegrid_cbar_mode.png'],
720
+ remove_text=True, style='mpl20', tol=0.3)
721
+ def test_imagegrid_cbar_mode_edge():
722
+ arr = np.arange(16).reshape((4, 4))
723
+
724
+ fig = plt.figure(figsize=(18, 9))
725
+
726
+ positions = (241, 242, 243, 244, 245, 246, 247, 248)
727
+ directions = ['row']*4 + ['column']*4
728
+ cbar_locations = ['left', 'right', 'top', 'bottom']*2
729
+
730
+ for position, direction, location in zip(
731
+ positions, directions, cbar_locations):
732
+ grid = ImageGrid(fig, position,
733
+ nrows_ncols=(2, 2),
734
+ direction=direction,
735
+ cbar_location=location,
736
+ cbar_size='20%',
737
+ cbar_mode='edge')
738
+ ax1, ax2, ax3, ax4 = grid
739
+
740
+ ax1.imshow(arr, cmap='nipy_spectral')
741
+ ax2.imshow(arr.T, cmap='hot')
742
+ ax3.imshow(np.hypot(arr, arr.T), cmap='jet')
743
+ ax4.imshow(np.arctan2(arr, arr.T), cmap='hsv')
744
+
745
+ # In each row/column, the "first" colorbars must be overwritten by the
746
+ # "second" ones. To achieve this, clear out the axes first.
747
+ for ax in grid:
748
+ ax.cax.cla()
749
+ cb = ax.cax.colorbar(ax.images[0])
750
+
751
+
752
+ def test_imagegrid():
753
+ fig = plt.figure()
754
+ grid = ImageGrid(fig, 111, nrows_ncols=(1, 1))
755
+ ax = grid[0]
756
+ im = ax.imshow([[1, 2]], norm=mpl.colors.LogNorm())
757
+ cb = ax.cax.colorbar(im)
758
+ assert isinstance(cb.locator, mticker.LogLocator)
759
+
760
+
761
+ def test_removal():
762
+ import matplotlib.pyplot as plt
763
+ import mpl_toolkits.axisartist as AA
764
+ fig = plt.figure()
765
+ ax = host_subplot(111, axes_class=AA.Axes, figure=fig)
766
+ col = ax.fill_between(range(5), 0, range(5))
767
+ fig.canvas.draw()
768
+ col.remove()
769
+ fig.canvas.draw()
770
+
771
+
772
+ @image_comparison(['anchored_locator_base_call.png'], style="mpl20")
773
+ def test_anchored_locator_base_call():
774
+ fig = plt.figure(figsize=(3, 3))
775
+ fig1, fig2 = fig.subfigures(nrows=2, ncols=1)
776
+
777
+ ax = fig1.subplots()
778
+ ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5))
779
+ ax.set(xticks=[], yticks=[])
780
+
781
+ Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
782
+ extent = (-3, 4, -4, 3)
783
+
784
+ axins = zoomed_inset_axes(ax, zoom=2, loc="upper left")
785
+ axins.set(xticks=[], yticks=[])
786
+
787
+ axins.imshow(Z, extent=extent, origin="lower")
788
+
789
+
790
+ def test_grid_with_axes_class_not_overriding_axis():
791
+ Grid(plt.figure(), 111, (2, 2), axes_class=mpl.axes.Axes)
792
+ RGBAxes(plt.figure(), 111, axes_class=mpl.axes.Axes)
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (823 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/angle_helper.cpython-310.pyc ADDED
Binary file (11.2 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axes_divider.cpython-310.pyc ADDED
Binary file (353 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axes_grid.cpython-310.pyc ADDED
Binary file (965 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axes_rgb.cpython-310.pyc ADDED
Binary file (871 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axisline_style.cpython-310.pyc ADDED
Binary file (6.9 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/axislines.cpython-310.pyc ADDED
Binary file (18 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/floating_axes.cpython-310.pyc ADDED
Binary file (8.89 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/grid_finder.cpython-310.pyc ADDED
Binary file (12.3 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/grid_helper_curvelinear.cpython-310.pyc ADDED
Binary file (11.3 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/__pycache__/parasite_axes.cpython-310.pyc ADDED
Binary file (414 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/axislines.py ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Axislines includes modified implementation of the Axes class. The
3
+ biggest difference is that the artists responsible for drawing the axis spine,
4
+ ticks, ticklabels and axis labels are separated out from Matplotlib's Axis
5
+ class. Originally, this change was motivated to support curvilinear
6
+ grid. Here are a few reasons that I came up with a new axes class:
7
+
8
+ * "top" and "bottom" x-axis (or "left" and "right" y-axis) can have
9
+ different ticks (tick locations and labels). This is not possible
10
+ with the current Matplotlib, although some twin axes trick can help.
11
+
12
+ * Curvilinear grid.
13
+
14
+ * angled ticks.
15
+
16
+ In the new axes class, xaxis and yaxis is set to not visible by
17
+ default, and new set of artist (AxisArtist) are defined to draw axis
18
+ line, ticks, ticklabels and axis label. Axes.axis attribute serves as
19
+ a dictionary of these artists, i.e., ax.axis["left"] is a AxisArtist
20
+ instance responsible to draw left y-axis. The default Axes.axis contains
21
+ "bottom", "left", "top" and "right".
22
+
23
+ AxisArtist can be considered as a container artist and has the following
24
+ children artists which will draw ticks, labels, etc.
25
+
26
+ * line
27
+ * major_ticks, major_ticklabels
28
+ * minor_ticks, minor_ticklabels
29
+ * offsetText
30
+ * label
31
+
32
+ Note that these are separate artists from `matplotlib.axis.Axis`, thus most
33
+ tick-related functions in Matplotlib won't work. For example, color and
34
+ markerwidth of the ``ax.axis["bottom"].major_ticks`` will follow those of
35
+ Axes.xaxis unless explicitly specified.
36
+
37
+ In addition to AxisArtist, the Axes will have *gridlines* attribute,
38
+ which obviously draws grid lines. The gridlines needs to be separated
39
+ from the axis as some gridlines can never pass any axis.
40
+ """
41
+
42
+ import numpy as np
43
+
44
+ import matplotlib as mpl
45
+ from matplotlib import _api
46
+ import matplotlib.axes as maxes
47
+ from matplotlib.path import Path
48
+ from mpl_toolkits.axes_grid1 import mpl_axes
49
+ from .axisline_style import AxislineStyle # noqa
50
+ from .axis_artist import AxisArtist, GridlinesCollection
51
+
52
+
53
+ class _AxisArtistHelperBase:
54
+ """
55
+ Base class for axis helper.
56
+
57
+ Subclasses should define the methods listed below. The *axes*
58
+ argument will be the ``.axes`` attribute of the caller artist. ::
59
+
60
+ # Construct the spine.
61
+
62
+ def get_line_transform(self, axes):
63
+ return transform
64
+
65
+ def get_line(self, axes):
66
+ return path
67
+
68
+ # Construct the label.
69
+
70
+ def get_axislabel_transform(self, axes):
71
+ return transform
72
+
73
+ def get_axislabel_pos_angle(self, axes):
74
+ return (x, y), angle
75
+
76
+ # Construct the ticks.
77
+
78
+ def get_tick_transform(self, axes):
79
+ return transform
80
+
81
+ def get_tick_iterators(self, axes):
82
+ # A pair of iterables (one for major ticks, one for minor ticks)
83
+ # that yield (tick_position, tick_angle, tick_label).
84
+ return iter_major, iter_minor
85
+ """
86
+
87
+ def __init__(self, nth_coord):
88
+ self.nth_coord = nth_coord
89
+
90
+ def update_lim(self, axes):
91
+ pass
92
+
93
+ def get_nth_coord(self):
94
+ return self.nth_coord
95
+
96
+ def _to_xy(self, values, const):
97
+ """
98
+ Create a (*values.shape, 2)-shape array representing (x, y) pairs.
99
+
100
+ The other coordinate is filled with the constant *const*.
101
+
102
+ Example::
103
+
104
+ >>> self.nth_coord = 0
105
+ >>> self._to_xy([1, 2, 3], const=0)
106
+ array([[1, 0],
107
+ [2, 0],
108
+ [3, 0]])
109
+ """
110
+ if self.nth_coord == 0:
111
+ return np.stack(np.broadcast_arrays(values, const), axis=-1)
112
+ elif self.nth_coord == 1:
113
+ return np.stack(np.broadcast_arrays(const, values), axis=-1)
114
+ else:
115
+ raise ValueError("Unexpected nth_coord")
116
+
117
+
118
+ class _FixedAxisArtistHelperBase(_AxisArtistHelperBase):
119
+ """Helper class for a fixed (in the axes coordinate) axis."""
120
+
121
+ @_api.delete_parameter("3.9", "nth_coord")
122
+ def __init__(self, loc, nth_coord=None):
123
+ """``nth_coord = 0``: x-axis; ``nth_coord = 1``: y-axis."""
124
+ super().__init__(_api.check_getitem(
125
+ {"bottom": 0, "top": 0, "left": 1, "right": 1}, loc=loc))
126
+ self._loc = loc
127
+ self._pos = {"bottom": 0, "top": 1, "left": 0, "right": 1}[loc]
128
+ # axis line in transAxes
129
+ self._path = Path(self._to_xy((0, 1), const=self._pos))
130
+
131
+ # LINE
132
+
133
+ def get_line(self, axes):
134
+ return self._path
135
+
136
+ def get_line_transform(self, axes):
137
+ return axes.transAxes
138
+
139
+ # LABEL
140
+
141
+ def get_axislabel_transform(self, axes):
142
+ return axes.transAxes
143
+
144
+ def get_axislabel_pos_angle(self, axes):
145
+ """
146
+ Return the label reference position in transAxes.
147
+
148
+ get_label_transform() returns a transform of (transAxes+offset)
149
+ """
150
+ return dict(left=((0., 0.5), 90), # (position, angle_tangent)
151
+ right=((1., 0.5), 90),
152
+ bottom=((0.5, 0.), 0),
153
+ top=((0.5, 1.), 0))[self._loc]
154
+
155
+ # TICK
156
+
157
+ def get_tick_transform(self, axes):
158
+ return [axes.get_xaxis_transform(), axes.get_yaxis_transform()][self.nth_coord]
159
+
160
+
161
+ class _FloatingAxisArtistHelperBase(_AxisArtistHelperBase):
162
+ def __init__(self, nth_coord, value):
163
+ self._value = value
164
+ super().__init__(nth_coord)
165
+
166
+ def get_line(self, axes):
167
+ raise RuntimeError("get_line method should be defined by the derived class")
168
+
169
+
170
+ class FixedAxisArtistHelperRectilinear(_FixedAxisArtistHelperBase):
171
+
172
+ @_api.delete_parameter("3.9", "nth_coord")
173
+ def __init__(self, axes, loc, nth_coord=None):
174
+ """
175
+ nth_coord = along which coordinate value varies
176
+ in 2D, nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
177
+ """
178
+ super().__init__(loc)
179
+ self.axis = [axes.xaxis, axes.yaxis][self.nth_coord]
180
+
181
+ # TICK
182
+
183
+ def get_tick_iterators(self, axes):
184
+ """tick_loc, tick_angle, tick_label"""
185
+ angle_normal, angle_tangent = {0: (90, 0), 1: (0, 90)}[self.nth_coord]
186
+
187
+ major = self.axis.major
188
+ major_locs = major.locator()
189
+ major_labels = major.formatter.format_ticks(major_locs)
190
+
191
+ minor = self.axis.minor
192
+ minor_locs = minor.locator()
193
+ minor_labels = minor.formatter.format_ticks(minor_locs)
194
+
195
+ tick_to_axes = self.get_tick_transform(axes) - axes.transAxes
196
+
197
+ def _f(locs, labels):
198
+ for loc, label in zip(locs, labels):
199
+ c = self._to_xy(loc, const=self._pos)
200
+ # check if the tick point is inside axes
201
+ c2 = tick_to_axes.transform(c)
202
+ if mpl.transforms._interval_contains_close((0, 1), c2[self.nth_coord]):
203
+ yield c, angle_normal, angle_tangent, label
204
+
205
+ return _f(major_locs, major_labels), _f(minor_locs, minor_labels)
206
+
207
+
208
+ class FloatingAxisArtistHelperRectilinear(_FloatingAxisArtistHelperBase):
209
+
210
+ def __init__(self, axes, nth_coord,
211
+ passingthrough_point, axis_direction="bottom"):
212
+ super().__init__(nth_coord, passingthrough_point)
213
+ self._axis_direction = axis_direction
214
+ self.axis = [axes.xaxis, axes.yaxis][self.nth_coord]
215
+
216
+ def get_line(self, axes):
217
+ fixed_coord = 1 - self.nth_coord
218
+ data_to_axes = axes.transData - axes.transAxes
219
+ p = data_to_axes.transform([self._value, self._value])
220
+ return Path(self._to_xy((0, 1), const=p[fixed_coord]))
221
+
222
+ def get_line_transform(self, axes):
223
+ return axes.transAxes
224
+
225
+ def get_axislabel_transform(self, axes):
226
+ return axes.transAxes
227
+
228
+ def get_axislabel_pos_angle(self, axes):
229
+ """
230
+ Return the label reference position in transAxes.
231
+
232
+ get_label_transform() returns a transform of (transAxes+offset)
233
+ """
234
+ angle = [0, 90][self.nth_coord]
235
+ fixed_coord = 1 - self.nth_coord
236
+ data_to_axes = axes.transData - axes.transAxes
237
+ p = data_to_axes.transform([self._value, self._value])
238
+ verts = self._to_xy(0.5, const=p[fixed_coord])
239
+ return (verts, angle) if 0 <= verts[fixed_coord] <= 1 else (None, None)
240
+
241
+ def get_tick_transform(self, axes):
242
+ return axes.transData
243
+
244
+ def get_tick_iterators(self, axes):
245
+ """tick_loc, tick_angle, tick_label"""
246
+ angle_normal, angle_tangent = {0: (90, 0), 1: (0, 90)}[self.nth_coord]
247
+
248
+ major = self.axis.major
249
+ major_locs = major.locator()
250
+ major_labels = major.formatter.format_ticks(major_locs)
251
+
252
+ minor = self.axis.minor
253
+ minor_locs = minor.locator()
254
+ minor_labels = minor.formatter.format_ticks(minor_locs)
255
+
256
+ data_to_axes = axes.transData - axes.transAxes
257
+
258
+ def _f(locs, labels):
259
+ for loc, label in zip(locs, labels):
260
+ c = self._to_xy(loc, const=self._value)
261
+ c1, c2 = data_to_axes.transform(c)
262
+ if 0 <= c1 <= 1 and 0 <= c2 <= 1:
263
+ yield c, angle_normal, angle_tangent, label
264
+
265
+ return _f(major_locs, major_labels), _f(minor_locs, minor_labels)
266
+
267
+
268
+ class AxisArtistHelper: # Backcompat.
269
+ Fixed = _FixedAxisArtistHelperBase
270
+ Floating = _FloatingAxisArtistHelperBase
271
+
272
+
273
+ class AxisArtistHelperRectlinear: # Backcompat.
274
+ Fixed = FixedAxisArtistHelperRectilinear
275
+ Floating = FloatingAxisArtistHelperRectilinear
276
+
277
+
278
+ class GridHelperBase:
279
+
280
+ def __init__(self):
281
+ self._old_limits = None
282
+ super().__init__()
283
+
284
+ def update_lim(self, axes):
285
+ x1, x2 = axes.get_xlim()
286
+ y1, y2 = axes.get_ylim()
287
+ if self._old_limits != (x1, x2, y1, y2):
288
+ self._update_grid(x1, y1, x2, y2)
289
+ self._old_limits = (x1, x2, y1, y2)
290
+
291
+ def _update_grid(self, x1, y1, x2, y2):
292
+ """Cache relevant computations when the axes limits have changed."""
293
+
294
+ def get_gridlines(self, which, axis):
295
+ """
296
+ Return list of grid lines as a list of paths (list of points).
297
+
298
+ Parameters
299
+ ----------
300
+ which : {"both", "major", "minor"}
301
+ axis : {"both", "x", "y"}
302
+ """
303
+ return []
304
+
305
+
306
+ class GridHelperRectlinear(GridHelperBase):
307
+
308
+ def __init__(self, axes):
309
+ super().__init__()
310
+ self.axes = axes
311
+
312
+ @_api.delete_parameter(
313
+ "3.9", "nth_coord", addendum="'nth_coord' is now inferred from 'loc'.")
314
+ def new_fixed_axis(
315
+ self, loc, nth_coord=None, axis_direction=None, offset=None, axes=None):
316
+ if axes is None:
317
+ _api.warn_external(
318
+ "'new_fixed_axis' explicitly requires the axes keyword.")
319
+ axes = self.axes
320
+ if axis_direction is None:
321
+ axis_direction = loc
322
+ return AxisArtist(axes, FixedAxisArtistHelperRectilinear(axes, loc),
323
+ offset=offset, axis_direction=axis_direction)
324
+
325
+ def new_floating_axis(self, nth_coord, value, axis_direction="bottom", axes=None):
326
+ if axes is None:
327
+ _api.warn_external(
328
+ "'new_floating_axis' explicitly requires the axes keyword.")
329
+ axes = self.axes
330
+ helper = FloatingAxisArtistHelperRectilinear(
331
+ axes, nth_coord, value, axis_direction)
332
+ axisline = AxisArtist(axes, helper, axis_direction=axis_direction)
333
+ axisline.line.set_clip_on(True)
334
+ axisline.line.set_clip_box(axisline.axes.bbox)
335
+ return axisline
336
+
337
+ def get_gridlines(self, which="major", axis="both"):
338
+ """
339
+ Return list of gridline coordinates in data coordinates.
340
+
341
+ Parameters
342
+ ----------
343
+ which : {"both", "major", "minor"}
344
+ axis : {"both", "x", "y"}
345
+ """
346
+ _api.check_in_list(["both", "major", "minor"], which=which)
347
+ _api.check_in_list(["both", "x", "y"], axis=axis)
348
+ gridlines = []
349
+
350
+ if axis in ("both", "x"):
351
+ locs = []
352
+ y1, y2 = self.axes.get_ylim()
353
+ if which in ("both", "major"):
354
+ locs.extend(self.axes.xaxis.major.locator())
355
+ if which in ("both", "minor"):
356
+ locs.extend(self.axes.xaxis.minor.locator())
357
+ gridlines.extend([[x, x], [y1, y2]] for x in locs)
358
+
359
+ if axis in ("both", "y"):
360
+ x1, x2 = self.axes.get_xlim()
361
+ locs = []
362
+ if self.axes.yaxis._major_tick_kw["gridOn"]:
363
+ locs.extend(self.axes.yaxis.major.locator())
364
+ if self.axes.yaxis._minor_tick_kw["gridOn"]:
365
+ locs.extend(self.axes.yaxis.minor.locator())
366
+ gridlines.extend([[x1, x2], [y, y]] for y in locs)
367
+
368
+ return gridlines
369
+
370
+
371
+ class Axes(maxes.Axes):
372
+
373
+ @_api.deprecated("3.8", alternative="ax.axis")
374
+ def __call__(self, *args, **kwargs):
375
+ return maxes.Axes.axis(self.axes, *args, **kwargs)
376
+
377
+ def __init__(self, *args, grid_helper=None, **kwargs):
378
+ self._axisline_on = True
379
+ self._grid_helper = grid_helper if grid_helper else GridHelperRectlinear(self)
380
+ super().__init__(*args, **kwargs)
381
+ self.toggle_axisline(True)
382
+
383
+ def toggle_axisline(self, b=None):
384
+ if b is None:
385
+ b = not self._axisline_on
386
+ if b:
387
+ self._axisline_on = True
388
+ self.spines[:].set_visible(False)
389
+ self.xaxis.set_visible(False)
390
+ self.yaxis.set_visible(False)
391
+ else:
392
+ self._axisline_on = False
393
+ self.spines[:].set_visible(True)
394
+ self.xaxis.set_visible(True)
395
+ self.yaxis.set_visible(True)
396
+
397
+ @property
398
+ def axis(self):
399
+ return self._axislines
400
+
401
+ def clear(self):
402
+ # docstring inherited
403
+
404
+ # Init gridlines before clear() as clear() calls grid().
405
+ self.gridlines = gridlines = GridlinesCollection(
406
+ [],
407
+ colors=mpl.rcParams['grid.color'],
408
+ linestyles=mpl.rcParams['grid.linestyle'],
409
+ linewidths=mpl.rcParams['grid.linewidth'])
410
+ self._set_artist_props(gridlines)
411
+ gridlines.set_grid_helper(self.get_grid_helper())
412
+
413
+ super().clear()
414
+
415
+ # clip_path is set after Axes.clear(): that's when a patch is created.
416
+ gridlines.set_clip_path(self.axes.patch)
417
+
418
+ # Init axis artists.
419
+ self._axislines = mpl_axes.Axes.AxisDict(self)
420
+ new_fixed_axis = self.get_grid_helper().new_fixed_axis
421
+ self._axislines.update({
422
+ loc: new_fixed_axis(loc=loc, axes=self, axis_direction=loc)
423
+ for loc in ["bottom", "top", "left", "right"]})
424
+ for axisline in [self._axislines["top"], self._axislines["right"]]:
425
+ axisline.label.set_visible(False)
426
+ axisline.major_ticklabels.set_visible(False)
427
+ axisline.minor_ticklabels.set_visible(False)
428
+
429
+ def get_grid_helper(self):
430
+ return self._grid_helper
431
+
432
+ def grid(self, visible=None, which='major', axis="both", **kwargs):
433
+ """
434
+ Toggle the gridlines, and optionally set the properties of the lines.
435
+ """
436
+ # There are some discrepancies in the behavior of grid() between
437
+ # axes_grid and Matplotlib, because axes_grid explicitly sets the
438
+ # visibility of the gridlines.
439
+ super().grid(visible, which=which, axis=axis, **kwargs)
440
+ if not self._axisline_on:
441
+ return
442
+ if visible is None:
443
+ visible = (self.axes.xaxis._minor_tick_kw["gridOn"]
444
+ or self.axes.xaxis._major_tick_kw["gridOn"]
445
+ or self.axes.yaxis._minor_tick_kw["gridOn"]
446
+ or self.axes.yaxis._major_tick_kw["gridOn"])
447
+ self.gridlines.set(which=which, axis=axis, visible=visible)
448
+ self.gridlines.set(**kwargs)
449
+
450
+ def get_children(self):
451
+ if self._axisline_on:
452
+ children = [*self._axislines.values(), self.gridlines]
453
+ else:
454
+ children = []
455
+ children.extend(super().get_children())
456
+ return children
457
+
458
+ def new_fixed_axis(self, loc, offset=None):
459
+ return self.get_grid_helper().new_fixed_axis(loc, offset=offset, axes=self)
460
+
461
+ def new_floating_axis(self, nth_coord, value, axis_direction="bottom"):
462
+ return self.get_grid_helper().new_floating_axis(
463
+ nth_coord, value, axis_direction=axis_direction, axes=self)
464
+
465
+
466
+ class AxesZero(Axes):
467
+
468
+ def clear(self):
469
+ super().clear()
470
+ new_floating_axis = self.get_grid_helper().new_floating_axis
471
+ self._axislines.update(
472
+ xzero=new_floating_axis(
473
+ nth_coord=0, value=0., axis_direction="bottom", axes=self),
474
+ yzero=new_floating_axis(
475
+ nth_coord=1, value=0., axis_direction="left", axes=self),
476
+ )
477
+ for k in ["xzero", "yzero"]:
478
+ self._axislines[k].line.set_clip_path(self.patch)
479
+ self._axislines[k].set_visible(False)
480
+
481
+
482
+ Subplot = Axes
483
+ SubplotZero = AxesZero
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (487 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/conftest.cpython-310.pyc ADDED
Binary file (313 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_angle_helper.cpython-310.pyc ADDED
Binary file (4.53 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_axislines.cpython-310.pyc ADDED
Binary file (4.42 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_floating_axes.cpython-310.pyc ADDED
Binary file (3.58 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/__pycache__/test_grid_helper_curvelinear.cpython-310.pyc ADDED
Binary file (6.14 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/conftest.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from matplotlib.testing.conftest import (mpl_test_settings, # noqa
2
+ pytest_configure, pytest_unconfigure)
evalkit_tf437/lib/python3.10/site-packages/mpl_toolkits/axisartist/tests/test_grid_finder.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from matplotlib.transforms import Bbox
5
+ from mpl_toolkits.axisartist.grid_finder import (
6
+ _find_line_box_crossings, FormatterPrettyPrint, MaxNLocator)
7
+
8
+
9
+ def test_find_line_box_crossings():
10
+ x = np.array([-3, -2, -1, 0., 1, 2, 3, 2, 1, 0, -1, -2, -3, 5])
11
+ y = np.arange(len(x))
12
+ bbox = Bbox.from_extents(-2, 3, 2, 12.5)
13
+ left, right, bottom, top = _find_line_box_crossings(
14
+ np.column_stack([x, y]), bbox)
15
+ ((lx0, ly0), la0), ((lx1, ly1), la1), = left
16
+ ((rx0, ry0), ra0), ((rx1, ry1), ra1), = right
17
+ ((bx0, by0), ba0), = bottom
18
+ ((tx0, ty0), ta0), = top
19
+ assert (lx0, ly0, la0) == (-2, 11, 135)
20
+ assert (lx1, ly1, la1) == pytest.approx((-2., 12.125, 7.125016))
21
+ assert (rx0, ry0, ra0) == (2, 5, 45)
22
+ assert (rx1, ry1, ra1) == (2, 7, 135)
23
+ assert (bx0, by0, ba0) == (0, 3, 45)
24
+ assert (tx0, ty0, ta0) == pytest.approx((1., 12.5, 7.125016))
25
+
26
+
27
+ def test_pretty_print_format():
28
+ locator = MaxNLocator()
29
+ locs, nloc, factor = locator(0, 100)
30
+
31
+ fmt = FormatterPrettyPrint()
32
+
33
+ assert fmt("left", None, locs) == \
34
+ [r'$\mathdefault{%d}$' % (l, ) for l in locs]
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (178 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/add.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/comparison.cpython-310.pyc ADDED
Binary file (2.34 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/intersection.cpython-310.pyc ADDED
Binary file (11.3 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/issubset.cpython-310.pyc ADDED
Binary file (4.84 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/power.cpython-310.pyc ADDED
Binary file (2.7 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/sympy/sets/handlers/__pycache__/union.cpython-310.pyc ADDED
Binary file (4.06 kB). View file
 
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2016 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ # flake8 flags all these imports as unused, hence the NOQAs everywhere.
19
+
20
+ from .automain import automain # NOQA
21
+ from .autoparse import autoparse, smart_open # NOQA
22
+ from .autocommand import autocommand # NOQA
23
+
24
+ try:
25
+ from .autoasync import autoasync # NOQA
26
+ except ImportError: # pragma: no cover
27
+ pass
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/autoasync.cpython-310.pyc ADDED
Binary file (4.15 kB). View file
 
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/automain.cpython-310.pyc ADDED
Binary file (1.64 kB). View file
 
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/__pycache__/errors.cpython-310.pyc ADDED
Binary file (389 Bytes). View file
 
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autoasync.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from asyncio import get_event_loop, iscoroutine
19
+ from functools import wraps
20
+ from inspect import signature
21
+
22
+
23
+ async def _run_forever_coro(coro, args, kwargs, loop):
24
+ '''
25
+ This helper function launches an async main function that was tagged with
26
+ forever=True. There are two possibilities:
27
+
28
+ - The function is a normal function, which handles initializing the event
29
+ loop, which is then run forever
30
+ - The function is a coroutine, which needs to be scheduled in the event
31
+ loop, which is then run forever
32
+ - There is also the possibility that the function is a normal function
33
+ wrapping a coroutine function
34
+
35
+ The function is therefore called unconditionally and scheduled in the event
36
+ loop if the return value is a coroutine object.
37
+
38
+ The reason this is a separate function is to make absolutely sure that all
39
+ the objects created are garbage collected after all is said and done; we
40
+ do this to ensure that any exceptions raised in the tasks are collected
41
+ ASAP.
42
+ '''
43
+
44
+ # Personal note: I consider this an antipattern, as it relies on the use of
45
+ # unowned resources. The setup function dumps some stuff into the event
46
+ # loop where it just whirls in the ether without a well defined owner or
47
+ # lifetime. For this reason, there's a good chance I'll remove the
48
+ # forever=True feature from autoasync at some point in the future.
49
+ thing = coro(*args, **kwargs)
50
+ if iscoroutine(thing):
51
+ await thing
52
+
53
+
54
+ def autoasync(coro=None, *, loop=None, forever=False, pass_loop=False):
55
+ '''
56
+ Convert an asyncio coroutine into a function which, when called, is
57
+ evaluted in an event loop, and the return value returned. This is intented
58
+ to make it easy to write entry points into asyncio coroutines, which
59
+ otherwise need to be explictly evaluted with an event loop's
60
+ run_until_complete.
61
+
62
+ If `loop` is given, it is used as the event loop to run the coro in. If it
63
+ is None (the default), the loop is retreived using asyncio.get_event_loop.
64
+ This call is defered until the decorated function is called, so that
65
+ callers can install custom event loops or event loop policies after
66
+ @autoasync is applied.
67
+
68
+ If `forever` is True, the loop is run forever after the decorated coroutine
69
+ is finished. Use this for servers created with asyncio.start_server and the
70
+ like.
71
+
72
+ If `pass_loop` is True, the event loop object is passed into the coroutine
73
+ as the `loop` kwarg when the wrapper function is called. In this case, the
74
+ wrapper function's __signature__ is updated to remove this parameter, so
75
+ that autoparse can still be used on it without generating a parameter for
76
+ `loop`.
77
+
78
+ This coroutine can be called with ( @autoasync(...) ) or without
79
+ ( @autoasync ) arguments.
80
+
81
+ Examples:
82
+
83
+ @autoasync
84
+ def get_file(host, port):
85
+ reader, writer = yield from asyncio.open_connection(host, port)
86
+ data = reader.read()
87
+ sys.stdout.write(data.decode())
88
+
89
+ get_file(host, port)
90
+
91
+ @autoasync(forever=True, pass_loop=True)
92
+ def server(host, port, loop):
93
+ yield_from loop.create_server(Proto, host, port)
94
+
95
+ server('localhost', 8899)
96
+
97
+ '''
98
+ if coro is None:
99
+ return lambda c: autoasync(
100
+ c, loop=loop,
101
+ forever=forever,
102
+ pass_loop=pass_loop)
103
+
104
+ # The old and new signatures are required to correctly bind the loop
105
+ # parameter in 100% of cases, even if it's a positional parameter.
106
+ # NOTE: A future release will probably require the loop parameter to be
107
+ # a kwonly parameter.
108
+ if pass_loop:
109
+ old_sig = signature(coro)
110
+ new_sig = old_sig.replace(parameters=(
111
+ param for name, param in old_sig.parameters.items()
112
+ if name != "loop"))
113
+
114
+ @wraps(coro)
115
+ def autoasync_wrapper(*args, **kwargs):
116
+ # Defer the call to get_event_loop so that, if a custom policy is
117
+ # installed after the autoasync decorator, it is respected at call time
118
+ local_loop = get_event_loop() if loop is None else loop
119
+
120
+ # Inject the 'loop' argument. We have to use this signature binding to
121
+ # ensure it's injected in the correct place (positional, keyword, etc)
122
+ if pass_loop:
123
+ bound_args = old_sig.bind_partial()
124
+ bound_args.arguments.update(
125
+ loop=local_loop,
126
+ **new_sig.bind(*args, **kwargs).arguments)
127
+ args, kwargs = bound_args.args, bound_args.kwargs
128
+
129
+ if forever:
130
+ local_loop.create_task(_run_forever_coro(
131
+ coro, args, kwargs, local_loop
132
+ ))
133
+ local_loop.run_forever()
134
+ else:
135
+ return local_loop.run_until_complete(coro(*args, **kwargs))
136
+
137
+ # Attach the updated signature. This allows 'pass_loop' to be used with
138
+ # autoparse
139
+ if pass_loop:
140
+ autoasync_wrapper.__signature__ = new_sig
141
+
142
+ return autoasync_wrapper
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/autocommand.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from .autoparse import autoparse
19
+ from .automain import automain
20
+ try:
21
+ from .autoasync import autoasync
22
+ except ImportError: # pragma: no cover
23
+ pass
24
+
25
+
26
+ def autocommand(
27
+ module, *,
28
+ description=None,
29
+ epilog=None,
30
+ add_nos=False,
31
+ parser=None,
32
+ loop=None,
33
+ forever=False,
34
+ pass_loop=False):
35
+
36
+ if callable(module):
37
+ raise TypeError('autocommand requires a module name argument')
38
+
39
+ def autocommand_decorator(func):
40
+ # Step 1: if requested, run it all in an asyncio event loop. autoasync
41
+ # patches the __signature__ of the decorated function, so that in the
42
+ # event that pass_loop is True, the `loop` parameter of the original
43
+ # function will *not* be interpreted as a command-line argument by
44
+ # autoparse
45
+ if loop is not None or forever or pass_loop:
46
+ func = autoasync(
47
+ func,
48
+ loop=None if loop is True else loop,
49
+ pass_loop=pass_loop,
50
+ forever=forever)
51
+
52
+ # Step 2: create parser. We do this second so that the arguments are
53
+ # parsed and passed *before* entering the asyncio event loop, if it
54
+ # exists. This simplifies the stack trace and ensures errors are
55
+ # reported earlier. It also ensures that errors raised during parsing &
56
+ # passing are still raised if `forever` is True.
57
+ func = autoparse(
58
+ func,
59
+ description=description,
60
+ epilog=epilog,
61
+ add_nos=add_nos,
62
+ parser=parser)
63
+
64
+ # Step 3: call the function automatically if __name__ == '__main__' (or
65
+ # if True was provided)
66
+ func = automain(module)(func)
67
+
68
+ return func
69
+
70
+ return autocommand_decorator
falcon/lib/python3.10/site-packages/setuptools/_vendor/autocommand/automain.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014-2015 Nathan West
2
+ #
3
+ # This file is part of autocommand.
4
+ #
5
+ # autocommand is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # autocommand is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with autocommand. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ import sys
19
+ from .errors import AutocommandError
20
+
21
+
22
+ class AutomainRequiresModuleError(AutocommandError, TypeError):
23
+ pass
24
+
25
+
26
+ def automain(module, *, args=(), kwargs=None):
27
+ '''
28
+ This decorator automatically invokes a function if the module is being run
29
+ as the "__main__" module. Optionally, provide args or kwargs with which to
30
+ call the function. If `module` is "__main__", the function is called, and
31
+ the program is `sys.exit`ed with the return value. You can also pass `True`
32
+ to cause the function to be called unconditionally. If the function is not
33
+ called, it is returned unchanged by the decorator.
34
+
35
+ Usage:
36
+
37
+ @automain(__name__) # Pass __name__ to check __name__=="__main__"
38
+ def main():
39
+ ...
40
+
41
+ If __name__ is "__main__" here, the main function is called, and then
42
+ sys.exit called with the return value.
43
+ '''
44
+
45
+ # Check that @automain(...) was called, rather than @automain
46
+ if callable(module):
47
+ raise AutomainRequiresModuleError(module)
48
+
49
+ if module == '__main__' or module is True:
50
+ if kwargs is None:
51
+ kwargs = {}
52
+
53
+ # Use a function definition instead of a lambda for a neater traceback
54
+ def automain_decorator(main):
55
+ sys.exit(main(*args, **kwargs))
56
+
57
+ return automain_decorator
58
+ else:
59
+ return lambda main: main