Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: anchor not supported for multiline text #740

Open
dsanr opened this issue Nov 8, 2023 · 3 comments
Open

ValueError: anchor not supported for multiline text #740

dsanr opened this issue Nov 8, 2023 · 3 comments

Comments

@dsanr
Copy link

dsanr commented Nov 8, 2023

Description

If there is a multiline text as a key in the dictionary, wordcloud.WordCloud().generate_from_frequencies(my_dict) is producing an error.
Seems this is due to the anchor value of wordcloud is not supported in PIL

Steps/Code to Reproduce

import wordcloud
This will work: wc = wordcloud.WordCloud().generate_from_frequencies({'a': 3, 'b': 1, 'c': 8})
This produces an error: wc = wordcloud.WordCloud().generate_from_frequencies({'a\n': 3, 'b': 1, 'c': 8})

Versions

Linux-6.2.0-36-generic-x86_64-with-glibc2.35
Python 3.11.3 (main, Apr 19 2023, 23:54:32) [GCC 11.2.0]
NumPy 1.23.5
matplotlib 3.8.0
wordcoud 1.9.2
pillow 10.1.0

@cocoa1231
Copy link

+1

Encountering the same issue with the values of the frequencies in a dictionary are floating point numbers

@amueller
Copy link
Owner

What is the expected result with newlines? I would imagine tokens not to include newlines. generate_from_frequencies is meant as a more low-level interface with already parsed tokens. We could provide a more instructive error message but I would say that for that interface, removing newlines is in the users responsibility.

@cocoa1231 can you provide a script to reproduce?

@dsanr
Copy link
Author

dsanr commented Feb 17, 2024

@amueller The expected result with the new lines can be printing the word as it is including the line separation. If adding that functionality is more complex, we can provide a more constructive message that asks the user to remove newline characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants