Beispiel #1
0
def Get(node):

    if funcs(node):
        return
    """
    #vec
    if node.declare.dim == 1:
        armadillo.vec(node)

    #rowvec
    if node.declare.dim == 2:
        armadillo.rowvec(node)

    #mat
    if node.declare.dim == 3:
        armadillo.mat(node)

    #cube
    if node.declare.dim == 4:
        armadillo.cube(node)
    """
    if node.parent.cls == "Assign" and node.parent[0] is node:
        node.declare.suggest = node.parent[1].type

    if node.declare.type != "TYPE":
        node.type = node.declare.type
Beispiel #2
0
def Var(node):
    """
Example:
    >>> print mc.qcpp("a.b = 4; c = a")
    #include <armadillo>
    using namespace arma ;
    <BLANKLINE>
    struct _A
    {
      int b ;
    } ;
    <BLANKLINE>
    int main(int argc, char** argv)
    {
      _A a, c ;
      a.b = 4 ;
      c = a ;
      return 0 ;
    }
    """

    if funcs(node):
        return

    if node.parent.cls == "Assign" and node.parent[0] is node:
        #assign b = [a.val], a is a structs, suggest vec -> dim=1
        if node.parent[1].cls == "Matrix" and \
          node.parent[1].backend == "structs" and len(node.parent[1][0]) == 1:
            node.declare.suggest = (1, node.parent[1].mem)
        #assign b = a, where a is a struct/structs.
        #This code sets b backend and type to a's backend and type
        elif node.parent[1].cls in ("Var",)\
                and node.parent[1].backend in ("struct", "structs"):

            backend = node.parent[1].backend

            node.parent[1].declare
            if hasattr(node.parent[1], "_declare"):

                node.declare.type = backend
                node.declare.backend = backend
                node.declare._declare = node.parent[1]._declare
                node._declare = node.parent[1]._declare
                node.backend = backend

        else:
            node.declare.suggest = node.parent[1].type
    
    if node.declare.type != "TYPE":
        node.type = node.declare.type
Beispiel #3
0
def Var(node):
    """
Example:
    >>> print mc.qcpp("a.b = 4; c = a")
    #include <armadillo>
    using namespace arma ;
    <BLANKLINE>
    struct _A
    {
      int b ;
    } ;
    <BLANKLINE>
    int main(int argc, char** argv)
    {
      _A a, c ;
      a.b = 4 ;
      c = a ;
      return 0 ;
    }
    """

    if funcs(node):
        return

    if node.parent.cls == "Assign" and node.parent[0] is node:
        #assign b = [a.val], a is a structs, suggest vec -> dim=1
        if node.parent[1].cls == "Matrix" and \
          node.parent[1].backend == "structs" and len(node.parent[1][0]) == 1:
            node.declare.suggest = (1, node.parent[1].mem)
        #assign b = a, where a is a struct/structs.
        #This code sets b backend and type to a's backend and type
        elif node.parent[1].cls in ("Var",)\
                and node.parent[1].backend in ("struct", "structs"):

            backend = node.parent[1].backend

            node.parent[1].declare
            if hasattr(node.parent[1], "_declare"):

                node.declare.type = backend
                node.declare.backend = backend
                node.declare._declare = node.parent[1]._declare
                node._declare = node.parent[1]._declare
                node.backend = backend

        else:
            node.declare.suggest = node.parent[1].type

    if node.declare.type != "TYPE":
        node.type = node.declare.type
Beispiel #4
0
def Get(node):

    if funcs(node):
        return

    #in backends.py backend is set to datatype. If a is rowvec,
    #i want a(2) to have backend rowvec and and datatype double
    #This code sets backend to rowvec, and below datatype is set
    #Thus backend is set before datatype is changed to double
    #mc.configure.backends.Get(node)
    
    #vec
    if node.declare.dim == 1:
        mc.configure.backends.Get(node)
        armadillo.vec(node)
        return

    #rowvec
    if node.declare.dim == 2:
        mc.configure.backends.Get(node)
        armadillo.rowvec(node)
        return

    #mat
    if node.declare.dim == 3:
        mc.configure.backends.Get(node)
        armadillo.mat(node)
        return

    #cube
    if node.declare.dim == 4:
        mc.configure.backends.Get(node)
        armadillo.cube(node)
        return
    
    if node.parent.cls == "Assign" and node.parent[0] is node:
        node.declare.suggest = node.parent[1].type

    if node.declare.type != "TYPE":
        node.type = node.declare.type
Beispiel #5
0
def Get(node):

    if funcs(node):
        return

    #in backends.py backend is set to datatype. If a is rowvec,
    #i want a(2) to have backend rowvec and and datatype double
    #This code sets backend to rowvec, and below datatype is set
    #Thus backend is set before datatype is changed to double
    #mc.configure.backends.Get(node)

    #vec
    if node.declare.dim == 1:
        mc.configure.backends.Get(node)
        armadillo.vec(node)
        return

    #rowvec
    if node.declare.dim == 2:
        mc.configure.backends.Get(node)
        armadillo.rowvec(node)
        return

    #mat
    if node.declare.dim == 3:
        mc.configure.backends.Get(node)
        armadillo.mat(node)
        return

    #cube
    if node.declare.dim == 4:
        mc.configure.backends.Get(node)
        armadillo.cube(node)
        return

    if node.parent.cls == "Assign" and node.parent[0] is node:
        node.declare.suggest = node.parent[1].type

    if node.declare.type != "TYPE":
        node.type = node.declare.type
Beispiel #6
0
import os
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit, least_squares
from scipy.linalg import svd
from scipy.optimize import OptimizeWarning
from matplotlib.widgets import Button
from astropy.io import fits

# Local modules
import dbio
import funcs
import fitstools as ft

db = dbio.fit_database()
func = funcs.funcs()


def model(x, param):
    i = 0
    mod = 0.0
    pp = []
    vpnum = []
    for k in range(db.component_num):
        pp.clear()
        vpnum1 = []
        for l in range(db.funcinfo[k][1]):
            if db.params[k][l][5] == 0:
                pp.append(param[i])
                vpnum1.append(i)
                i += 1