Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: check-case-conflict

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
rev: v0.16.2
hooks:
- id: ruff
args: [--fix, --show-fixes, --exit-non-zero-on-fix]
2 changes: 1 addition & 1 deletion src/cooler/_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _greedy_prune_partition(edges: np.ndarray, maxlen: int) -> np.ndarray:
edges = np.asarray(edges)
assert len(edges) >= 2 and edges[0] == 0
cumlen = np.r_[0, np.cumsum(np.diff(edges))]
cuts = [maxlen * i for i in range(0, int(np.ceil(cumlen[-1] / maxlen)))]
cuts = [maxlen * i for i in range(int(np.ceil(cumlen[-1] / maxlen)))]
cuts.append(cumlen[-1])
idx = np.unique(np.searchsorted(cumlen, cuts))
return edges[idx]
Expand Down
3 changes: 1 addition & 2 deletions src/cooler/cli/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,4 @@ def dump(
na_rep=na_rep,
)

else:
f.flush()
f.flush()
2 changes: 1 addition & 1 deletion src/cooler/core/_rangequery.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def __call__(

# Concatenate outputs
if len(result["bin1_id"]):
for key in result.keys():
for key in result:
result[key] = np.concatenate(result[key], axis=0)

if reflect:
Expand Down
2 changes: 1 addition & 1 deletion src/cooler/create/_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def _set_h5opts(h5opts: dict[str, Any]) -> dict[str, Any]:
"fillvalue",
"track_times",
}
for key in result.keys():
for key in result:
if key not in available_opts:
raise ValueError(f"Unknown storage option '{key}'.")
result.setdefault("compression", "gzip")
Expand Down
2 changes: 1 addition & 1 deletion src/cooler/sandbox/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def read_table(group_uri, keys=None, chunksize=10_000_000, index=None, lock=None

# Build the task graph
dsk = {}
for i in range(0, ceil(nrows / chunksize)):
for i in range(ceil(nrows / chunksize)):
slc = slice(i * chunksize, (i + 1) * chunksize)
data_dict = (_slice_group, filepath, grouppath, keys, slc, lock)
if categoricals:
Expand Down
2 changes: 1 addition & 1 deletion src/cooler/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def parse_region(
return chrom, start, end


def natsort_key(s: str, _NS_REGEX=re.compile(r"(\d+)", re.U)) -> tuple:
def natsort_key(s: str, _NS_REGEX=re.compile(r"(\d+)", re.UNICODE)) -> tuple:
return tuple([int(x) if x.isdigit() else x for x in _NS_REGEX.split(s) if x])


Expand Down
10 changes: 4 additions & 6 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,13 @@ def test_hdf5_contextmanagers():
assert f.id

# can't change mode on open file
with pytest.raises(ValueError):
with util.open_hdf5(f, "r+"):
pass
with pytest.raises(ValueError), util.open_hdf5(f, "r+"):
pass

# not allowed on open files
for mode in ["w", "w-", "x"]:
with pytest.raises(ValueError):
with util.open_hdf5(f, mode):
pass
with pytest.raises(ValueError), util.open_hdf5(f, mode):
pass

# group's parent file gets closed on teardown
with util.closing_hdf5(f["chroms"]):
Expand Down