Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3427,13 +3427,17 @@ def extract_err(name, err, data, lolims, uplims):
the note in the main docstring about this parameter's name.
"""
try:
low, high = np.broadcast_to(err, (2, len(data)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I looked at this so late. A simpler solution here is to add subok=True...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just today, I decided to look at how matplotlib does this, because I need a similar interface (accept a scalar and 1 d array or a 2 d array - just like err here. I guess that's a rare case that that happens, but should I open a PR to simplify this back to np.boradcast_to with subok?

np.broadcast_to(err, (2, len(data)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to check for this directly, rather than via an error? Maybe this is just as efficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... I guess I just mean int(len(err)/2)==len(err)/2, or whatever is more elegant than that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance should not matter. This should be proportional to len(data) in computation/mempry and is only called once twice for the whole errorbar function.

except ValueError:
raise ValueError(
f"'{name}err' (shape: {np.shape(err)}) must be a scalar "
f"or a 1D or (2, n) array-like whose shape matches "
f"'{name}' (shape: {np.shape(data)})") from None
return data - low * ~lolims, data + high * ~uplims # low, high
# This is like
# low, high = np.broadcast_to(...)
# return data - low * ~lolims, data + high * ~uplims
# except that broadcast_to would strip units.
return data + np.row_stack([-(1 - lolims), 1 - uplims]) * err

if xerr is not None:
left, right = extract_err('x', xerr, x, xlolims, xuplims)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy