Skip to content

Commit

Permalink
Pre-commit hooks (#193)
Browse files Browse the repository at this point in the history
* Add pre-commit hooks

* Specify explicitly all exportable names from tiledbsc and remove the flake8 per-file-ignore

Reason: per-file-ignores paths are treated relative to the current directory, not the config file.
This breaks the flake8 pre-commit hook that is invoked from the project root.
See PyCQA/flake8#693

* Lint Python scripts outside of apis/python
  • Loading branch information
gsakkis authored Jun 30, 2022
1 parent 766f4d8 commit 067ad90
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ["--config", "apis/python/setup.cfg"]
2 changes: 0 additions & 2 deletions apis/python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,3 @@ known_third_party = anndata
statistics = true
ignore = E203,E501,W503,B950
select = B,C,E,F,W,T4,B9
per-file-ignores =
src/tiledbsc/__init__.py: F401
20 changes: 20 additions & 0 deletions apis/python/src/tiledbsc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,23 @@
from .uns_group import UnsGroup
from .util_ann import describe_ann_file
from .util_tiledb import show_soma_schemas

__all__ = [
"AnnotationMatrix",
"AnnotationMatrixGroup",
"AnnotationPairwiseMatrixGroup",
"AssayMatrix",
"AssayMatrixGroup",
"RawGroup",
"SOMA",
"SOMACollection",
"SOMAOptions",
"SOMASlice",
"TileDBArray",
"TileDBGroup",
"TileDBObject",
"UnsArray",
"UnsGroup",
"describe_ann_file",
"show_soma_schemas",
]
28 changes: 12 additions & 16 deletions data/simple/ij_test1/gen.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import tiledb, numpy as np
from tiledb import *
import numpy as np
import tiledb

# Reference/label array

s1 = ArraySchema(
domain=Domain(
*[
Dim(name="z_name", tile=None, dtype="ascii"),
]
s1 = tiledb.ArraySchema(
domain=tiledb.Domain(
tiledb.Dim(name="z_name", tile=None, dtype="ascii"),
),
attrs=[
Attr(name="z_idx", dtype="uint32", var=False, nullable=False),
tiledb.Attr(name="z_idx", dtype="uint32", var=False, nullable=False),
],
cell_order="row-major",
tile_order="row-major",
capacity=10000,
sparse=True,
allows_duplicates=True,
coords_filters=FilterList([ZstdFilter(level=-1)]),
coords_filters=tiledb.FilterList([tiledb.ZstdFilter(level=-1)]),
)

tiledb.Array.create("ref", s1)
Expand All @@ -39,21 +37,19 @@

# Target array

s2 = ArraySchema(
domain=Domain(
*[
Dim(name="z_idx", domain=(0, 99), tile=10, dtype="uint32"),
]
s2 = tiledb.ArraySchema(
domain=tiledb.Domain(
tiledb.Dim(name="z_idx", domain=(0, 99), tile=10, dtype="uint32"),
),
attrs=[
Attr(name="data", dtype="int32", var=False, nullable=False),
tiledb.Attr(name="data", dtype="int32", var=False, nullable=False),
],
cell_order="row-major",
tile_order="row-major",
capacity=10000,
sparse=True,
allows_duplicates=False,
coords_filters=FilterList([ZstdFilter(level=-1)]),
coords_filters=tiledb.FilterList([tiledb.ZstdFilter(level=-1)]),
)

tiledb.Array.create("tgt", s2)
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-tiledb-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main(args):
filepath = os.path.realpath(filepath)
print(f"Updating {filepath}")
print(f" new version = {args.version}-{new_hash}")
print(f" computing SHA1 hashes...")
print(" computing SHA1 hashes...")

# all "print" statements in this "with" block go to the "fp" file
with FileInput(filepath, inplace=True) as fp:
Expand Down

0 comments on commit 067ad90

Please sign in to comment.