Title: [Bug]: Matplotlib 3.5 breaks unyt integration of error bars · Issue #21669 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Matplotlib 3.5 breaks unyt integration of error bars · Issue #21669 · matplotlib/matplotlib
X Title: [Bug]: Matplotlib 3.5 breaks unyt integration of error bars · Issue #21669 · matplotlib/matplotlib
Description: Bug summary Discovered this in unyt's daily CI jobs: https://github.com/yt-project/unyt/actions Code for reproduction import matplotlib.pyplot as plt import unyt as un un.matplotlib_support.enable() fig, ax = plt.subplots() x = un.unyt_a...
Open Graph Description: Bug summary Discovered this in unyt's daily CI jobs: https://github.com/yt-project/unyt/actions Code for reproduction import matplotlib.pyplot as plt import unyt as un un.matplotlib_support.enable(...
X Description: Bug summary Discovered this in unyt's daily CI jobs: https://github.com/yt-project/unyt/actions Code for reproduction import matplotlib.pyplot as plt import unyt as un un.matplotlib_support.ena...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21669
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Matplotlib 3.5 breaks unyt integration of error bars","articleBody":"### Bug summary\r\n\r\nDiscovered this in unyt's daily CI jobs: https://github.com/yt-project/unyt/actions\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport unyt as un\r\n\r\nun.matplotlib_support.enable()\r\nfig, ax = plt.subplots()\r\n\r\nx = un.unyt_array([1, 2], \"cm\")\r\ny = un.unyt_array([3, 4], \"kg\")\r\nyerr = un.unyt_array([0.1, 0.2], \"kg\")\r\nax.errorbar(x, y, yerr=(yerr, yerr))\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n```\r\nUnitOperationError: The \u003cufunc 'subtract'\u003e operator for unyt_arrays with units \"kg\" \r\n(dimensions \"(mass)\") and \"dimensionless\" (dimensions \"1\") is not well defined.\r\n```\r\n\r\n\u003cdetails\u003e \u003csummary\u003edetailed raceback\u003c/summary\u003e\r\n\r\n```\r\n╭──────────────────────────── Traceback (most recent call last) ────────────────────────────╮\r\n│ │\r\n│ /private/tmp/matplotlib/t.py:10 in \u003cmodule\u003e │\r\n│ │\r\n│ 7 x = un.unyt_array([1, 2], \"cm\") │\r\n│ 8 y = un.unyt_array([3, 4], \"kg\") │\r\n│ 9 yerr = un.unyt_array([0.1, 0.2], \"kg\") │\r\n│ ❱ 10 ax.errorbar(x, y, yerr=yerr) │\r\n│ 11 │\r\n│ /private/tmp/matplotlib/lib/matplotlib/__init__.py:1348 in inner │\r\n│ │\r\n│ 1345 │ @functools.wraps(func) │\r\n│ 1346 │ def inner(ax, *args, data=None, **kwargs): │\r\n│ 1347 │ │ if data is None: │\r\n│ ❱ 1348 │ │ │ return func(ax, *map(sanitize_sequence, args), **kwargs) │\r\n│ 1349 │ │ │\r\n│ 1350 │ │ bound = new_sig.bind(ax, *args, **kwargs) │\r\n│ 1351 │ │ auto_label = (bound.arguments.get(label_namer) │\r\n│ │\r\n│ /private/tmp/matplotlib/lib/matplotlib/axes/_axes.py:3474 in errorbar │\r\n│ │\r\n│ 3471 │ │ │ │ │ │ xo, yo, marker='|', **eb_cap_style)) │\r\n│ 3472 │ │ │\r\n│ 3473 │ │ if yerr is not None: │\r\n│ ❱ 3474 │ │ │ lower, upper = extract_err('y', yerr, y, lolims, uplims) │\r\n│ 3475 │ │ │ barcols.append(self.vlines( │\r\n│ 3476 │ │ │ │ *apply_mask([x, lower, upper], everymask), **eb_lines_style)) │\r\n│ 3477 │ │ │ # select points without upper/lower limits in y and │\r\n│ │\r\n│ /private/tmp/matplotlib/lib/matplotlib/axes/_axes.py:3434 in extract_err │\r\n│ │\r\n│ 3431 │ │ │ │ │ f\"'{name}err' (shape: {np.shape(err)}) must be a scalar \" │\r\n│ 3432 │ │ │ │ │ f\"or a 1D or (2, n) array-like whose shape matches \" │\r\n│ 3433 │ │ │ │ │ f\"'{name}' (shape: {np.shape(data)})\") from None │\r\n│ ❱ 3434 │ │ │ return data - low * ~lolims, data + high * ~uplims # low, high │\r\n│ 3435 │ │ │\r\n│ 3436 │ │ if xerr is not None: │\r\n│ 3437 │ │ │ left, right = extract_err('x', xerr, x, xlolims, xuplims) │\r\n│ │\r\n│ /Users/robcleme/.pyenv/versions/3.9.7/envs/tmp_unit/lib/python3.9/site-packages/unyt/arra │\r\n│ y.py:1764 in __array_ufunc__ │\r\n│ │\r\n│ 1761 │ │ │ │ │ │ │ │ else: │\r\n│ 1762 │ │ │ │ │ │ │ │ │ raise UnitOperationError(ufunc, u0, u1) │\r\n│ 1763 │ │ │ │ │ │ else: │\r\n│ ❱ 1764 │ │ │ │ │ │ │ raise UnitOperationError(ufunc, u0, u1) │\r\n│ 1765 │ │ │ │ │ conv, offset = u1.get_conversion_factor(u0, inp1.dtype) │\r\n│ 1766 │ │ │ │ │ new_dtype = np.dtype(\"f\" + str(inp1.dtype.itemsize)) │\r\n│ 1767 │ │ │ │ │ conv = new_dtype.type(conv) │\r\n╰───────────────────────────────────────────────────────────────────────────────────────────╯\r\nUnitOperationError: The \u003cufunc 'subtract'\u003e operator for unyt_arrays with units \"kg\" \r\n(dimensions \"(mass)\") and \"dimensionless\" (dimensions \"1\") is not well defined.\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\n### Expected outcome\r\n\r\nThis is the output figure with matplotlib 3.4.3\r\n\r\n\r\n\r\n### Additional information\r\n\r\nThe regression bisects to #19526 (https://github.com/matplotlib/matplotlib/pull/19526/commits/8cd22b4d5840b08cd42f793f5a30e23595aa44f2)\r\n\r\nI note that if replace the last line with\r\n```\r\nax.errorbar(x, y, yerr=yerr)\r\n```\r\n(passing a single array instead of a tuple), it doesn't break on the main branch.\r\n\r\n### Operating system\r\n\r\nUnbuntu\r\n\r\n### Matplotlib Version\r\n\r\n3.5.0\r\n\r\n### Matplotlib Backend\r\n\r\nnot relevant (I get an identical error with the 'agg' backend)\r\n\r\n### Python version\r\n\r\ntested on 3.7 to 3.9\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/neutrinoceros","@type":"Person","name":"neutrinoceros"},"datePublished":"2021-11-18T14:28:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":18},"url":"https://github.com/21669/matplotlib/issues/21669"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:84b7c4c4-9637-c69b-165a-16e0c639d1f6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA00:113CA7:2D43C37:3D2894C:6A53C2D2 |
| html-safe-nonce | 00f1f663f32d2b3c6a4da9578729c0515f88113a5d3191883c7c7c78047c754c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTAwOjExM0NBNzoyRDQzQzM3OjNEMjg5NEM6NkE1M0MyRDIiLCJ2aXNpdG9yX2lkIjoiOTE4OTU1ODU1MTM5MTIyNDUzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c142c089caa462db9eed97afba338c020a64cfe9c7757c4ba522356bb932ffda |
| hovercard-subject-tag | issue:1057421750 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/21669/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6b7238a7ffeeb11f5a8f5b8342b63fc27d584fbb12cf46069c0da501a46748d/matplotlib/matplotlib/issues/21669 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6b7238a7ffeeb11f5a8f5b8342b63fc27d584fbb12cf46069c0da501a46748d/matplotlib/matplotlib/issues/21669 |
| og:image:alt | Bug summary Discovered this in unyt's daily CI jobs: https://github.com/yt-project/unyt/actions Code for reproduction import matplotlib.pyplot as plt import unyt as un un.matplotlib_support.enable(... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | neutrinoceros |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width