Skip to content

Commit 8c50da4

Browse files
authored
pyx fix for numpy and cython updates (#198)
1 parent 6ff4a5e commit 8c50da4

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Please see our [release notes](./RELEASE_NOTES.md) for the latest updates to Sel
88

99
## Installation
1010

11-
We recommend using Selene with Python 3.6 or above.
11+
We recommend using Selene with Python 3.9 or above.
1212
Package installation should only take a few minutes (less than 10 minutes, typically ~2-3 minutes) with any of these methods (conda, pip, source).
1313

1414
**First, install [PyTorch](https://pytorch.org/get-started/locally/).** If you have an NVIDIA GPU, install a version of PyTorch that supports it--Selene will run much faster with a discrete GPU.
15-
The library is currently compatible with PyTorch versions between 0.4.1 and 1.9.
15+
The library is currently compatible with PyTorch versions between 1.0.0 and 2.3.1.
1616
We will continue to update Selene to be compatible with the latest version of PyTorch.
1717

1818
### Installing selene with [Anaconda](https://www.anaconda.com/download/) (for Linux):
@@ -73,6 +73,10 @@ Join our [Google group](https://groups.google.com/forum/#!forum/selene-sdk) if y
7373
The documentation for Selene is available [here](https://selene.flatironinstitute.org/).
7474
If you are interested in running Selene through the command-line interface (CLI), [this document](https://selene.flatironinstitute.org/overview/cli.html) describes how the configuration file format (used by the CLI) works and details all the possible configuration parameters you may need to build your own configuration file.
7575

76+
**Important**: The tutorials and manuscript examples were originally run on Selene version 0.1.3---and later with Selene 0.2.0 (PyTorch version 0.4.1). Selene has since been updated substantially and files such as `selene-gpu.yml` specify PyTorch version 1.0.0. Please note that models created with an older version of PyTorch (such as those downloadable with the manuscript case studies) are NOT compatible with newer versions of PyTorch. If you run into errors loading trained model weights files, it is likely the result of differences in PyTorch or CUDA toolkit versions.
77+
78+
We recommend referring to the API documentation linked above, along with more current usages of Selene in related papers (e.g. [Sei framework code](https://github.com/FunctionLab/sei-framework)) as the easiest starting point as of right now.
79+
7680
## Examples
7781

7882
We provide 2 sets of examples: Jupyter notebook tutorials and case studies that we've described in our manuscript.
@@ -88,8 +92,6 @@ These examples reflect how we most often use Selene in our own projects, whereas
8892
We recommend that the examples be run on a machine with a CUDA-enabled GPU. All examples take significantly longer when run on a CPU machine.
8993
(See the following sections for time estimates.)
9094

91-
**Important**: The tutorials and manuscript examples were originally run on Selene version 0.1.3---and later with Selene 0.2.0 (PyTorch version 0.4.1). Selene has since been updated and files such as `selene-gpu.yml` specify PyTorch version 1.0.0. Please note that models created with an older version of PyTorch (such as those downloadable with the manuscript case studies) are NOT compatible with newer versions of PyTorch. If you run into errors loading trained model weights files, it is likely the result of differences in PyTorch or CUDA toolkit versions.
92-
9395
### Tutorials
9496

9597
Tutorials for Selene are available [here](https://github.com/FunctionLab/selene/tree/master/tutorials).

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This is a document describing new functionality, bug fixes, breaking changes, etc. associated with Selene version releases from v0.5.0 onwards.
44

5+
## Version 0.5.2
6+
- Fix Cython type error causing build issues with Python 3.9+
7+
8+
## Version 0.5.1
9+
- PyTorch<=1.9 compatibility
10+
511
## Version 0.5.0
612

713
### New functionality

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "numpy", "cython"]
2+
requires = ["setuptools", "wheel", "numpy>=1.26.4", "cython>=3.0.10"]
3+
4+
[tool.poetry.dependencies]
5+
python = ">=3.9"

selene_sdk/targets/_genomic_features.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import numpy as np
44
cimport cython
55
cimport numpy as np
66

7-
ctypedef np.int_t DTYPE_t
7+
ctypedef np.int64_t DTYPE_t
88
ctypedef np.float32_t FDTYPE_t
99

1010
@cython.boundscheck(False)
11-
@cython.wraparound(False)
11+
@cython.wraparound(False)
1212
def _fast_get_feature_data(int start,
1313
int end,
1414
np.ndarray[FDTYPE_t, ndim=1] thresholds,
@@ -18,14 +18,14 @@ def _fast_get_feature_data(int start,
1818
cdef int query_length = end - start
1919
cdef int feature_start, feature_end, index_start, index_end, index_feat
2020
cdef np.ndarray[DTYPE_t, ndim=2] encoding = np.zeros(
21-
(query_length, n_features), dtype=np.int)
21+
(query_length, n_features), dtype=np.int64)
2222
cdef np.ndarray[DTYPE_t, ndim=1] targets = np.zeros(
23-
n_features, dtype=np.int)
23+
n_features, dtype=np.int64)
2424
cdef list row
2525

2626
if rows is None:
2727
return np.zeros((n_features,))
28-
28+
2929
for row in rows:
3030
feature_start = int(row[1])
3131
feature_end = int(row[2])
@@ -37,6 +37,6 @@ def _fast_get_feature_data(int start,
3737
encoding[index_start:index_end, index_feat] = 1
3838

3939
thresholds = (thresholds * query_length - 1).clip(min=0)
40-
targets = (np.sum(encoding, axis=0) > thresholds.astype(int)).astype(int)
40+
targets = (np.sum(encoding, axis=0) > thresholds.astype(np.int64)).astype(np.int64)
4141
return targets
4242

selene_sdk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.0"
1+
__version__ = "0.5.2"

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
cmdclass = {'build_ext': build_ext}
2626

2727
setup(name="selene-sdk",
28-
version="0.5.0",
28+
version="0.5.2",
2929
long_description=long_description,
3030
long_description_content_type='text/markdown',
3131
description=("framework for developing sequence-level "
@@ -48,12 +48,13 @@
4848
],
4949
ext_modules=ext_modules,
5050
cmdclass=cmdclass,
51+
python_requires='>=3.9',
5152
install_requires=[
52-
"cython>=0.27.3",
53+
"cython>=3.0.10",
5354
'click',
5455
"h5py",
5556
"matplotlib>=2.2.3",
56-
"numpy",
57+
"numpy>=1.26.4",
5758
"pandas",
5859
"plotly",
5960
"pyfaidx",
@@ -63,7 +64,7 @@
6364
"scipy",
6465
"seaborn",
6566
"statsmodels",
66-
"torch>=0.4.1, <=1.9",
67+
"torch>=1.0.0, <=2.3.1",
6768
],
6869
entry_points={
6970
'console_scripts': [

0 commit comments

Comments
 (0)