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

Fix failing image scalebar export test #359

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Jan 19, 2025

Fix for failure with matplotlib development version - from https://github.com/hyperspy/hyperspy-extensions-list/actions/runs/12849344100/job/35838748193:

=================================== FAILURES ===================================
__________________________ test_export_scalebar[gif] ___________________________
[gw0] linux -- Python 3.12.8 /home/runner/miniconda3/envs/test/bin/python

ext = 'gif'
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-1/popen-gw0/test_export_scalebar_gif_0')

    @pytest.mark.skipif(
        Version(imageio.__version__) < Version("2.23"),
        reason="needs imageio >=2.23",
    )
    @pytest.mark.parametrize(("ext"), ["png", "bmp", "gif", "jpg"])
    def test_export_scalebar(ext, tmp_path):
        hs = pytest.importorskip("hyperspy.api", reason="hyperspy not installed")
        pytest.importorskip("matplotlib_scalebar")
        # Use np.uint8 to be able to save as BMP
        pixels = 64
        data = np.arange(pixels**2).reshape((pixels, pixels)).astype(np.uint8)
        s = hs.signals.Signal2D(data)
        s.axes_manager[0].units = "nm"
        s.axes_manager[1].units = "nm"
    
        filename = tmp_path / f"test_scalebar_export.{ext}"
        if ext in ["bmp", "gif"]:
>           with pytest.raises(ValueError):
E           Failed: DID NOT RAISE <class 'ValueError'>

../../../miniconda3/envs/test/lib/python3.12/site-packages/rsciio/tests/test_image.py:118: Failed

Progress of the PR

  • Replace hardcoded list with supported file types from matplotlib,
  • [n/a] update docstring (if appropriate),
  • [n/a] update user guide (if appropriate),
  • [n/a] add a changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • [n/a] Check formatting of the changelog entry (and eventual user guide changes) in the docs/readthedocs.org:rosettasciio build of this PR (link in github checks)
  • update tests,
  • ready for review.

Copy link

codecov bot commented Jan 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.84%. Comparing base (8a420af) to head (a003297).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #359   +/-   ##
=======================================
  Coverage   87.84%   87.84%           
=======================================
  Files          85       85           
  Lines       11246    11246           
  Branches     2084     2084           
=======================================
  Hits         9879     9879           
  Misses        868      868           
  Partials      499      499           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jlaehne jlaehne modified the milestones: v7.3.2, v0.8, v0.7.2 Jan 19, 2025
@jlaehne jlaehne merged commit 6813ec9 into hyperspy:main Jan 19, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants