Skip to content

Navigation Menu

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

[ENH]: Typing: broaden acceptable floats #29332

Copy link
Copy link
Open
@stefanv

Description

@stefanv
Issue body actions

Problem

From plot_bar.py in the SP lecture notes, we have:

X = np.arange(n)
rng = np.random.default_rng()
Y1 = (1 - X / float(n)) * rng.uniform(0.5, 1.0, n)

for x, y in zip(X, Y1):
    plt.text(x, y + 0.05, f"{y:.2f}", ha="center", va="bottom")

Mypy reports typing errors:

intro/matplotlib/examples/plot_bar.py:22: error: Argument 1 to "text" has incompatible type "signedinteger[Any]"; expected "float"  [arg-type]
intro/matplotlib/examples/plot_bar.py:22: error: Argument 2 to "text" has incompatible type "floating[Any] | float64"; expected "float"  [arg-type]
intro/matplotlib/examples/plot_bar.py:25: error: Argument 1 to "text" has incompatible type "signedinteger[Any]"; expected "float"  [arg-type]
intro/matplotlib/examples/plot_bar.py:25: error: Argument 2 to "text" has incompatible type "floating[Any] | float64"; expected "float"  [arg-type]

Proposed solution

Could we broaden the floating point & integer types accepted?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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