1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 883

Show
Ignore:
Timestamp:
02/01/11 22:58:46 (3 years ago)
Author:
ext_JorisGillis
Message:

Last commit of branch - in process of labeling unittests

Location:
branches/matrixtypemaps2
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/matrixtypemaps2/swig/matrixtypemaps.i

    r871 r883  
    149149%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) const Matrix<double> & { 
    150150    PyObject* p = $input; 
     151    // Disallow 1D numpy arrays. Allowing them may introduce conflicts with other typemaps or overloaded methods 
    151152    if ((is_array(p) && array_numdims(p)==2) || PyObjectHasClassName(p,"csr_matrix") || PyObjectHasClassName(p,"DMatrix")) { 
    152153        $1=1; 
  • branches/matrixtypemaps2/test/python/helpers.py

    r837 r883  
    22from numpy import * 
    33import unittest 
     4import sys 
    45 
    56class FunctionPool: 
     
    1415 
    1516class casadiTestCase(unittest.TestCase): 
     17  def message(self,s): 
     18      print s 
     19      sys.stdout.flush() 
    1620  def checkarray(self,zr,zt,name): 
    1721      """ 
  • branches/matrixtypemaps2/test/python/mx.py

    r858 r883  
    6161 
    6262  def test_MX1(self): 
     63    self.message("MX constructor") 
    6364    x = MX("x",2,3) 
    6465    self.assertEqual(x.size1(),2,"MX fails to indicate its size1") 
     
    6667 
    6768  def test_MXvertcat(self): 
     69    self.message("MX vertcat") 
    6870    x = MX("x",1,3) 
    6971    y = MX("y",1,3) 
     
    7375 
    7476  def test_MXindices(self): 
     77    self.message("MX simple indexing") 
    7578    x = MX("x",2,3) 
    7679    for i in range(2): 
     
    8689 
    8790  def test_MXfunction1(self): 
     91    self.message("MXFunction single input, single output") 
    8892    # check if x->2*x 
    8993    # evaluates correctly for x=3 
     
    104108 
    105109  def test_MXfunction2(self): 
     110    self.message("MXFunction multi input, multi output") 
    106111      # check if [x,y]->[y+x,y*x] 
    107112    # evaluates correctly for x=3,y=7 
     
    132137 
    133138  def test_MXfunction3(self): 
     139    self.message("MXFunction single input, multi output (1)") 
    134140    # check if [x,y]->[y+x,y*x] 
    135141    # evaluates correctly for x=3,y=7 
     
    156162 
    157163  def test_MXfunction3b(self): 
     164    self.message("MXFunction single input, multi output (2)") 
    158165    # check if [x,y]->[y+x,y*x] 
    159166    # evaluates correctly for x=3,y=7 
     
    185192 
    186193  def test_MXfunction4(self): 
     194    self.message("MXFunction single input, single output , using vertcat") 
    187195    # check if [x,y]->[y+x,y*x] 
    188196    # evaluates correctly for x=3,y=7 
     
    208216 
    209217  def test_MXfunction5(self): 
     218    self.message("MXFunction single input, single output , using horzcat") 
    210219    # check if [x,y]->[y+x,y*x] 
    211220    # evaluates correctly for x=3,y=7 
     
    261270         
    262271  def test_MXorder(self): 
     272    self.message("MXFunction order of non-zero elements") 
    263273    x = MX("x",2,3) 
    264274    f = MXFunction([x],[x]) 
     
    279289     
    280290  def test_MXtrans(self): 
     291    self.message("trans(MX)") 
    281292    x = MX("x",2,3) 
    282293    z=trans(x) 
     
    299310     
    300311  def test_MXflatten(self): 
     312    self.message("trans(MX)") 
    301313    x = MX("x",2,3) 
    302314    z=flatten(x) 
     
    316328     
    317329  def test_MXreshape(self): 
     330    self.message("reshape(MX)") 
    318331    x = MX("x",2,3) 
    319332    z=c.reshape(x,(1,6)) 
     
    332345   
    333346  def test_MXcompose(self): 
     347    self.message("compositions of flatten, trans, reshape with vertcat") 
    334348    checkMXoperations(self,lambda x: x,lambda x: x,'vertcat') 
    335349    checkMXoperations(self,lambda x: trans(x),lambda x: x.T,'trans(vertcat)') 
     
    342356 
    343357  def test_MXcompose2(self): 
     358    self.message("compositions of flatten, trans, reshape with horzcat") 
    344359    checkMXoperations2(self,lambda x: x,lambda x: x,'horzcat') 
    345360    checkMXoperations2(self,lambda x: trans(x),lambda x: x.T,'trans(horzcat)') 
     
    352367 
    353368  def test_MXcompose3(self): 
     369    self.message("compositions of flatten, trans, reshape with vertcat") 
    354370    checkMXoperations3(self,lambda x: x,lambda x: x,'snippet') 
    355371    checkMXoperations3(self,lambda x: trans(x),lambda x: x.T,'trans(snippet)') 
  • branches/matrixtypemaps2/test/python/sx.py

    r816 r883  
    4646      x=symbolic("x"); 
    4747      x0=1; 
    48       p=10 # increase to 20 to showcase ticket #56 
     48      p=3 # increase to 20 to showcase ticket #56 
    4949      y=x**p; 
    5050      dx=jacobian(y,x); 
     
    6363      p=symbolic("p"); 
    6464      x0=1; 
    65       p0=10 # increase to 20 to showcase ticket #56 
     65      p0=3 # increase to 20 to showcase ticket #56 
    6666      y=x**p; 
    6767      dx=jacobian(y,x); 
  • branches/matrixtypemaps2/test/python/typemaps.py

    r871 r883  
    9494    w = DMatrix(3,4,[1,2,1],[0,2,2,3],[3,2.3,8]) 
    9595    d = array([[1,2,3],[4,5,6]]) 
     96     
    9697    list(w) 
    9798    tuple(w) 
     
    102103    w.toCsr_matrix() 
    103104 
    104     dd=DMatrix(d) 
    105     self.checkarray(dd,d,"get(csr_matrix)") 
    106  
     105    self.checkarray(DMatrix(d),d,"DMatrix(numpy.ndarray)") 
     106    #self.checkarray(DMatrix(array([1,2,3,4,5,6])),d.ravel(),"DMatrix(numpy.ndarray)") 
    107107    #print DMatrix(array([1,2,3,6]),2,2).toArray() 
    108108