Skip to content

Commit 734d4f3

Browse files
committed
Added numpy and pysam as hard dependencies
1 parent 32bf6e1 commit 734d4f3

File tree

4 files changed

+9
-47
lines changed

4 files changed

+9
-47
lines changed

docs/docs/Install.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ Base installation:
1616
pip install gwplot
1717
```
1818

19-
`gwplot` also has a few optional runtime dependencies including `numpy`, `pillow` and `pysam`. Fetch them using:
20-
21-
```bash
22-
pip install gwplot[all]
23-
```
19+
`gwplot` also has `pillow` as an optional runtime dependency.
2420

2521
### Building from Source
2622

docs/docs/api/gw-saving-images.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ Convert the pixel data to a numpy array using zero-copy interface.
194194
**Returns:**
195195
- `numpy.ndarray` or `None`: RGBA image data as a 3D numpy array (height × width × 4) or None if the raster surface hasn't been created
196196

197-
**Raises:**
198-
- `ImportError`: If Numpy could not be imported
199-
200197
**Example:**
201198
```python
202199
# Get the visualization as a numpy array

gwplot/interface.pyx

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,18 @@
22
import os
33
import json
44
from typing import Any, Dict, List, Optional, Tuple
5-
from libcpp.string cimport string
6-
from libcpp.vector cimport vector
7-
8-
cdef bint HAVE_NUMPY = False
5+
import numpy as np
96
cdef bint HAVE_PILLOW = False
10-
cdef bint HAVE_PYSAM = False
11-
try:
12-
import numpy as np
13-
cimport numpy as np
14-
np.import_array()
15-
HAVE_NUMPY = True
16-
except (ImportError, ModuleNotFoundError):
17-
pass
18-
197
try:
208
from PIL import Image
219
HAVE_PILLOW = True
2210
except (ImportError, ModuleNotFoundError):
2311
pass
2412

25-
cdef class AlignedSegment:
26-
pass
27-
28-
try:
29-
from pysam.libcalignedsegment cimport AlignedSegment
30-
HAVE_PYSAM = True
31-
except (ImportError, ModuleNotFoundError):
32-
pass
33-
13+
from libcpp.string cimport string
14+
from libcpp.vector cimport vector
3415
from cpython.bytes cimport PyBytes_FromStringAndSize
16+
from pysam.libcalignedsegment cimport AlignedSegment
3517

3618
__all__ = ["Gw", "GwPalette"]
3719

@@ -1496,15 +1478,12 @@ cdef class Gw:
14961478

14971479
Raises
14981480
------
1499-
ImportError
1500-
If pysam could not be imported
15011481
IndexError
15021482
If the region_index or bam_index are out of range
15031483
UserWarning
15041484
If any normal collections are already present in the Gw object
15051485
"""
1506-
if not HAVE_PYSAM:
1507-
raise ImportError("Pysam could not be imported")
1486+
15081487
if not self.raster_surface_created:
15091488
self.make_raster_surface()
15101489
cdef bint needs_clearing = <bint>False
@@ -1974,8 +1953,6 @@ cdef class Gw:
19741953
RGBA image data as a 3D numpy array (height × width × 4)
19751954
or None if the raster surface hasn't been created
19761955
"""
1977-
if not HAVE_NUMPY:
1978-
raise ImportError("Numpy could not be imported")
19791956
if not self.raster_surface_created:
19801957
return None
19811958
#return np.array(self).reshape(self.canvas_height, self.canvas_width, 4)

pyproject.toml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@ classifiers = [
1717
"Operating System :: POSIX :: Linux",
1818
"Operating System :: MacOS :: MacOS X",
1919
]
20-
dependencies = [ "setuptools>=61.0" ]
20+
dependencies = [ "setuptools>=61.0", "numpy>=1.19.3", "pysam>=0.21.0" ]
2121

2222
[project.optional-dependencies]
23-
test = ["matplotlib",
24-
"Flask",
25-
"pysam>=0.21.0",
26-
"numpy>=1.19.3",
27-
"pillow"]
28-
pysam = ["pysam>=0.21.0"]
29-
numpy = ["numpy>=1.19.3"]
23+
test = ["matplotlib", "Flask", "pillow"]
3024
pillow = ["pillow"]
31-
all = ["pysam>=0.21.0",
32-
"numpy>=1.19.3",
33-
"pillow"]
25+
all = ["matplotlib", "Flask", "pillow"]
3426

3527
[tool.setuptools]
3628
packages = ["gwplot"]

0 commit comments

Comments
 (0)