예제 #1
0
    def _rule_parser(self, field: str, value: str, schema: dict):
        """Return a list containing all rule functions to be executed"""
        rulelst = []

        if 'required' not in schema.keys():
            schema['required'] = False

        order = list(schema.keys())
        priority = list(self.priority) + list(set(order) - set(self.priority))
        order.sort(key=lambda x: priority.index(x))

        for k in order:
            if hasattr(self, '_rule_%s' % k):
                rule = getattr(self, '_rule_%s' % k)
                rule = fp(rule, field, value, schema.get(k))
                rulelst.append(rule)

        if 'custom' in schema.keys():
            for k in schema['custom']:
                if hasattr(self, '_rule_custom_%s' % k):
                    rule = getattr(self, '_rule_custom_%s' % k)
                    rule = fp(rule, field, value)
                    rulelst.append(rule)

        return rulelst
예제 #2
0
    def _rule_parser(self, this):
        """Return a list containing all rule functions to be executed"""
        partials = []
        for k in this.rules:
            if hasattr(self, '_rule_%s' % k):
                rule = getattr(self, '_rule_%s' % k)
                rule = fp(rule, this)
                partials.append(rule)

        if this.custom is not None:
            for k in this.custom:
                if hasattr(self, '_rule_custom_%s' % k):
                    rule = getattr(self, '_rule_custom_%s' % k)
                    rule = fp(rule, this)
                    partials.append(rule)

        return partials
예제 #3
0
def main():
      #ser_port = serial.Serial('/dev/ttyUSB0', 460800)
      ser_port = serial.Serial('/dev/ttyUSB0', 460800)
      #ser_port = serial.Serial('/dev/ttyUSB0', 115200)

      app = QtGui.QApplication([])

      win = pg.GraphicsWindow(title="Basic plotting examples")
      win.resize(1200,800)
      win.setWindowTitle('Plotting')
      pg.setConfigOptions(antialias=True)

      plotnames = ("Acceleration", "AngularMotion", "Magnetic Field")
      colors = (((255, 0, 0),(0,255,0), (0,0,255)),
                ((255,255,0),(255,0,255),(0,255,255)),
                ((255,100,100),(100,100,255),(100,255,100)))
      plots = []

      for i in range(3):
            newplot = Plot(win, plotnames[i])
            for color in colors[i]: # colors[i] is a color triple
                  newplot.addCurveToPlot([], color)
            plots.append(newplot)

      win.nextRow()


  
      timer = pg.QtCore.QTimer()
      timer.timeout.connect(fp(readSerialAndUpdatePlot,
                               ser_port, plots))

      timer.start(20)
      
      QtGui.QApplication.instance().exec_()
  
      ser_port.flush()
      ser_port.close()
    return y


lamb = -1.0
initial = 3.0

if __name__ == "__main__":
    p = 7
    K_1 = 2
    K_2 = 4
    K_3 = 6
    delta_t = 0.05

    rung4 = RungeKutta(lamb, 1, 4, 1, 1, t_start=0)
    rung = RungeKutta(lamb, 1, 2, 1, 1, t_start=0)
    coarse_func = fp(coarse_function, rung)
    fine_func = fp(fine_function, rung4)
    para = Parareal(coarse_func,
                    fine_func,
                    p,
                    K_1,
                    delta_t,
                    3.0,
                    start_time=0.0,
                    stop_time=7.183)
    y, i_value = para.run_result_per_iter()
    para2 = Parareal(coarse_func,
                     fine_func,
                     p,
                     K_2,
                     delta_t,
예제 #5
0
class ArcGISExportRequestParams(RequestParams):
    """
    Supported params f, bbox(required), size, dpi, imageSR, bboxSR, format, layerDefs,
    layers, transparent, time, layerTimeOptions.

    @param layers: Determines which layers appear on the exported map. There are
                   four ways to specify layers: show, hide, include, exclude.
                   (ex show:1,2)
    """
    def _get_format(self):
        """
        The requested format as string (w/o any 'image/', 'text/', etc prefixes)
        """
        return self["format"]
    def _set_format(self, format):
        self["format"] = format.rsplit("/")[-1]
    format = property(_get_format, _set_format)
    del _get_format
    del _set_format

    def _get_bbox(self):
        """
        ``bbox`` as a tuple (minx, miny, maxx, maxy).
        """
        if 'bbox' not in self.params or self.params['bbox'] is None:
            return None
        points = [float(val) for val in self.params['bbox'].split(',')]
        return tuple(points[:4])
    def _set_bbox(self, value):
        if value is not None and not isinstance(value, string_type):
            value = ','.join(str(x) for x in value)
        self['bbox'] = value
    bbox = property(_get_bbox, _set_bbox)
    del _get_bbox
    del _set_bbox

    def _get_size(self):
        """
        Size of the request in pixel as a tuple (width, height),
        or None if one is missing.
        """
        if 'size' not in self.params or self.params['size'] is None:
            return None
        dim = [float(val) for val in self.params['size'].split(',')]
        return tuple(dim[:2])
    def _set_size(self, value):
        if value is not None and not isinstance(value, string_type):
            value = ','.join(str(x) for x in value)
        self['size'] = value
    size = property(_get_size, _set_size)
    del _get_size
    del _set_size

    def _get_srs(self, key):
        return self.params.get(key, None)
    def _set_srs(self, srs, key):
        if hasattr(srs, 'srs_code'):
            code = srs.srs_code
        else:
            code = srs
        self.params[key] = code.rsplit(":", 1)[-1]

    bboxSR = property(fp(_get_srs, key="bboxSR"), fp(_set_srs, key="bboxSR"))
    imageSR = property(fp(_get_srs, key="imageSR"), fp(_set_srs, key="imageSR"))
    del _get_srs
    del _set_srs