Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A little word cloud generator"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.9"
license = "MIT"
dependencies = ["numpy>=1.19", "pillow", "matplotlib"]
dependencies = ["numpy>=1.19.3", "pillow", "matplotlib"]
dynamic = ["version"]

[project.urls]
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
matplotlib>=1.5.3
numpy>=1.6.1
numpy>1.19.3; python_version >= '3.10'
numpy==1.19.3; python_version == '3.9'
pillow
cython
cython
12 changes: 10 additions & 2 deletions wordcloud/wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,22 @@ def to_array(self, copy=None):
copy : bool
If `True`, then the object is copied. If `None` then the object is copied
only if needed. For `False` it raises a ValueError if a copy cannot be
avoided. Default: `None`.
avoided. Default: `None`. `copy` is passed directly to `np.asarray`
which is supported on NumPy>=2.0. For older NumPy versions `copy` is
ignored.

Returns
-------
image : nd-array size (width, height, 3)
Word cloud image as numpy matrix.
"""
return np.asarray(self.to_image(), copy=copy)
image = self.to_image()
if copy is None:
return np.asarray(image)
try:
return np.asarray(image, copy=copy)
except TypeError:
return np.asarray(image)

def __array__(self, copy=None):
"""Convert to numpy array.
Expand Down