In [1]:
import sys
sys.path.insert(0, '../..')
import numpy as np
import allel; print(allel.__version__)


0.20.3

In [2]:
h = allel.HaplotypeArray([[0, 1], [1, 0]])
h


Out[2]:
HaplotypeArray((2, 2), dtype=int64)
0 1
0 0 1
1 1 0

In [3]:
%matplotlib inline
import matplotlib.pyplot as plt

In [4]:
h.reshape(-1)


Out[4]:
array([0, 1, 1, 0])

In [5]:
h.flatten()


Out[5]:
array([0, 1, 1, 0])

In [6]:
h.ravel()


Out[6]:
array([0, 1, 1, 0])

In [7]:
plt.pcolormesh(h);



In [8]:
plt.pcolormesh(h, vmin=0, vmax=1);



In [9]:
h.T


Out[9]:
array([[0, 1],
       [1, 0]])

In [10]:
h.transpose()


Out[10]:
array([[0, 1],
       [1, 0]])

In [11]:
np.moveaxis(h, 0, 1)


Out[11]:
array([[0, 1],
       [1, 0]])

In [12]:
h.astype('i1')


Out[12]:
HaplotypeArray((2, 2), dtype=int8)
0 1
0 0 1
1 1 0

In [13]:
h.astype('f4')


Out[13]:
array([[ 0.,  1.],
       [ 1.,  0.]], dtype=float32)

In [ ]: