From bf4ccc34621129d53963b97a27e6fb0dd85d47c7 Mon Sep 17 00:00:00 2001 From: Ilya Flyamer Date: Tue, 24 Oct 2023 17:01:15 +0200 Subject: [PATCH] copy bins, so they are nto modified twice... is it ok for memory? --- src/cooler/api.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cooler/api.py b/src/cooler/api.py index ea2677f1..53f6b100 100644 --- a/src/cooler/api.py +++ b/src/cooler/api.py @@ -582,7 +582,7 @@ def annotate(pixels, bins, replace=False): """ columns = pixels.columns ncols = len(columns) - is_selector = isinstance(bins, RangeSelector1D) + is_selector = isinstance(bins, cooler.core.RangeSelector1D) if "bin1_id" in columns: if len(bins) > len(pixels): @@ -592,14 +592,14 @@ def annotate(pixels, bins, replace=False): lo = 0 if np.isnan(lo) else lo hi = 0 if np.isnan(hi) else hi if is_selector: - right1 = bins[lo:hi + bin1.dtype.type(1)] # slicing works like iloc + right1 = bins[lo:hi + bin1.dtype.type(1)].copy() # slicing works like iloc else: - right1 = bins.loc[lo:hi] + right1 = bins.loc[lo:hi].copy() elif is_selector: - right1 = bins[:] + right1 = bins[:].copy() lo = 0 else: - right1 = bins + right1 = bins.copy() lo = 0 right1.columns = [f'{col}1' for col in right1.columns] right1 = right1.iloc[pixels['bin1_id']-lo].reset_index(drop=True) @@ -614,14 +614,14 @@ def annotate(pixels, bins, replace=False): lo = 0 if np.isnan(lo) else lo hi = 0 if np.isnan(hi) else hi if is_selector: - right2 = bins[lo:hi + bin2.dtype.type(1)] # slicing works like iloc + right2 = bins[lo:hi + bin2.dtype.type(1)].copy() # slicing works like iloc else: - right2 = bins.loc[lo:hi] + right2 = bins.loc[lo:hi].copy() elif is_selector: - right2 = bins[:] + right2 = bins[:].copy() lo = 0 else: - right2 = bins + right2 = bins.copy() lo = 0 right2.columns = [f'{col}2' for col in right2.columns] right2 = right2.iloc[pixels['bin2_id']-lo].reset_index(drop=True)