Skip to content

Commit

Permalink
Fix test failures and deprecated Pillow functions (amueller#711)
Browse files Browse the repository at this point in the history
* fix: remove deprecated np.int to int

* fix: remove deprecated Pillow functions

* feat: add aarch64 cp311

---------

Co-authored-by: Valinquish <[email protected]>
Co-authored-by: Andreas Mueller <[email protected]>
  • Loading branch information
3 people authored Apr 27, 2023
1 parent ec4a157 commit fda9208
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
name: "Build aarch64 ${{ matrix.pyver }}"
strategy:
matrix:
pyver: [cp37-cp37m, cp38-cp38, cp39-cp39, cp310-cp310]
pyver: [cp37-cp37m, cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311]
fail-fast: false
runs-on: ubuntu-latest
env:
Expand Down
4 changes: 2 additions & 2 deletions wordcloud/color_from_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def __call__(self, word, font_size, font_path, position, orientation, **kwargs):
transposed_font = ImageFont.TransposedFont(font,
orientation=orientation)
# get size of resulting text
box_size = transposed_font.getsize(word)
box_size = transposed_font.getbbox(word)
x = position[0]
y = position[1]
# cut out patch under word box
patch = self.image[x:x + box_size[0], y:y + box_size[1]]
patch = self.image[x:x + box_size[2], y:y + box_size[3]]
if patch.ndim == 3:
# drop alpha channel if any
patch = patch[:, :, :3]
Expand Down
6 changes: 3 additions & 3 deletions wordcloud/wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C
transposed_font = ImageFont.TransposedFont(
font, orientation=orientation)
# get size of resulting text
box_size = draw.textsize(word, font=transposed_font)
box_size = draw.textbbox((0, 0), word, font=transposed_font, anchor="lt")
# find possible places using integral image:
result = occupancy.sample_position(box_size[1] + self.margin,
box_size[0] + self.margin,
result = occupancy.sample_position(box_size[3] + self.margin,
box_size[2] + self.margin,
random_state)
if result is not None or font_size < self.min_font_size:
# either we found a place or font-size went too small
Expand Down

0 comments on commit fda9208

Please sign in to comment.