Skip to content
Snippets Groups Projects
Commit b150cb2c authored by Benedikt Seeger's avatar Benedikt Seeger
Browse files

docstring stubs added

parent a5c349e5
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ def checkDSiToolsVersionCompatibility(versionToCheck):
if versionToCheck==DSITOOLSVERSION:
return True
else:
raise RuntimeWarning("Using Data from Different DSI Tool versions check for sanity")
raise RuntimeWarning("Using Data from Different DSI Tool versions. Check for sanity")
class dsiJSONEncoder(json.JSONEncoder):
def default(self, obj):
......@@ -39,7 +39,16 @@ del revd
class dsiVector:
def __init__(self, values, uncer, quantity, unit, uncerType="absolute"):
'''
:param values:
:param uncer:
:param quantity:
:param unit:
:param uncerType:
'''
self.dataType = self.__class__.__name__
self.dsiToolsVersion=DSITOOLSVERSION
self.quantity = str(quantity)
......@@ -68,6 +77,11 @@ class dsiVector:
@classmethod
def fromdict(cls, dict):
'''
:param dict:
:return:
'''
if checkDSiToolsVersionCompatibility(dict['dsiToolsVersion'])==False:
raise ValueError("Incompatible DSI Tools Versions JSONData/This Software"+str(dict['dsiToolsVersion'])+' / '+str(DSITOOLSVERSION))
# change constructor so that np.arrays are created
......@@ -83,10 +97,21 @@ class dsiVector:
@classmethod
def fromjson(cls, jsonstr):
'''
:param jsonstr:
:return:
'''
dict = json.loads(jsonstr)
return cls.fromdict(dict)
def InterPolatedValuesTODSIVector(self, values,uncer):
'''
:param values:
:param uncer:
:return:
'''
# change constructor so that np.arrays are created
if type(values)!=np.ndarray:
values=np.array(values)
......@@ -110,6 +135,10 @@ class dsiVector:
return resultDSiVector
def jsonDumps(self):
'''
:return:
'''
return json.dumps(self.__dict__, cls=dsiJSONEncoder)
......@@ -178,6 +207,12 @@ class dsiVector:
class dsiMultiVector:
def __init__(self, indexVector, valueVectors, interpolationTypes=None):#TODO add interpolation args
'''
:param indexVector:
:param valueVectors:
:param interpolationTypes:
'''
self.dataType = self.__class__.__name__
self.dsiToolsVersion=DSITOOLSVERSION
self.index = indexVector
......@@ -207,6 +242,11 @@ class dsiMultiVector:
@classmethod
def fromdict(cls, dict):
'''
:param dict:
:return:
'''
if checkDSiToolsVersionCompatibility(dict['dsiToolsVersion'])==False:
raise ValueError("Incompatible DSI Tools Versions JSONData/This Software"+str(dict['dsiToolsVersion'])+' / '+str(DSITOOLSVERSION))
......@@ -233,6 +273,11 @@ class dsiMultiVector:
@classmethod
def fromjson(cls, jsonstr):
'''
:param jsonstr:
:return:
'''
dict = json.loads(jsonstr)
return cls.fromdict(dict)
......@@ -263,6 +308,12 @@ class dsiMultiVector:
class dsiInterpolator:
def __init__(self , indexVector , dataVector , type):
'''
:param indexVector:
:param dataVector:
:param type:
'''
self.dataType = self.__class__.__name__
self.dsitoolsVersion=DSITOOLSVERSION
self.indexQuantity = indexVector['quantity']
......@@ -283,6 +334,10 @@ class dsiInterpolator:
return str(self.dataType)+" @" + hex(id(self))+' '+str(self.type)+' '+str(self.interpolatorSoftware)+' '+str(self.interPolatorSoftwareVersion)+' X> '+str(self.indexQuantity) +' Y>'+str(self.dataQuantity)
def toDict(self):
'''
:return:
'''
exclude_keys = ['interpolators','dataVector','indexVector']
return {k: self.__dict__[k] for k in set(list(self.__dict__.keys())) - set(exclude_keys)}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment