diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e6e271..4b02be3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] + python-version: [ "3,9", "3.10", "3.11", "3.12" ] include: - os: windows-latest python-version: "3.12" diff --git a/pyproject.toml b/pyproject.toml index e4dfeb4..8b2ac03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "cooler" version = "0.10.2" description = "Sparse binary format for genomic interaction matrices." -requires-python = ">=3.8" +requires-python = ">=3.9" license = {text = "BSD-3-Clause"} authors = [ {name = "Nezar Abdennur", email = "nabdennur@gmail.com"}, @@ -29,7 +29,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -39,7 +38,7 @@ classifiers = [ readme = "README.md" dependencies = [ - "numpy>=1.9, <2", + "numpy>=1.26,<3", "scipy>=0.16", "pandas>1.5", "h5py>=2.5", @@ -59,7 +58,7 @@ all = [ "ipytree>=0.2.2", "ipywidgets>=8.0.0", "matplotlib", - "pypairix; platform_system != 'Windows'", +# "pypairix; platform_system != 'Windows'", # doesn't compile, see 4dn-dcic/pairix#79 "psutil", "pysam; platform_system != 'Windows'", ] diff --git a/src/cooler/_reduce.py b/src/cooler/_reduce.py index 1117531..f184913 100644 --- a/src/cooler/_reduce.py +++ b/src/cooler/_reduce.py @@ -4,7 +4,8 @@ import warnings from bisect import bisect_right from collections import OrderedDict, defaultdict -from typing import Any, Iterator, Literal +from collections.abc import Iterator +from typing import Any, Literal import h5py import multiprocess as mp diff --git a/src/cooler/_typing.py b/src/cooler/_typing.py index 7802200..6660ee2 100644 --- a/src/cooler/_typing.py +++ b/src/cooler/_typing.py @@ -1,6 +1,7 @@ from __future__ import annotations -from typing import Callable, Dict, Iterable, Optional, Tuple, TypeVar, Union +from collections.abc import Iterable +from typing import Callable, Optional, TypeVar, Union import numpy as np import pandas as pd @@ -8,8 +9,8 @@ T = TypeVar('T') U = TypeVar('U') MapFunctor = Callable[[Callable[[T], U], Iterable[T]], Iterable[U]] -GenomicRangeSpecifier = Union[str , Tuple[str, Optional[int], Optional[int]]] -GenomicRangeTuple = Tuple[str, int, int] -Tabular = Union[pd.DataFrame, Dict[str, np.ndarray]] +GenomicRangeSpecifier = Union[str , tuple[str, Optional[int], Optional[int]]] +GenomicRangeTuple = tuple[str, int, int] +Tabular = Union[pd.DataFrame, dict[str, np.ndarray]] __all__ = ["GenomicRangeSpecifier", "GenomicRangeTuple", "MapFunctor", "Tabular"] diff --git a/src/cooler/core/_rangequery.py b/src/cooler/core/_rangequery.py index fce8198..0065b92 100644 --- a/src/cooler/core/_rangequery.py +++ b/src/cooler/core/_rangequery.py @@ -1,6 +1,7 @@ from __future__ import annotations -from typing import Any, Callable, Iterator +from collections.abc import Iterator +from typing import Any, Callable import h5py import numpy as np diff --git a/src/cooler/core/_selectors.py b/src/cooler/core/_selectors.py index ac4df5f..eb04f65 100644 --- a/src/cooler/core/_selectors.py +++ b/src/cooler/core/_selectors.py @@ -1,11 +1,11 @@ from __future__ import annotations -from typing import Any, Callable, List, Optional, Tuple, Union, overload +from typing import Any, Callable, Optional, Union, overload import pandas as pd -ColumnsArg = Optional[Union[str, List[str]]] -GenomicRangeArg = Optional[Union[str, Tuple[str, Optional[int], Optional[int]]]] +ColumnsArg = Optional[Union[str, list[str]]] +GenomicRangeArg = Optional[Union[str, tuple[str, Optional[int], Optional[int]]]] FieldArg = Optional[str] diff --git a/src/cooler/core/_tableops.py b/src/cooler/core/_tableops.py index 03ae814..7349ca8 100644 --- a/src/cooler/core/_tableops.py +++ b/src/cooler/core/_tableops.py @@ -102,7 +102,7 @@ def get( data[field] = pd.Categorical.from_codes( dset[lo:hi], sorted(dt, key=dt.__getitem__), ordered=True ) - elif dset.dtype.type == np.string_: + elif dset.dtype.type == np.bytes_: data[field] = dset[lo:hi].astype("U") else: data[field] = dset[lo:hi] diff --git a/src/cooler/create/_create.py b/src/cooler/create/_create.py index 3dd081a..6de4013 100644 --- a/src/cooler/create/_create.py +++ b/src/cooler/create/_create.py @@ -5,8 +5,9 @@ import posixpath import tempfile import warnings +from collections.abc import Iterable from datetime import datetime -from typing import Any, Iterable +from typing import Any import h5py import numpy as np diff --git a/src/cooler/create/_ingest.py b/src/cooler/create/_ingest.py index 33f152b..8124617 100644 --- a/src/cooler/create/_ingest.py +++ b/src/cooler/create/_ingest.py @@ -12,8 +12,9 @@ import warnings from bisect import bisect_left from collections import Counter, OrderedDict +from collections.abc import Iterator from functools import partial -from typing import Any, Callable, Iterator +from typing import Any, Callable import h5py import numpy as np @@ -112,8 +113,8 @@ def _sanitize_records( return chunk # Find positional anchor columns, convert to zero-based if needed - anchor1 = np.array(chunk[anchor_field + suffixes[0]]) - anchor2 = np.array(chunk[anchor_field + suffixes[1]]) + anchor1 = chunk[anchor_field + suffixes[0]].to_numpy(copy=True) + anchor2 = chunk[anchor_field + suffixes[1]].to_numpy(copy=True) if is_one_based: anchor1 -= 1 anchor2 -= 1 diff --git a/src/cooler/parallel.py b/src/cooler/parallel.py index 9bcbecd..bb28f66 100644 --- a/src/cooler/parallel.py +++ b/src/cooler/parallel.py @@ -5,8 +5,9 @@ """ from __future__ import annotations +from collections.abc import Iterable, Iterator, Sequence from functools import partial, reduce -from typing import Any, Callable, Iterable, Iterator, Sequence +from typing import Any, Callable from multiprocess import Lock diff --git a/src/cooler/util.py b/src/cooler/util.py index 0ad9954..d25b65e 100644 --- a/src/cooler/util.py +++ b/src/cooler/util.py @@ -3,8 +3,9 @@ import os import re from collections import OrderedDict, defaultdict +from collections.abc import Generator, Iterable, Iterator from contextlib import contextmanager -from typing import IO, Any, Generator, Iterable, Iterator +from typing import IO, Any import h5py import numpy as np @@ -627,7 +628,7 @@ def infer_meta(x, index=None): # pragma: no cover "m": np.timedelta64(1), "S": np.str_("foo"), "a": np.str_("foo"), - "U": np.unicode_("foo"), + "U": np.str_("foo"), "O": "foo", }