Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
tahseenadit committed May 14, 2024
2 parents cce52ed + 4c5caea commit d3acf64
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpython_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
pyversion: ["3.8", "3.9", "3.10", "3.11"]
pyversion: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- name: Linux py310 full
os: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypy_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest"]
pyversion: ["pypy-3.8", "pypy-3.9"]
os: ["ubuntu-latest", "macos-12"]
pyversion: ["pypy-3.8", "pypy-3.9", "pypy-3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up pypy
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!--next-version-placeholder-->

## v2.34.1 (2024-04-22)

### Fix

* Fix bug of #1068 that `getattr` cannot get attribute with index directly ([#1069](https://github.com/imageio/imageio/issues/1069)) ([`05f0b37`](https://github.com/imageio/imageio/commit/05f0b372a7010debb39d2e8a65aed40bf2840f90))

### Other

* Update pyav.py ([#1070](https://github.com/imageio/imageio/issues/1070)) ([`0bc584e`](https://github.com/imageio/imageio/commit/0bc584ea79eb008be141b4b03bcf088194e219ba))
* Trivial typo fixes ([#1072](https://github.com/imageio/imageio/issues/1072)) ([`9d1bced`](https://github.com/imageio/imageio/commit/9d1bced7703fc198f60b1d891cf85a10686822a7))

## v2.34.0 (2024-02-12)

### Feature
Expand Down
4 changes: 2 additions & 2 deletions docs/development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class to API calls using the plugin kwarg. For example::

**Installation**

To develop a new plugin, you can start off with a simple def install::
To develop a new plugin, you can start off with a simple dev install::
# 1. Fork the ImageIO repository

Expand Down Expand Up @@ -449,7 +449,7 @@ the file, define functions that have their name begin with ``test_`` (example:
``def test_png_reading():``) and fill them with code that uses your plugin.

Our main requirement for tests of new plugins is that they cover the full
plugin. Ideally, they also test readiing and writing of all supported formats,
plugin. Ideally, they also test reading and writing of all supported formats,
but this is not strictly necessary. Check the commands above for how to run
tests and check test coverage of your plugin.

Expand Down
2 changes: 1 addition & 1 deletion docs/formats/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Supported Formats
you can search this page using ``Ctrl+F`` and then type the name of
the extension or format.

ImageIO reads and writes images by deligating your request to one of many
ImageIO reads and writes images by delegating your request to one of many
backends. Example backends are pillow, ffmpeg, tifffile among others. Each
backend supports its own set of formats, which is how ImageIO manages to support
so many of them.
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/freezing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ because plugins are lazy-loaded upon first use for better platform support and
reduced loading times. This lazy-loading is an interesting case as (1) these
plugins are exactly the kind of thing that PyInstaller_ tries desperately to
avoid collecting to minimize package size and (2) these plugins are - by
themself - super lightweight and won't bloat the package.
themselves - super lightweight and won't bloat the package.

To add plugins to the application your first option is to add all of imageio to
your package, which will also include the plugins. This can be done by using a
Expand Down
2 changes: 1 addition & 1 deletion imageio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# flake8: noqa

__version__ = "2.34.0"
__version__ = "2.34.1"

import warnings

Expand Down
11 changes: 10 additions & 1 deletion imageio/plugins/_dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,16 @@ def _append(self, dcm):
self._entries.append(dcm)

def _sort(self):
self._entries.sort(key=lambda k: k.InstanceNumber)
self._entries.sort(
key=lambda k: (
k.InstanceNumber,
(
k.ImagePositionPatient[2]
if hasattr(k, "ImagePositionPatient")
else None
),
)
)

def _finish(self):
"""
Expand Down
4 changes: 1 addition & 3 deletions imageio/plugins/pillow_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@
The number of iterations. Default 0 (meaning loop indefinitely).
duration : {float, list}
(Only available in GIF-PIL)
The duration (in seconds) of each frame. Either specify one value
The duration (in milliseconds) of each frame. Either specify one value
that is used for all frames, or one value for each frame.
Note that in the GIF format the duration/delay is expressed in
hundredths of a second, which limits the precision of the duration.
fps : float
(Only available in GIF-PIL)
The number of frames per second. If duration is not given, the
Expand Down
2 changes: 1 addition & 1 deletion imageio/plugins/pyav.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def init_video_stream(
Parameters
----------
codec : str
The codec to use, e.g. ``"x264"`` or ``"vp9"``.
The codec to use, e.g. ``"libx264"`` or ``"vp9"``.
fps : float
The desired framerate of the video stream (frames per second).
pixel_format : str
Expand Down
26 changes: 12 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def working_directory(path):


@pytest.fixture(scope="session")
def test_images(request):
def test_images(request, pytestconfig):
"""A collection of test images.
Note: The images are cached persistently (across test runs) in
Expand All @@ -81,6 +81,7 @@ def test_images(request):
# downloaded once in the beginning

checkout_dir = request.config.cache.get("imageio_test_binaries", None)
use_internet = "not needs_internet" not in pytestconfig.getoption("-m")

if checkout_dir is not None and not Path(checkout_dir).exists():
# cache value set, but cache is gone :( ... recreate
Expand All @@ -90,6 +91,8 @@ def test_images(request):
# download test images and other binaries
checkout_dir = Path(__file__).parents[1] / ".test_images"

if not checkout_dir.exists() and not use_internet:
pytest.skip("Internet use disabled and `.test_images` not found.")
try:
checkout_dir.mkdir()
except FileExistsError:
Expand All @@ -103,14 +106,15 @@ def test_images(request):

checkout_dir = Path(checkout_dir)

with working_directory(checkout_dir):
result = os.system("git pull")
if use_internet:
with working_directory(checkout_dir):
result = os.system("git pull")

if result != 0:
request.config.cache.set("imageio_test_binaries", None)
raise RuntimeError(
"Cache directory is corrupt. Delete `.test_images` at project root."
)
if result != 0:
request.config.cache.set("imageio_test_binaries", None)
raise RuntimeError(
"Cache directory is corrupt. Delete `.test_images` at project root."
)

return checkout_dir

Expand Down Expand Up @@ -175,12 +179,6 @@ def tmp_userdir(tmp_path):
del os.environ[user_dir_env]


def pytest_collection_modifyitems(items):
for item in items:
if "test_images" in getattr(item, "fixturenames", ()):
item.add_marker("needs_internet")


def deprecated_test(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
Expand Down
12 changes: 12 additions & 0 deletions tests/test_dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,15 @@ def test_v3_reading(test_images):
actual = iio3.imread(test_images / "dicom_file01.dcm")

assert np.allclose(actual, expected)


def test_contiguous_dicom_series(test_images, tmp_path):
# this is a regression test for
# https://github.com/imageio/imageio/issues/1067
fname = test_images / "dicom_issue_1067.zip"
with ZipFile(fname) as zip_ref:
zip_ref.extractall(tmp_path)

dname = tmp_path / "modified_dicom_sample1"
ims = iio.volread(dname, "DICOM")
assert ims.shape == (25, 512, 512)
5 changes: 5 additions & 0 deletions tests/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"imageio_ffmpeg", reason="imageio-ffmpeg is not installed"
)

try:
imageio_ffmpeg.get_ffmpeg_version()
except RuntimeError:
pytest.skip("No compatible FFMPEG binary could be found.", allow_module_level=True)


def get_ffmpeg_pids():
pids = set()
Expand Down
8 changes: 7 additions & 1 deletion tests/test_ffmpeg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
import imageio
import sys

imageio_ffmpeg = pytest.importorskip(
"imageio_ffmpeg", reason="imageio-ffmpeg is not installed"
)

pytest.importorskip("imageio_ffmpeg", reason="imageio-ffmpeg is not installed")
try:
imageio_ffmpeg.get_ffmpeg_version()
except RuntimeError:
pytest.skip("No compatible FFMPEG binary could be found.", allow_module_level=True)


def dedent(text, dedent=8):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_freeimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ def setup_library(tmp_path_factory, vendored_lib):
add = core.appdata_dir("imageio")
os.makedirs(add, exist_ok=True)
shutil.copytree(vendored_lib, os.path.join(add, "freeimage"))

try:
fi.load_freeimage()
assert fi.has_lib(), "imageio-binaries' version of libfreeimage was not found"
except OSError:
pytest.skip("Could not find a compatible FreeImage version for this OS.")

yield

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pyav.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ def test_bayer_write():

def test_sequential_reading(test_images):
expected_imgs = [
iio.imread(test_images / "cockatoo.mp4", index=1),
iio.imread(test_images / "cockatoo.mp4", index=5),
iio.imread(test_images / "cockatoo.mp4", plugin="pyav", index=1),
iio.imread(test_images / "cockatoo.mp4", plugin="pyav", index=5),
]

with iio.imopen(test_images / "cockatoo.mp4", "r", plugin="pyav") as img_file:
Expand Down

0 comments on commit d3acf64

Please sign in to comment.