aboutsummaryrefslogtreecommitdiff
path: root/gn3/genodb.py
diff options
context:
space:
mode:
authorArun Isaac2022-06-17 14:15:56 +0530
committerArun Isaac2022-06-17 14:15:56 +0530
commit4d0d77ad005f0832a14c4bc050fad77ec727d476 (patch)
tree4b4a920adf051f7d4e8a15f16c91d974b2649869 /gn3/genodb.py
parent9c98575e712d623083347271389395b2a90a6484 (diff)
downloadgenenetwork3-4d0d77ad005f0832a14c4bc050fad77ec727d476.tar.gz
gn3: genodb: Rename Matrix named tuple to GenotypeMatrix.
* gn3/genodb.py (Matrix): Rename to GenotypeMatrix. (matrix): Update invocation of Matrix.
Diffstat (limited to 'gn3/genodb.py')
-rw-r--r--gn3/genodb.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/gn3/genodb.py b/gn3/genodb.py
index 7ffaf8b..31ac76f 100644
--- a/gn3/genodb.py
+++ b/gn3/genodb.py
@@ -29,7 +29,7 @@ import numpy as np
# pylint: disable=invalid-name,redefined-builtin
GenotypeDatabase = namedtuple('GenotypeDatabase', 'txn hash_length')
-Matrix = namedtuple('Matrix', 'db nrows ncols array transpose')
+GenotypeMatrix = namedtuple('Matrix', 'db nrows ncols array transpose')
@contextmanager
def open(path):
@@ -54,11 +54,13 @@ def matrix(db):
read_optimized_blob = get(db, get(db, b'current'))
nrows = int.from_bytes(get_metadata(db, hash, 'nrows'), byteorder='little')
ncols = int.from_bytes(get_metadata(db, hash, 'ncols'), byteorder='little')
- return Matrix(db, nrows, ncols,
- np.reshape(np.frombuffer(read_optimized_blob[0 : nrows*ncols], dtype=np.uint8),
- (nrows, ncols)),
- np.reshape(np.frombuffer(read_optimized_blob[nrows*ncols :], dtype=np.uint8),
- (nrows, ncols)))
+ return GenotypeMatrix(db, nrows, ncols,
+ np.reshape(np.frombuffer(read_optimized_blob[0 : nrows*ncols],
+ dtype=np.uint8),
+ (nrows, ncols)),
+ np.reshape(np.frombuffer(read_optimized_blob[nrows*ncols :],
+ dtype=np.uint8),
+ (nrows, ncols)))
def nparray(matrix):
'''Get matrix as a 2D numpy array.'''