-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
47 lines (40 loc) · 1.27 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
@author: Raymond F. Pauszek III, Ph.D. (2020)
smtirf >> __init__
"""
import numpy as np
import json
__version__ = "0.1.4"
print(f"smtirf v{__version__}")
class SMJsonEncoder(json.JSONEncoder):
""" https://bit.ly/2sb9YCT """
def default(self, obj):
try:
return obj._as_dict()
except AttributeError:
pass
if isinstance(obj, np.ndarray):
return obj.tolist()
elif isinstance(obj, slice):
return (obj.start, obj.stop)
elif np.issubdtype(obj, np.signedinteger):#np.int):
return int(obj)
elif np.issubdtype(obj, np.float):
return float(obj)
return json.JSONEncoder.default(self, obj)
class SMJsonDecoder(json.JSONDecoder):
def __init__(self, *args, **kwargs):
super().__init__(object_hook=self.object_hook, *args, **kwargs)
def object_hook(self, obj):
for key, val in obj.items():
if isinstance(val, list):
obj[key] = np.array(val)
return obj
from . import hmm
from . import util
from . import results
from .auxiliary import SMTraceID, SMMovieList, SMSpotCoordinate
from .auxiliary import where
from .hmm.models import HiddenMarkovModel
from .experiments import Experiment