Ejemplo n.º 1
0
mock_res = pd.read_csv(mock_result).rename(columns={
    "row": "bin1_id",
    "col": "bin2_id"
})

# load bunch of array from a numpy npz container:
arrays_loaded = np.load(mock_input)
# snippets of M_raw, M_ice, E_ice and v_ice are supposed
# to be there ...
mock_M_raw = arrays_loaded["mock_M_raw"]
mock_M_ice = arrays_loaded["mock_M_ice"]
mock_E_ice = arrays_loaded["mock_E_ice"]
mock_v_ice = arrays_loaded["mock_v_ice"]

# 1D expected extracted for tiling-tests:
mock_exp = LazyToeplitz(mock_E_ice[0, :])

# we need kernel_half_width-edge for tiling procedures:
kernel_half_width = 3
# just a simple donut kernel for testing:
kernel = np.array([
    [1, 1, 1, 0, 1, 1, 1],
    [1, 1, 1, 0, 1, 1, 1],
    [1, 1, 0, 0, 0, 1, 1],
    [0, 0, 0, 0, 0, 0, 0],
    [1, 1, 0, 0, 0, 1, 1],
    [1, 1, 1, 0, 1, 1, 1],
    [1, 1, 1, 0, 1, 1, 1],
])
# mock bin size 20kb
b = 20000
Ejemplo n.º 2
0
from scipy.linalg import toeplitz
import numpy as np
from cooltools.lib.numutils import LazyToeplitz

n = 100
m = 150
c = np.arange(1, n + 1)
r = np.r_[1, np.arange(-2, -m, -1)]

L = LazyToeplitz(c, r)
T = toeplitz(c, r)


def test_symmetric():
    for si in [
            slice(10, 20),
            slice(0, 150),
            slice(0, 0),
            slice(150, 150),
            slice(10, 10),
    ]:
        assert np.allclose(L[si, si], T[si, si])


def test_triu_no_overlap():
    for si, sj in [
        (slice(10, 20), slice(30, 40)),
        (slice(10, 15), slice(30, 40)),
        (slice(10, 20), slice(30, 45)),
    ]:
        assert np.allclose(L[si, sj], T[si, sj])