Example #1
0
    def __init__( self, modelClass ):
        Adaptor.__init__( self )
        SqlAlchemyAdaptor._adaptors[modelClass] = self
        
        table = modelClass.__table__
        self.setTypeName( modelClass.__name__)
        primary=[]
        for c in table.columns:
            if c.primary_key:
                primary.append(c.name)
            try:
                self.addAttribute(c.name, c.type.python_type, editable=not c.primary_key)
            # For Geometry type, which doesn't implement python_type yet.
            except NotImplementedError:
                pass

        if len(primary) == 1:
            self.setIdAttribute( primary[0] )

        for relname in dir(modelClass):
            if relname.startswith("_"):
                continue
            rel= type(modelClass).__getattribute__(modelClass,relname)
            if 'property' not in dir(rel):
                continue
            prop = rel.property
            if not isinstance(prop,RelationshipProperty):
                continue
            adaptor = SqlAlchemyAdaptor.getAdaptor(prop.mapper.class_)
            islist = prop.uselist
            self.addAttribute( relname, adaptor, editable=True, islist=islist )
Example #2
0
    kernel_type = config.get('kernel_type', '')
    cost = config.get('cost', 1)
    degree = config.get('degree', 3)
    coef0 = config.get('coef0', 0)
    sparse_matrix = config.get('sparse_matrix', False)
    threshold = config.get('threshold', 50)

    y_train, x_train = svm_read_problem(train_data_path)
    y_test, x_test = svm_read_problem(test_data_path)
    data_size_train = len(y_train)
    data_size_test = len(y_test)
    features_num = extract_features_from_data(x_train, x_test)
    gamma = config.get('gamma', 1 / features_num)

    adaptor_train = Adaptor(y=y_train,
                            x=x_train,
                            data_size=data_size_train,
                            features_num=features_num)
    adaptor_test = Adaptor(y=y_test,
                           x=x_test,
                           data_size=data_size_test,
                           features_num=features_num)
    npx_train = adaptor_train.adapt_x()
    npy_train = adaptor_train.adapt_y()
    npx_test = adaptor_test.adapt_x()
    npy_test = adaptor_test.adapt_y()

    lower_boundary = np.zeros((npy_train.shape[0], npy_train.shape[1]))
    upper_boundary = np.ones((npy_train.shape[0], npy_train.shape[1])) * cost
    q = np.ones((npy_train.shape[0], npy_train.shape[1]))

    check_generation_memory(data_size_train, features_num, sparse_matrix)
Example #3
0
 def test_add_listener(self):
     adaptor = Adaptor(1)
     room = Room()
     adaptor.add_listener(room)
     self.assertEqual(len(adaptor.get_listeners()),1)
Example #4
0
 def test_start_reading(self):
     adaptor = Adaptor(1)
     adaptor.start_reading()
Example #5
0
 def test_add_listener(self):
     adaptor = Adaptor(1)
     room = Room()
     adaptor.add_listener(room)
     self.assertEqual(len(adaptor.get_listeners()), 1)
Example #6
0
 def test_start_reading(self):
     adaptor = Adaptor(1)
     adaptor.start_reading()