/[escript]/branches/arrexp_2137_win_merge/escript/src/WrappedArray.cpp
ViewVC logotype

Diff of /branches/arrexp_2137_win_merge/escript/src/WrappedArray.cpp

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

revision 2116 by jfenwick, Tue Dec 2 01:58:34 2008 UTC revision 2119 by jfenwick, Tue Dec 2 06:06:04 2008 UTC
# Line 14  Line 14 
14  #include "WrappedArray.h"  #include "WrappedArray.h"
15  #include "DataException.h"  #include "DataException.h"
16    
17    #include <iostream>
18    
19  using namespace escript;  using namespace escript;
20  using namespace boost::python;  using namespace boost::python;
21    
# Line 22  namespace Line 24  namespace
24    
25  void checkFeatures(const boost::python::object& obj)  void checkFeatures(const boost::python::object& obj)
26  {  {
27        using namespace std;
28      int len=0;      int len=0;
29      boost::python::object o2;      boost::python::object o2;
30      try      try
# Line 31  void checkFeatures(const boost::python:: Line 34  void checkFeatures(const boost::python::
34      catch (...)      catch (...)
35      {      {
36         PyErr_Clear();         PyErr_Clear();
37           string s=extract<std::string>(obj.attr("__str__")());
38           cerr << "Failure for object: " << s << endl;
39           s=extract<std::string>(obj.attr("__repr__")());
40           cerr << "Failurr for object: " << s << endl;
41         throw DataException("Object passed to WrappedArray must support __len__");         throw DataException("Object passed to WrappedArray must support __len__");
42      }      }
43      try      try
# Line 74  void getObjShape(const boost::python::ob Line 81  void getObjShape(const boost::python::ob
81  WrappedArray::WrappedArray(const boost::python::object& obj_in)  WrappedArray::WrappedArray(const boost::python::object& obj_in)
82  :obj(obj_in)  :obj(obj_in)
83  {  {
84        // First we check for scalars
85        try
86        {
87           double v=extract<double>(obj_in);
88           m_scalar=v;
89           rank=0;
90           return;
91        }
92        catch (...)
93        {       // so we
94           PyErr_Clear();
95        }
96        try
97        {
98           double v=extract<double>(obj_in[make_tuple()]);
99           m_scalar=v;
100           rank=0;
101           return;
102        }
103        catch (...)
104        {       // so we
105           PyErr_Clear();
106        }
107    
108    
109        m_scalar=0;
110      checkFeatures(obj_in);      checkFeatures(obj_in);
111      getObjShape(obj,shape);      getObjShape(obj,shape);
112      rank=shape.size();      rank=shape.size();

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

  ViewVC Help
Powered by ViewVC 1.1.26