Open
Description
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?