FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix build with numpy master. by anntzer · Pull Request #15833 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 4 additions & 9 deletions lib/matplotlib/axes/_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6586,8 +6586,6 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
if histtype == 'barstacked' and not stacked:
stacked = True

# basic input validation
input_empty = np.size(x) == 0
# Massage 'x' for processing.
x = cbook._reshape_2D(x, 'x')
nx = len(x) # number of datasets
Expand Down Expand Up @@ -6649,13 +6647,10 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
# If bins are not specified either explicitly or via range,
# we need to figure out the range required for all datasets,
# and supply that to np.histogram.
if not input_empty and len(x) > 1:
if weights is not None:
_w = np.concatenate(w)
else:
_w = None
bins = np.histogram_bin_edges(
np.concatenate(x), bins, bin_range, _w)
all_xs = np.concatenate(x)
if len(all_xs):
all_ws = np.concatenate(w) if weights is not None else None
bins = np.histogram_bin_edges(all_xs, bins, bin_range, all_ws)
else:
hist_kwargs['range'] = bin_range

Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/colors.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
from collections.abc import Sized
import functools
import itertools
from numbers import Number
import re

import numpy as np
Expand Down Expand Up @@ -260,14 +261,12 @@ def _to_rgba_no_colorcycle(c, alpha=None):
return c, c, c, alpha if alpha is not None else 1.
raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
# tuple color.
c = np.array(c)
if not np.can_cast(c.dtype, float, "same_kind") or c.ndim != 1:
# Test the dtype explicitly as `map(float, ...)`, `np.array(...,
# float)` and `np.array(...).astype(float)` all convert "0.5" to 0.5.
# Test dimensionality to reject single floats.
if not np.iterable(c) or not all(isinstance(x, Number) for x in c):
# Checks that don't work: `map(float, ...)`, `np.array(..., float)` and
# `np.array(...).astype(float)` would all convert "0.5" to 0.5.
raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
# Return a tuple to prevent the cached value from being modified.
c = tuple(c.astype(float))
c = tuple(map(float, c))
if len(c) not in [3, 4]:
raise ValueError("RGBA sequence should have length 3 or 4")
if len(c) == 3 and alpha is None:
Expand Down
8 changes: 6 additions & 2 deletions lib/matplotlib/tests/test_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ def test_shaped_data():
plt.plot(y2)

plt.subplot(413)
with pytest.raises(ValueError):
# DeprecationWarning is raised by numpy 1.19 on object array creation;
# later it will be a ValueError again.
with pytest.raises((ValueError, DeprecationWarning)):
plt.plot((y1, y2))

plt.subplot(414)
Expand Down Expand Up @@ -2697,7 +2699,9 @@ def test_boxplot_bad_ci_2():
x = np.linspace(-7, 7, 140)
x = np.hstack([-25, x, 25])
fig, ax = plt.subplots()
with pytest.raises(ValueError):
# DeprecationWarning is raised by numpy 1.19 on object array creation;
# later it will be a ValueError again.
with pytest.raises((ValueError, DeprecationWarning)):
ax.boxplot([x, x], conf_intervals=[[1, 2], [1]])


Expand Down

Back | FazBrowse Home | New Git URL