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

bug-fix: Numpy ValueError when cheking empty list equality #459

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

ajadczaksunriselabs
Copy link
Contributor

Using the equality operator with an empty list will result in the following error.

ValueError: operands could not be broadcast together with shapes (28,) (0,)

Using len() and inverting the logic avoids this issue.

Using the equality operator with an empty list will result in the
following error.

ValueError: operands could not be broadcast together with shapes (28,) (0,)

Using len() and inverting the logic avoids this issue.
@ajadczaksunriselabs
Copy link
Contributor Author

No idea what is going on with the test failures here, but it doesn't seem to be entirely related to the changes I made...
I get test failures on main when executing the following steps:

  1. Created and activated a fresh python 3.11 venv
  2. Cloned the github.com/MIT-LCP/wfdb-python repo
  3. Navigated to the repo base director and ran pip install ".[dev]"
  4. Navigated to tests and ran pytest (I didn't see any specific instructions so this seemed like the logical thing to do)

image

Most of the failures seem to be related to missing test data
image

Maybe I missed a test in the test setup? If there are additional instructions for unit testing let me know and I'll try to figure out which of the failures are related to this pull request.

@tompollard
Copy link
Member

I haven't looked into the errors that you're seeing, but my guess is this is either a path issue or an operating system issue.

Typically I would expect to run pytest from the root of a project. Pytest will then iterate folders looking for tests. You may find that running pytest from the root of your project fixes the issue (because the files are now on the correct path).

If the approach above doesn't work, then it's possible that the tests are set up to run on a unix style operating system. If so, we would need to modify them to work on (Windows?).

@ajadczaksunriselabs
Copy link
Contributor Author

running pytest from the base directory does fix the file not found issues I was encountering and I'm getting much better results (or at least results that match python3.9 on debian on WSL).
image
image

The failures are identical between windows and debian (WSL) now
image

image

which is encouraging.

If I apply this patch and run pytest the correct way all test pass (with warnings) on both windows and debian.

image

image

So now I'm at a loss to why the CI is blowing up.

Benjamin Moody added 2 commits July 5, 2023 13:21
Currently, Python 3.7 in GitHub Actions (on macos-latest) appears to
be broken ("No module named '_bz2'").  Moreover, this version has now
reached its end of life.  Remove it from the test matrix.
Python 3.11 is the latest stable version; add it to the GitHub test
matrix.
@bemoody
Copy link
Collaborator

bemoody commented Jul 5, 2023

Thanks for your help!

So now I'm at a loss to why the CI is blowing up.

Yeah, the GitHub workflow error reporting is not great. In this case it looks like there is something severely broken in GitHub's version of Python 3.7 on MacOS ("No module named '_bz2'"). Perhaps relatedly, CPython 3.7 is now officially at its end of life.

At the same time, this numpy issue needs to be fixed in order for the other CI tests to pass.

Could you please run:

git fetch --all
git merge 07da4f48dad5cfc07420a061db4fd341a4e4a089

Copy link
Collaborator

@bemoody bemoody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@bemoody bemoody merged commit c0f1b12 into MIT-LCP:main Jul 5, 2023
lorepirri added a commit to AnacondaRecipes/wfdb-feedstock that referenced this pull request Oct 8, 2024
tompollard added a commit that referenced this pull request Jan 21, 2025
This pull request adds a changelog for `v4.2.0`. The changelog is based
on the following auto-generated summary of merge commits generated by
GitHub:

```
## What's Changed

* bug-fix: Numpy ValueError when cheking empty list equality by @ajadczaksunriselabs in #459
* bug-fix: Pandas set indexing error by @ajadczaksunriselabs in #460
* fix for /issues/452 by @tecamenz in #465
* Use numpydoc to render documentation by @SnoopJ in #472
* build(deps): bump readthedocs-sphinx-search from 0.1.1 to 0.3.2 in /docs by @dependabot in #477
* Update style by @bemoody in #482
* Fix NaN handling in Record.adc, and other fixes by @bemoody in #481
* Set upper bound on Numpy version (numpy = ">=1.10.1,<2.0.0"). Ref #493. by @tompollard in #494
* Update actions to use actions/checkout@v3 and actions/setup-python@v4. by @tompollard in #495
* Fix: Indent code to ensure 'j' is within for-loop in GQRS algorithm by @tompollard in #499
* Add write_dir argument to csv_to_wfdb. Fixes #67. by @tompollard in #492
* Fix warnings by @cbrnr in #502
* README improvements by @bemoody in #503
* Change in type promotion. Fixes to annotation.py by @tompollard in #506
* Use uv by @cbrnr in #504
* Change in type promotion. Fixes to _signal.py by @tompollard in #507
* Test round-trip write/read of supported binary formats by @bemoody in #509
* Corrected typo and extended allowed types for MultiSegmentRecord by @agent3gatech in #514
* Allow expanded physical signal in `calc_adc_params` by @briangow in #512
* Add capability to write signal with unique `samps_per_frame` to `wfdb.io.wrsamp` by @briangow in #510
* Fix selection of channels when converting to EDF by @SamJelfs in #519
* Change in type promotion introduced in Numpy 2.0. Fixes to edf.py. by @tompollard in #527
* Bump dependencies for NumPy 2 compatibility by @cbrnr in #511
* Bump version to v4.2.0 and update notes on creating new releases by @tompollard in #497

## New Contributors

* @ajadczaksunriselabs made their first contribution in #459
* @tecamenz made their first contribution in #465
* @SnoopJ made their first contribution in #472
* @dependabot made their first contribution in #477
* @agent3gatech made their first contribution in #514
* @SamJelfs made their first contribution in #519

**Full Changelog**: v4.1.2...v4.2.0
```
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