aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander_Kabui2023-01-24 07:09:42 +0300
committerAlexander_Kabui2023-01-24 07:09:42 +0300
commitcf9871f97e065c210b72251458c9649c10a778ce (patch)
tree383f2d8c542f69dbd56d7ff66e9560b101d633e5
parentc728e6d2448d3f23c568e30a43ab8fdcc8785f96 (diff)
downloadgenenetwork2-cf9871f97e065c210b72251458c9649c10a778ce.tar.gz
add array serialization/deserialization
-rw-r--r--wqflask/wqflask/correlation/correlation_file_generator.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/wqflask/wqflask/correlation/correlation_file_generator.py b/wqflask/wqflask/correlation/correlation_file_generator.py
index e06c4123..ccc06f3c 100644
--- a/wqflask/wqflask/correlation/correlation_file_generator.py
+++ b/wqflask/wqflask/correlation/correlation_file_generator.py
@@ -5,6 +5,8 @@ import csv
import lmdb
import os
import tempfile
+import numpy as np
+from io import BytesIO
@@ -144,25 +146,20 @@ def generate_csv_file(conn,db_name,txt_dir,file_name):
raise e
-
def lmdb_file_generator():
pass
-""""
-import lmdb
-import os
-import tempfile
-with tempfile.TemporaryDirectory() as tmpdirname:
+def array_to_bytes(x:np.ndarray) -> bytes:
+ np_bytes = BytesIO()
- tmp_file_path = os.path.join(tmpdirname,"img_lmdb")
- breakpoint()
- db = lmdb.open(tmp_file_path, map_size=int(1e12))
+ np.save(np_bytes,x,allow_pickle =True)
+ return (np_bytes.getvalue())
- with db.begin(write=True) as in_txn:
-
- db.close()
-"""
+
+def bytes_to_array(b: bytes) -> np.ndarray:
+ np_bytes = BytesIO(b)
+ return np.load(np_bytes, allow_pickle=True) \ No newline at end of file