Skip to content

Commit 0e84970

Browse files
committed
linting and include with docs
1 parent aec6380 commit 0e84970

File tree

5 files changed

+65
-37
lines changed

5 files changed

+65
-37
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515
- id: check-yaml
1616
- id: detect-private-key
1717
- repo: https://github.com/tox-dev/pyproject-fmt
18-
rev: "v2.21.0"
18+
rev: "v2.21.1"
1919
hooks:
2020
- id: pyproject-fmt
2121
- repo: https://github.com/codespell-project/codespell
@@ -50,7 +50,7 @@ repos:
5050
hooks:
5151
- id: actionlint
5252
- repo: https://github.com/astral-sh/ruff-pre-commit
53-
rev: "v0.15.8"
53+
rev: "v0.15.10"
5454
hooks:
5555
- id: ruff-format
5656
- id: ruff-check

docs/src/examples.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Examples
22

3+
Featured example:
4+
[OME Arrow and CytoDataFrame](examples/omearrow_and_cytodataframe)
5+
36
```{toctree}
47
---
58
caption: "List of examples"

docs/src/examples/omearrow_and_cytodataframe.ipynb

Lines changed: 32 additions & 17 deletions
Large diffs are not rendered by default.

docs/src/examples/omearrow_and_cytodataframe.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,47 @@
1212
# name: python3
1313
# ---
1414

15+
# # OME-Arrow and CytoDataFrame
16+
#
17+
# This notebook demonstrates how [OME-Arrow](https://github.com/WayScience/ome-arrow) works in context with CytoDataFrame.
18+
1519
# + colab={"base_uri": "https://localhost:8080/", "height": 423} id="Y5e85t05nSLt" outputId="a0807c7c-4705-41a2-83b2-9fb7287c40f9"
20+
import pyarrow as pa
21+
import pyarrow.parquet as pq
1622
from ome_arrow import OMEArrow
1723

24+
from cytodataframe import CytoDataFrame
25+
1826
# load a tiff using OME Arrow
19-
oa_img = OMEArrow("../../../tests/data/cytotable/JUMP_plate_BR00117006/images/orig/r01c01f01p01-ch2sk1fk1fl1.tiff")
27+
oa_img = OMEArrow(
28+
"../../../tests/data/cytotable/JUMP_plate_BR00117006/images/orig/r01c01f01p01-ch2sk1fk1fl1.tiff"
29+
)
2030
oa_img
2131

2232
# + colab={"base_uri": "https://localhost:8080/", "height": 423} id="wkCpuZEBosNV" outputId="4adee883-9707-40a4-92ab-2ee748bbcf76"
23-
# make a slice from the overall image
24-
oa_img_slice = oa_img.slice(x_min=240,x_max=310,y_min=360,y_max=430)
33+
# make a "slice" (crop) from the overall image
34+
oa_img_slice = oa_img.slice(x_min=240, x_max=310, y_min=360, y_max=430)
2535
oa_img_slice
2636

2737
# + colab={"base_uri": "https://localhost:8080/"} id="ZZ8LWIuQqQqz" outputId="f82de1df-3240-4dba-d0a0-6a4ce973f299"
2838
# show the OME Arrow struct
2939
oa_img_slice.data
3040

3141
# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="zcaDHeNorxCt" outputId="e64c061b-c56e-462b-dfe0-c73de76df0d3"
32-
import pyarrow as pa
33-
import pyarrow.parquet as pq
34-
from cytodataframe import CytoDataFrame
35-
3642
# create a pyarrow table for writing the data
37-
table = pa.table({
38-
"metadata_1": pa.array([0, 2], type=pa.int64()),
39-
"feature_1": pa.array([1, 2], type=pa.int64()),
40-
# add an image column with repeated entries based on the image slice
41-
"image": pa.repeat(oa_img_slice.data, 2),
42-
})
43+
table = pa.table(
44+
{
45+
# two columns, two values each, both int64 type
46+
"metadata_1": pa.array([0, 2], type=pa.int64()),
47+
"feature_1": pa.array([1, 2], type=pa.int64()),
48+
# add an image column with repeated entries based on the image slice
49+
"image": pa.repeat(oa_img_slice.data, 2),
50+
}
51+
)
4352

4453
# write a parquet table
4554
pq.write_table(table, "example.ome.parquet")
4655

4756
# read the parquet table with cytodataframe
57+
# (showing the OME-Arrow image that was written)
4858
CytoDataFrame("example.ome.parquet")

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ lint.select = [
110110
]
111111
# Ignore `E402` and `F401` (unused imports) in all `__init__.py` files
112112
lint.per-file-ignores."__init__.py" = [ "E402", "F401" ]
113-
lint.per-file-ignores."docs/src/examples/cytodataframe_at_a_glance.py" = [ "E402" ]
113+
lint.per-file-ignores."docs/src/examples/*.py" = [ "E402", "E501" ]
114114
lint.per-file-ignores."src/cytodataframe/*.py" = [ "ANN401", "PLC0415" ]
115115
lint.per-file-ignores."src/cytodataframe/image.py" = [ "PLR2004" ]
116116
# ignore typing rules for tests
117117
lint.per-file-ignores."tests/*" = [ "ANN201", "PLR0913", "PLR2004", "SIM105" ]
118118

119+
# specify where version replacement is performed
120+
[tool.bandit]
121+
exclude_dirs = [ "tests" ]
122+
119123
[tool.pytest]
120124
ini_options.addopts = "--cov=src/cytodataframe --cov-report=term-missing:skip-covered --no-cov-on-fail"
121125

@@ -130,10 +134,6 @@ run.omit = [
130134
[tool.jupytext]
131135
formats = "ipynb,py:light"
132136

133-
# specify where version replacement is performed
134-
[tool.bandit]
135-
exclude_dirs = [ "tests" ]
136-
137137
[tool.poe]
138138
# note: quarto commands below expect quarto installed on the local system.
139139
# see here for more information: https://quarto.org/docs/download/

0 commit comments

Comments
 (0)