McDermott-Group / servers

Public repo that stores LabRAD servers and other non-measurement related code
0 stars 2 forks source link

boolean parameter type conversion incompatibility #89

Closed roboguy222 closed 7 years ago

roboguy222 commented 7 years ago
ValueError: ('Invalid datatype parameter\r\n\twas provided.\r\n\tAccepted types: int, long, float,\r\n\tcomplex, bool, list, np.ndarray,\r\n\tstr, unicode.\r\n\tType provided=', <type 'numpy.bool_'>)
roboguy222 commented 7 years ago
from dataChest import dataChest
import numpy

path = ['Tunable Dissipator','Probe Station','bae0007upy_CW20161104B_RN.hdf5']

chest = dataChest(path[:-1])
chest.openDataset(path[-1])
data = [row for row in chest.getData()]
for row in data:
    row[0] = row[0][0] + str( (9-int(row[0][1:]))%12 )
resDataChest = dataChest( path[:-1] )
resDataChest.createDataset(path[-1].split('_',1)[-1].split('.',-1)[0],
        [('die',[1],'string',''),('area',[1],'float64','um**2'),('DMM range',[1],'float64','Ohms')],
        [('resistance',[1],'float64','Ohms')])
resDataChest.addData( data )
for param in chest.getParameterList():
    p = chest.getParameter(param)
    if type(p)==numpy.bool_:
        p = bool(p)
    if type(p)==numpy.int32:
        p = int(p)
    resDataChest.addParameter(param, p)
roboguy222 commented 7 years ago

In general, the datachest does not accept numpy types, which maybe it should? Or if it does not, it should not return them.

amopremcak commented 7 years ago

The dataChest now accepts all python/numpy datatypes described in updated document. The types are preserved so that the type you input to addParameter is the type returned by getParameter. In addition I have allowed for tuple and dict type entries but with some reluctance as these will be a pain in the ass to display on the grapher when I get around to it.