Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmoore committed Dec 18, 2024
2 parents 0ec0b30 + 4be0a8b commit 8f58ab0
Show file tree
Hide file tree
Showing 29 changed files with 410 additions and 253 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12']
os: ['windows-latest', 'macos-latest', 'ubuntu-latest']
steps:
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,9 @@ jobs:
run: tox --conf tox.ini

- name: Upload code coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.xml
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions .github/workflows/pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
fail-fast: false
matrix:
include:
- {os: windows-latest, python_Version: '3.9', toxenv: 'py39'}
- {os: macos-latest, python_Version: '3.8', toxenv: 'py38'}
- {os: windows-latest, python_Version: '3.11', toxenv: 'py311'}
- {os: macos-latest, python_Version: '3.10', toxenv: 'py310'}

steps:
- uses: actions/checkout@v4
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/precommit.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Build a binary wheel and a source tarball
run: |
python -mpip install wheel build
python -mpip install build
python -m build
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.3.0
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
password: ${{ secrets.PYPI_PASSWORD }}
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[settings]
known_third_party = dask,numcodecs,numpy,pytest,scipy,skimage,zarr
known_third_party = dask,fsspec,numcodecs,numpy,pytest,scipy,skimage,zarr
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
Expand Down
19 changes: 10 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.10.0
hooks:
- id: black
args: [--target-version=py36]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
rev: v3.19.0
hooks:
- id: pyupgrade
args:
- --py36-plus
- --py39-plus

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: .bumpversion.cfg
Expand All @@ -45,14 +45,14 @@ repos:
- --autofix

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [
# flake8-blind-except, FIXME
flake8-builtins,
flake8-rst-docstrings,
flake8-logging-format,
# flake8-logging-format, FIXME
]
args: [
# default black line length is 88
Expand All @@ -61,12 +61,13 @@ repos:
# Conflicts with PEP8 and black:
# W503 line break before binary operator
# Does not recognize deprecated directive in docstrings
"--ignore=E203,RST303, W503",
"--ignore=E203,RST303,W503",
"--builtins-allowed-modules=csv,io,types",
"--rst-roles=class,func,ref,mod,meth,const",
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.13.0
hooks:
- id: mypy
args: [--config-file=mypy.ini]
Expand All @@ -79,6 +80,6 @@ repos:
#

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# 0.8.4 (unreleased)
# Unreleased

- Drop support for Python 3.8.
- Document parameters and return value of `parse_url`.

# 0.9.0 (May 2024)

- Correctly specify maximum compatible fsspec version. ([#338](https://github.com/ome/ome-zarr-py/pull/338))
- Add tests on Python 3.12. ([#338](https://github.com/ome/ome-zarr-py/pull/338))
- Write OMERO metadata. ([#261](https://github.com/ome/ome-zarr-py/pull/261))
- Fixed chunking when a scalar value for chunks is given. Previously
passing ``storage_options={"chunks": <int>}`` only set the chunk
size of the final dimension. Now the chunk size of all dimensions is
set to this value, which is identical behaviour to ``zarr-python``.
([#365](https://github.com/ome/ome-zarr-py/pull/365))

# 0.8.3 (November 2023)

Expand Down
8 changes: 1 addition & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ome-zarr-py

Tools for multi-resolution images stored in Zarr filesets, according to the `OME NGFF spec`_.

See `Documentation <https://ome-zarr.readthedocs.io/>`_ for usage information.
See `Readthedocs <https://ome-zarr.readthedocs.io/>`_ for usage information.

Documentation
-------------
Expand Down Expand Up @@ -56,13 +56,7 @@ Distributed under the terms of the `BSD`_ license,
"ome-zarr-py" is free and open source software

.. _`OME NGFF spec`: https://github.com/ome/ngff
.. _`@napari`: https://github.com/napari
.. _`BSD`: https://opensource.org/licenses/BSD-2-Clause
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0
.. _`Mozilla Public License 2.0`: https://www.mozilla.org/media/MPL/2.0/index.txt
.. _`napari`: https://github.com/napari/napari
.. _`napari-ome-zarr`: https://github.com/ome/napari-ome-zarr
.. _`ome-zarr`: https://pypi.org/project/ome-zarr/

.. |pypi| image:: https://badge.fury.io/py/ome-zarr.svg
:alt: PyPI project
Expand Down
53 changes: 29 additions & 24 deletions docs/source/cli.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. highlight:: bash


Command-line tool
-----------------
Expand All @@ -7,50 +9,53 @@ The examples below use the image at http://idr.openmicroscopy.org/webclient/?sho

All examples can be made more or less verbose by passing `-v` or `-q` one or more times::

# ome_zarr -vvv ...
ome_zarr -vvv ...


info
====

Use the `ome_zarr` command to interrogate Zarr datasets::
Use the `ome_zarr` command to interrogate Zarr datasets.

Remote data::

# Remote data
$ ome_zarr info https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/
ome_zarr info https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/

# Local data (after downloading as below)
$ ome_zarr info 6001240.zarr/
Local data::

ome_zarr info 6001240.zarr/

view
====

Use the `ome_zarr` command to view Zarr data in the https://ome.github.io/ome-ngff-validator::

# Local data (after downloading as below)
$ ome_zarr view 6001240.zarr/
ome_zarr view 6001240.zarr/

download
========

To download all the resolutions and metadata for an image::
To download all the resolutions and metadata for an image use ``ome_zarr download``. This creates ``6001240.zarr`` locally::

ome_zarr download https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/

# creates local 6001240.zarr/
$ ome_zarr download https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/
Specify a different output directory::

# Specify output directory
$ ome_zarr download https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/ --output image_dir
ome_zarr download https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr/ --output image_dir

create
======

To create sample OME-Zarr image from the `skimage coins <https://scikit-image.org/docs/stable/api/skimage.data.html#skimage.data.coins>`_
image::
To create sample OME-Zarr image from the `skimage <https://scikit-image.org/docs/stable/api/skimage.data.html>`_
data.

# Create an OME-Zarr image in coinsdata/ dir:
$ ome_zarr create coinsdata
Create an OME-Zarr image in coinsdata/ dir::

# Create an rgb image from skimage astronaut in testimage dir:
$ ome_zarr create testimage --method=astronaut
ome_zarr create coinsdata

Create an rgb image from skimage astronaut in testimage dir::

ome_zarr create testimage --method=astronaut

csv to labels
=============
Expand All @@ -75,13 +80,13 @@ to specify the data-type for each column (string by default).
- `s`: `StringColumn`, for text
- `b`: `BoolColumn`, for true/false

Use e.g. `#d` as a suffix in the column name to denote a `float` column, no spaces etc.:
```
"area#d,label_text#s,Width#l,Height#l"
```
Use e.g. `#d` as a suffix in the column name to denote a `float` column, no spaces etc.::

"area#d,label_text#s,Width#l,Height#l"


For example, to take values from columns named `area`, `label_text`, `Width` and `Height`
within a CSV file named `labels_data.csv` with an ID column named `shape_id` and add these
values to label properties with an ID key of `omero:shapeId` in an Image or Plate named `123.zarr`::

ome_zarr csv_to_labels labels_data.csv shape_id "area#d,label_text#s,Width#l,Height#l" 123.zarr omero:shapeId```
ome_zarr csv_to_labels labels_data.csv shape_id "area#d,label_text#s,Width#l,Height#l" 123.zarr omero:shapeId
2 changes: 0 additions & 2 deletions docs/source/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ The following code creates a 3D Image in OME-Zarr::

import numpy as np
import zarr
import os

from ome_zarr.io import parse_url
from ome_zarr.writer import write_image

path = "test_ngff_image.zarr"
os.mkdir(path)

size_xy = 128
size_z = 10
Expand Down
14 changes: 7 additions & 7 deletions ome_zarr/axes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Axes class for validating and transforming axes
"""

from typing import Any, Dict, List, Union
from typing import Any, Union

from .format import CurrentFormat, Format

Expand All @@ -11,7 +11,7 @@
class Axes:
def __init__(
self,
axes: Union[List[str], List[Dict[str, str]]],
axes: Union[list[str], list[dict[str, str]]],
fmt: Format = CurrentFormat(),
) -> None:
"""
Expand Down Expand Up @@ -41,15 +41,15 @@ def validate(self) -> None:

def to_list(
self, fmt: Format = CurrentFormat()
) -> Union[List[str], List[Dict[str, str]]]:
) -> Union[list[str], list[dict[str, str]]]:
if fmt.version == "0.3":
return self._get_names()
return self.axes

@staticmethod
def _axes_to_dicts(
axes: Union[List[str], List[Dict[str, str]]]
) -> List[Dict[str, str]]:
axes: Union[list[str], list[dict[str, str]]]
) -> list[dict[str, str]]:
"""Returns a list of axis dicts with name and type"""
axes_dicts = []
for axis in axes:
Expand All @@ -74,7 +74,7 @@ def _validate_axes_types(self) -> None:
"Too many unknown axes types. 1 allowed, found: %s" % unknown_types
)

def _last_index(item: str, item_list: List[Any]) -> int:
def _last_index(item: str, item_list: list[Any]) -> int:
return max(loc for loc, val in enumerate(item_list) if val == item)

if "time" in axes_types and _last_index("time", axes_types) > 0:
Expand All @@ -88,7 +88,7 @@ def _last_index(item: str, item_list: List[Any]) -> int:
) > axes_types.index("space"):
raise ValueError("'space' axes must come after 'channel'")

def _get_names(self) -> List[str]:
def _get_names(self) -> list[str]:
"""Returns a list of axis names"""
axes_names = []
for axis in self.axes:
Expand Down
4 changes: 2 additions & 2 deletions ome_zarr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import argparse
import logging
import sys
from typing import List, Union
from typing import Union

from .csv import csv_to_zarr
from .data import astronaut, coins, create_zarr
Expand Down Expand Up @@ -81,7 +81,7 @@ def csv_to_labels(args: argparse.Namespace) -> None:
csv_to_zarr(args.csv_path, args.csv_id, args.csv_keys, args.zarr_path, args.zarr_id)


def main(args: Union[List[str], None] = None) -> None:
def main(args: Union[list[str], None] = None) -> None:
"""Run appropriate function with argparse arguments, handling errors."""
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down
6 changes: 2 additions & 4 deletions ome_zarr/conversions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Simple conversion helpers."""

from typing import List


def int_to_rgba(v: int) -> List[float]:
def int_to_rgba(v: int) -> list[float]:
"""Get rgba (0-1) e.g. (1, 0.5, 0, 1) from integer.
>>> print(int_to_rgba(0))
[0.0, 0.0, 0.0, 0.0]
Expand All @@ -13,7 +11,7 @@ def int_to_rgba(v: int) -> List[float]:
return [x / 255 for x in v.to_bytes(4, signed=True, byteorder="big")]


def int_to_rgba_255(v: int) -> List[int]:
def int_to_rgba_255(v: int) -> list[int]:
"""Get rgba (0-255) from integer.
>>> print(int_to_rgba_255(0))
[0, 0, 0, 0]
Expand Down
Loading

0 comments on commit 8f58ab0

Please sign in to comment.