Пример #1
0
 def __init__(self, parameters, maxParameter, 
              g, V, prefac, gtot,
              scaledVolt, T, Vq):
     self.Vq = Vq
     self.parameters = parameters
     self.V = V
     self.T = T
     self.isZeroT = mp.almosteq(self.T, mpf(0))
     self.scaledVolt = scaledVolt
     self.g = g
     self.maxParameter = maxParameter
     self.prefac = prefac
     self.gtot = gtot
     ### input check ###            
     if len(self.maxParameter.shape) == 1:
         self.maxParameter = self.maxParameter[newaxis,:]
     if len(self.prefac.shape) == 1:
         self.prefac = self.prefac[newaxis,:]
     if self.g.shape != self.parameters.shape or \
                 self.V.shape != self.scaledVolt.shape or \
                 self.maxParameter.shape[1] != self.parameters.shape[0]:
         
         raise ValueError
     if len(self.g.shape) == 1:
         self.g = self.g[:, newaxis]
         self.parameters = self.parameters[:, newaxis]
     self.prefac = self.prefac * np.power(self.maxParameter, 
                               -self.scaledVolt[...,newaxis])
Пример #2
0
Файл: libm.py Проект: bayao/qml
 def emit(name, iname, cdf, args, no_small=False):
     V = []
     for arg in sorted(args):
         y = cdf(*arg)
         if isinstance(y, mpf):
             e = sp.nsimplify(y, rational=True)
             if e.is_Rational and e.q <= 1000 and mp.almosteq(e, y, 1e-25):
                 y = e
         else:
             y = N(y)
         V.append(arg + (y,))
     for v in V:
         if name:
             test(name, *v)
     for v in V:
         if iname and (not no_small or 1/1000 <= v[-1] <= 999/1000):
             test(iname, *(v[:-2] + v[:-3:-1]))
Пример #3
0
    def __init__(self, input_parameters, V, Q, T):
        self.V, self.Q, self.T = V, mpf(Q), mpf(T)
########## Process input # Perform Sanity Checks ###########
        for i, j in input_parameters.items():
            if not isinstance(j, list):
                raise ValueError
            self.input_parameters[i] = np.asarray(j)
        if len(set(map(len, input_parameters.values()))) > 1:
            raise ValueError
        if not isinstance(self.V, np.ndarray) or not isinstance(self.V, list):
            self.V = np.array([self.V]).ravel()
        self.isZeroT = mp.almosteq(self.T, mpf(0))
########### Restructure distance and voltage, if necessary
        if len(self.input_parameters["x"].shape) == 1:
            self.input_parameters["x"] = self.input_parameters["x"][:,newaxis]
########### Generate parameters
        self.gtot = mp.fsum(self.input_parameters["g"])
        self.genParameters()
        self.genScaledVoltage()
Пример #4
0
    def __init__(self, input_parameters, V, Q, T):
        self.V, self.Q, self.T = V, mpf(Q), mpf(T)
        ########## Process input # Perform Sanity Checks ###########
        for i, j in input_parameters.items():
            if not isinstance(j, list):
                raise ValueError
            self.input_parameters[i] = np.asarray(j)
        if len(set(map(len, input_parameters.values()))) > 1:
            raise ValueError
        if not isinstance(self.V, np.ndarray) or not isinstance(self.V, list):
            self.V = np.array([self.V]).ravel()
        self.isZeroT = mp.almosteq(self.T, mpf(0))
        ########### Restructure distance and voltage, if necessary
        if len(self.input_parameters["x"].shape) == 1:
            self.input_parameters["x"] = self.input_parameters["x"][:, newaxis]


########### Generate parameters
        self.gtot = mp.fsum(self.input_parameters["g"])
        self.genParameters()
        self.genScaledVoltage()