/[escript]/branches/arrexp_trunk2098/escript/src/Data.cpp
ViewVC logotype

Diff of /branches/arrexp_trunk2098/escript/src/Data.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2118 by jfenwick, Tue Dec 2 01:58:34 2008 UTC revision 2119 by jfenwick, Tue Dec 2 06:06:04 2008 UTC
# Line 53  using namespace escript; Line 53  using namespace escript;
53    
54  void escript::jtest(boost::python::object& obj)  void escript::jtest(boost::python::object& obj)
55  {  {
56    cout << "Testing1\n";
57        try
58        {
59           double v=extract<double>(obj);
60           cout << "Found a double " << v << endl;
61           return;
62        }
63        catch (...)
64        {
65           PyErr_Clear();
66           // There isn't actually an error here
67        }
68    cout << "Testing2\n";
69        try
70        {
71           double v=extract<double>(obj[make_tuple()]);
72           cout << "Found a () double " << v << endl;
73           return;
74        }
75        catch (...)
76        {
77           PyErr_Clear();
78        }
79    cout << "Testing 3\n";
80      WrappedArray w(obj);      WrappedArray w(obj);
81      DataTypes::ShapeType shape=w.getShape();      DataTypes::ShapeType shape=w.getShape();
82      size_t rank=shape.size();      size_t rank=shape.size();
# Line 514  Data::Data(DataAbstract_ptr underlyingda Line 538  Data::Data(DataAbstract_ptr underlyingda
538  }  }
539    
540    
541  Data::Data(const numeric::array& value,  // Data::Data(const numeric::array& value,
542         const FunctionSpace& what,  //     const FunctionSpace& what,
543             bool expanded)  //            bool expanded)
544  {  // {
545    initialise(value,what,expanded);  //   initialise(value,what,expanded);
546    m_protected=false;  //   m_protected=false;
547  }  // }
548    
549  Data::Data(const DataTypes::ValueType& value,  Data::Data(const DataTypes::ValueType& value,
550           const DataTypes::ShapeType& shape,           const DataTypes::ShapeType& shape,
# Line 536  Data::Data(const object& value, Line 560  Data::Data(const object& value,
560         const FunctionSpace& what,         const FunctionSpace& what,
561             bool expanded)             bool expanded)
562  {  {
563    numeric::array asNumArray(value);    //numeric::array asNumArray(value);
564    initialise(asNumArray,what,expanded);    WrappedArray w(value);
565      initialise(w,what,expanded);
566    m_protected=false;    m_protected=false;
567  }  }
568    
# Line 580  Data::~Data() Line 605  Data::~Data()
605  }  }
606    
607    
608    void Data::initialise(const WrappedArray& value,
609                     const FunctionSpace& what,
610                     bool expanded)
611    {
612      //
613      // Construct a Data object of the appropriate type.
614      // Construct the object first as there seems to be a bug which causes
615      // undefined behaviour if an exception is thrown during construction
616      // within the shared_ptr constructor.
617      if (expanded) {
618        DataAbstract* temp=new DataExpanded(value, what);
619        m_data=temp->getPtr();
620      } else {
621        DataAbstract* temp=new DataConstant(value, what);
622        m_data=temp->getPtr();
623      }
624    }
625    
626    
627  void  void
628  Data::initialise(const boost::python::numeric::array& value,  Data::initialise(const boost::python::numeric::array& value,

Legend:
Removed from v.2118  
changed lines
  Added in v.2119

  ViewVC Help
Powered by ViewVC 1.1.26