In [1]:
import numpy as np
np.random.seed(1)
import scipy.stats
import sys
import cProfile
%load_ext memory_profiler
# dev imports
sys.path.insert(0, '../src')
%reload_ext autoreload
%autoreload 1
%aimport anhima.sim
%aimport anhima.gt

Pack/unpack


In [2]:
genotypes = np.random.randint(-1, 3, size=(200000, 100, 2)).astype('i1')
genotypes.nbytes / 1e6


Out[2]:
40.0

In [3]:
packed = anhima.gt.pack_diploid(genotypes)

In [4]:
packed.nbytes / 1e6


Out[4]:
20.0

In [5]:
%timeit anhima.gt.pack_diploid(genotypes)


1 loops, best of 3: 209 ms per loop

In [6]:
%memit anhima.gt.pack_diploid(genotypes)


peak memory: 215.93 MiB, increment: 91.63 MiB

In [7]:
unpacked = anhima.gt.unpack_diploid(packed)

In [8]:
unpacked.nbytes / 1e6


Out[8]:
40.0

In [9]:
%timeit anhima.gt.unpack_diploid(packed)


10 loops, best of 3: 116 ms per loop

In [10]:
%memit anhima.gt.unpack_diploid(packed)


peak memory: 274.00 MiB, increment: 111.22 MiB

In [ ]: