René's URL Explorer Experiment


Title: [Bug]: Axes.grouped_bar() with non-string orientation (e.g., NumPy array) raises ambiguous truth-value error instead of clean ValueError · Issue #30706 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: Axes.grouped_bar() with non-string orientation (e.g., NumPy array) raises ambiguous truth-value error instead of clean ValueError · Issue #30706 · matplotlib/matplotlib

X Title: [Bug]: Axes.grouped_bar() with non-string orientation (e.g., NumPy array) raises ambiguous truth-value error instead of clean ValueError · Issue #30706 · matplotlib/matplotlib

Description: Bug summary Passing a non-string value (like a NumPy array) to orientation in Axes.grouped_bar() triggers a misleading “ambiguous truth value” error from _api.check_in_list. The function should instead raise a clear ValueError stating th...

Open Graph Description: Bug summary Passing a non-string value (like a NumPy array) to orientation in Axes.grouped_bar() triggers a misleading “ambiguous truth value” error from _api.check_in_list. The function should ins...

X Description: Bug summary Passing a non-string value (like a NumPy array) to orientation in Axes.grouped_bar() triggers a misleading “ambiguous truth value” error from _api.check_in_list. The function should ins...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30706

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Axes.grouped_bar() with non-string orientation (e.g., NumPy array) raises ambiguous truth-value error instead of clean ValueError","articleBody":"### Bug summary\n\nPassing a non-string value (like a NumPy array) to orientation in Axes.grouped_bar() triggers a misleading “ambiguous truth value” error from _api.check_in_list. The function should instead raise a clear ValueError stating the value is not valid.\n\n\n### Code for reproduction\n\n```Python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfig, ax = plt.subplots()\nax.grouped_bar([[1, 2, 3], [3, 2, 1]], orientation=np.array([1, 2, 3]))\n```\n\n### Actual outcome\n\nAxes.grouped_bar() fails inside _api.check_in_list() because NumPy arrays cannot be evaluated in a boolean context.\nInstead of raising a clear validation error, it produces a misleading NumPy truth-value error, causing the test to fail.\n\n\u003cimg width=\"1600\" height=\"1172\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/0a24242f-ae50-45ba-a15e-af44768f4333\" /\u003e\n\n### Expected outcome\n\nAfter applying the fix, invalid inputs (including NumPy arrays) are handled gracefully, and all tests expecting a clear ValueError now pass.\n\n\n\n### Additional information\n\n\n1. Conditions under which this bug happens:\n\nThe bug occurs whenever the orientation parameter passed to Axes.grouped_bar() is not a string, such as:\norientation = np.array([1, 2, 3])  # NumPy array  \norientation = 1                    # integer  \norientation = None                 # NoneType\n\nThese types trigger an internal truth-value evaluation inside _api.check_in_list, which expects a scalar comparable value (like a string).\n\n2. Edge cases affected:\n\nNumPy arrays (np.array([...]))\nNon-string types (integers, floats, None, lists, etc.)\nAny custom object that doesn’t implement __eq__ safely with strings\n\n3. Behavior in earlier versions:\n\nThis issue has likely existed since the introduction of Axes.grouped_bar() (Matplotlib 3.11, provisional API).\nOther similar Matplotlib APIs (e.g., barh, stem, etc.) already validate string-type enums, so they are not affected.\n\n4. Root cause (why this happens):\n\nThe function directly calls:\n\n_api.check_in_list([\"vertical\", \"horizontal\"], orientation=orientation)\n\nWhen orientation is a NumPy array, the expression val not in values inside check_in_list() performs elementwise comparison, returning an array of booleans.\n\nPython then attempts to interpret that array as a single truth value, which triggers NumPy’s error:\nValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().\n\n5. Proposed fix (confirmed working):\n\nAdd an early type guard before calling _api.check_in_list():\n\nif not isinstance(orientation, str):\n    raise ValueError(f\"{orientation!r} is not a valid value for orientation\")\n_api.check_in_list([\"vertical\", \"horizontal\"], orientation=orientation)\n\n-- This ensures non-string inputs are rejected immediately and consistently,\n-- prevents the ambiguous truth-value error, and\n-- aligns grouped_bar() with Matplotlib’s standard API validation behavior.\n\n### Operating system\n\nMacOS\n\n### Matplotlib Version\n\n3.11.0.dev1446+g319295e28.d20251030\n\n### Matplotlib Backend\n\nmacosx\n\n### Python version\n\nPython 3.13.7\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/ilakkmanoharan","@type":"Person","name":"ilakkmanoharan"},"datePublished":"2025-10-30T20:25:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/30706/matplotlib/issues/30706"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:79a8c22a-2ad1-efa9-59f9-7af3111f7173
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA70A:292960:4D4FED:69951D:6969DE1B
html-safe-nonce9b51a257a38b8900139ccc2316729b0d5565d909eb565b90abd7291f498f0ef4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzBBOjI5Mjk2MDo0RDRGRUQ6Njk5NTFEOjY5NjlERTFCIiwidmlzaXRvcl9pZCI6IjYxNzk4OTUxMTk2MDgxNDMzODciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac061ea3307c0e344a1c8bc2d3bf1912f2ac828d5af084b3e863da1dfc2f449e7d
hovercard-subject-tagissue:3572386499
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/30706/issue_layout
twitter:imagehttps://opengraph.githubassets.com/44e11f00907848d57ecee7895ca5d3f57c1192b55be175d7c5b5593c81cc1f24/matplotlib/matplotlib/issues/30706
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/44e11f00907848d57ecee7895ca5d3f57c1192b55be175d7c5b5593c81cc1f24/matplotlib/matplotlib/issues/30706
og:image:altBug summary Passing a non-string value (like a NumPy array) to orientation in Axes.grouped_bar() triggers a misleading “ambiguous truth value” error from _api.check_in_list. The function should ins...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameilakkmanoharan
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/30706#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F30706
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F30706
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/30706
Reloadhttps://github.com/matplotlib/matplotlib/issues/30706
Reloadhttps://github.com/matplotlib/matplotlib/issues/30706
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/30706
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.2k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 22.2k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 401 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects 2 https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/matplotlib/matplotlib/security
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/30706
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
New issuehttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/30706
New issuehttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/30706
#30714https://github.com/matplotlib/matplotlib/pull/30714
[Bug]: Axes.grouped_bar() with non-string orientation (e.g., NumPy array) raises ambiguous truth-value error instead of clean ValueErrorhttps://github.com/matplotlib/matplotlib/issues/30706#top
#30714https://github.com/matplotlib/matplotlib/pull/30714
v3.10.8https://github.com/matplotlib/matplotlib/milestone/106
https://github.com/ilakkmanoharan
https://github.com/ilakkmanoharan
ilakkmanoharanhttps://github.com/ilakkmanoharan
on Oct 30, 2025https://github.com/matplotlib/matplotlib/issues/30706#issue-3572386499
https://private-user-images.githubusercontent.com/28582192/507872344-0a24242f-ae50-45ba-a15e-af44768f4333.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njg1NDYxMjAsIm5iZiI6MTc2ODU0NTgyMCwicGF0aCI6Ii8yODU4MjE5Mi81MDc4NzIzNDQtMGEyNDI0MmYtYWU1MC00NWJhLWExNWUtYWY0NDc2OGY0MzMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAxMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMTE2VDA2NDM0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE1MzJlNTc4YWJiNTE3YjUzY2E4MTk1ZWNjZDlkNDVhZDhjZjE4M2Y2NDI1Y2YzNmZjNWNjYTY1ZTU5NmUxNjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.oEvLSqZWRrPJcu1I_X5vkivLPFNTYXrMfs6OWEb8VXw
v3.10.8https://github.com/matplotlib/matplotlib/milestone/106
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.