wip
This commit is contained in:
19
geometry.py
19
geometry.py
@@ -384,6 +384,23 @@ if __name__=="__main__":
|
||||
import numpy as np
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
import json
|
||||
|
||||
class MyJsonEncoder(json.JSONEncoder):
|
||||
""" Special json encoder for numpy types """
|
||||
|
||||
def default(self, obj):
|
||||
if isinstance(obj, np.integer):
|
||||
return int(obj)
|
||||
elif isinstance(obj, np.floating):
|
||||
return float(obj)
|
||||
elif isinstance(obj, np.ndarray):
|
||||
return obj.tolist()
|
||||
elif type(obj) not in (dict, list, str, int):
|
||||
_log.error('dont know how to json')
|
||||
return repr(obj)
|
||||
return json.JSONEncoder.default(self, obj)
|
||||
|
||||
|
||||
np.set_printoptions(suppress=True)
|
||||
np.set_printoptions(linewidth=196)
|
||||
@@ -444,6 +461,8 @@ if __name__=="__main__":
|
||||
|
||||
|
||||
obj.update_pix2pos(measure)
|
||||
print(json.dumps(obj._lut_pix2pos, cls=MyJsonEncoder))
|
||||
|
||||
obj.interp_zoom(1)
|
||||
print(obj._pix2pos)
|
||||
print(obj._pix2pos.I)
|
||||
|
||||
Reference in New Issue
Block a user