Skip to content

Commit af8170f

Browse files
committed
Fix deprecated conversion of length-1 array to scalar
1 parent 36913b6 commit af8170f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

cooltools/api/snipping.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
The main user-facing function of this module is `pileup`, it performs pileups using
55
snippers and other functions defined in the module. The concept is the following:
66
7-
- First, the provided features are annotated with the regions from a view (or simply
7+
- First, the provided features are annotated with the regions from a view (or simply
88
whole chromosomes, if no view is provided). They are assigned to the region that
99
contains it, or the one with the largest overlap.
10-
- Then the features are expanded using the `flank` argument, and aligned to the bins
10+
- Then the features are expanded using the `flank` argument, and aligned to the bins
1111
of the cooler
12-
- Depending on the requested operation (whether the normalization to expected is
12+
- Depending on the requested operation (whether the normalization to expected is
1313
required), the appropriate snipper object is created
14-
- A snipper can `select` a particular region of a genome-wide matrix, meaning it
14+
- A snipper can `select` a particular region of a genome-wide matrix, meaning it
1515
stores its sparse representation in memory. This could be whole chromosomes or
1616
chromosome arms, for example
17-
- A snipper can `snip` a small area of a selected region, meaning it will extract
17+
- A snipper can `snip` a small area of a selected region, meaning it will extract
1818
and return a dense representation of this area
19-
- For each region present, it is first `select`ed, and then all features within it are
19+
- For each region present, it is first `select`ed, and then all features within it are
2020
`snip`ped, creating a stack: a 3D array containing all snippets for this region
21-
- For features that are not assigned to any region, an empty snippet is returned
22-
- All per-region stacks are then combined into one, which then can be averaged to create
21+
- For features that are not assigned to any region, an empty snippet is returned
22+
- All per-region stacks are then combined into one, which then can be averaged to create
2323
a single pileup
24-
- The order of snippets in the stack matches the order of features, this way the stack
24+
- The order of snippets in the stack matches the order of features, this way the stack
2525
can also be used for analysis of any subsets of original features
2626
2727
This procedure achieves a good tradeoff between speed and RAM. Extracting each
@@ -390,7 +390,8 @@ def select(self, region1, region2):
390390
if self.cooler_opts["sparse"]:
391391
matrix = matrix.tocsr()
392392
if self.min_diag is not None:
393-
diags = np.arange(np.diff(self.clr.extent(region1_coords)), dtype=np.int32)
393+
lo, hi = self.clr.extent(region1_coords)
394+
diags = np.arange(hi - lo, dtype=np.int32)
394395
self.diag_indicators[region1] = LazyToeplitz(-diags, diags)
395396
return matrix
396397

@@ -600,7 +601,8 @@ def select(self, region1, region2):
600601
.values
601602
)
602603
if self.min_diag is not None:
603-
diags = np.arange(np.diff(self.clr.extent(region1_coords)), dtype=np.int32)
604+
lo, hi = self.clr.extent(region1_coords)
605+
diags = np.arange(hi - lo, dtype=np.int32)
604606
self.diag_indicators[region1] = LazyToeplitz(-diags, diags)
605607
return matrix
606608

@@ -770,7 +772,8 @@ def select(self, region1, region2):
770772
.values
771773
)
772774
if self.min_diag is not None:
773-
diags = np.arange(np.diff(self.clr.extent(region1_coords)), dtype=np.int32)
775+
lo, hi = self.clr.extent(region1_coords)
776+
diags = np.arange(hi - lo, dtype=np.int32)
774777
self.diag_indicators[region1] = LazyToeplitz(-diags, diags)
775778
return self._expected
776779

@@ -861,7 +864,7 @@ def pileup(
861864
map_functor : callable, optional
862865
Map function to dispatch the matrix chunks to workers.
863866
If left unspecified, pool_decorator applies the following defaults: if nproc>1 this defaults to multiprocess.Pool;
864-
If nproc=1 this defaults the builtin map.
867+
If nproc=1 this defaults the builtin map.
865868
866869
Returns
867870
-------
@@ -983,5 +986,5 @@ def pileup(
983986
stack = _pileup(features_df, snipper.select, snipper.snip, map=map_functor)
984987
if feature_type == "bed":
985988
stack = np.fmax(stack, np.transpose(stack, axes=(0, 2, 1)))
986-
989+
987990
return stack

0 commit comments

Comments
 (0)