Skip to content

Tolerate an empty BarGraphItem#2658

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
jmakovicka:master
Apr 13, 2023
Merged

Tolerate an empty BarGraphItem#2658
j9ac9k merged 1 commit intopyqtgraph:masterfrom
jmakovicka:master

Conversation

@jmakovicka
Copy link
Copy Markdown
Contributor

Sometimes, it is useful to be able to create an empty BarGraphItem to be populated later using setOpts, like

bg = pg.BarGraphItem(
x0=[], height=[], y0=[], width=[],
pen=...,
brush=...
)

Avoid NumPy ValueError when computing np.max/min from and empty array in this case.

Detail the reasoning behind the code change. If there is an associated issue that this PR will resolve add

Fixes #

Other Tasks

Bump Dependency Versions

Files that need updates

Confirm the following files have been either updated or there has been a determination that no update is needed.

  • README.md
  • setup.py
  • tox.ini
  • .github/workflows/main.yml and associated requirements.txt and conda environemt.yml files
  • pyproject.toml
  • binder/requirements.txt
Pre-Release Checklist

Pre Release Checklist

  • Update version info in __init__.py
  • Update CHANGELOG primarily using contents from automated changelog generation in GitHub release page
  • Have git tag in the format of pyqtgraph-
Post-Release Checklist

Steps To Complete

  • Append .dev0 to __version__ in __init__.py
  • Announce on mail list
  • Announce on Twitter

Sometimes, it is useful to be able to create an empty BarGraphItem
to be populated later using setOpts, like

bg = pg.BarGraphItem(
    x0=[], height=[], y0=[], width=[],
    pen=...,
    brush=...
)

Avoid NumPy ValueError when computing np.max/min from and empty array
in this case.
@jmakovicka jmakovicka changed the title Tolerate an emptyBarGraphItem Tolerate an empty BarGraphItem Mar 22, 2023
@pijyoi
Copy link
Copy Markdown
Contributor

pijyoi commented Mar 27, 2023

In a way, this fixes a regression of #2599.

Firstly, it has never been possible to create BarGraphItem() with no arguments.
However, prior to #2599, it was possible to create an empty data BarGraphItem(x0=[], y0=[], width=0, height=0)

What is currently possible is to create a single zero area rectangle BarGraphItem(x0=[0], y0=[0], width=0, height=0)

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Apr 13, 2023

Hi @jmakovicka

This PR LGTM, sorry it took so long before someone chimed in. Merging!

@j9ac9k j9ac9k merged commit 7e35570 into pyqtgraph:master Apr 13, 2023
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

Successfully merging this pull request may close these issues.

3 participants