Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3e592d7

Browse filesBrowse files
committed
Remove incorrect statement about data-kwarg interface.
We don't actually require `data` to support `key in data`; we only ever try `data[key]` (treating any exception as meaning "`key` is not in `data`, use its value directly"). This can be checked e.g. by creating a custom type that supports `__getitem__` but throws on `in` checks, and verify that it can be used as `data`: ``` class T: __getitem__ = lambda self, k: {"foo": 1, "bar": 2}[k] l, = plt.plot("foo", "bar", data=T()) l.get_xydata() # == [[1, 2]] "foo" in T() # raises ``` So delete the statement about `s in data`; the statement about `data[s]` can also be removed as it is clearly implied by the fact that "`s` is interpreted as `data[s]`".
1 parent a3fbf18 commit 3e592d7
Copy full SHA for 3e592d7

File tree

Expand file treeCollapse file tree

1 file changed

+4
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-10
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,18 +1281,12 @@ def _add_data_doc(docstring, replace_names):
12811281

12821282
data_doc = ("""\
12831283
If given, all parameters also accept a string ``s``, which is
1284-
interpreted as ``data[s]`` (unless this raises an exception).
1285-
1286-
Objects passed as **data** must support item access (``data[s]``) and
1287-
membership test (``s in data``)."""
1284+
interpreted as ``data[s]`` (unless this raises an exception)."""
12881285
if replace_names is None else f"""\
1289-
If given, the following parameters also accept a string ``s``, which
1290-
is interpreted as ``data[s]`` (unless this raises an exception):
1291-
1292-
{', '.join(map('*{}*'.format, replace_names))}
1286+
If given, the following parameters also accept a string ``s``, which is
1287+
interpreted as ``data[s]`` (unless this raises an exception):
12931288
1294-
Objects passed as **data** must support item access (``data[s]``) and
1295-
membership test (``s in data``).""")
1289+
{', '.join(map('*{}*'.format, replace_names))}""")
12961290
# using string replacement instead of formatting has the advantages
12971291
# 1) simpler indent handling
12981292
# 2) prevent problems with formatting characters '{', '%' in the docstring

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.