/[escript]/trunk/escript/src/DataArrayView.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataArrayView.cpp

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

revision 82 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC
# Line 54  DataArrayView::DataArrayView(ValueType& Line 54  DataArrayView::DataArrayView(ValueType&
54         << m_maxRank;         << m_maxRank;
55        throw DataException(temp.str());        throw DataException(temp.str());
56      }      }
57      if (m_data->size()<(noValues()+m_offset)) {      if (m_data->size() < (noValues()+m_offset)) {
58        stringstream temp;        stringstream temp;
59        temp << "Error- Couldn't construct DataArrayView, insufficient storage."        temp << "Error- Couldn't construct DataArrayView, insufficient storage."
60         << " Shape requires: " << noValues()+m_offset << " values."         << " Shape requires: " << noValues()+m_offset << " values."
# Line 119  DataArrayView::copy(const boost::python: Line 119  DataArrayView::copy(const boost::python:
119        }        }
120      }      }
121  }  }
122      
123  void  void
124  DataArrayView::copy(const DataArrayView& other)  DataArrayView::copy(const DataArrayView& other)
125  {  {
# Line 180  DataArrayView::noValues(const ShapeType& Line 180  DataArrayView::noValues(const ShapeType&
180      }      }
181      return noValues;      return noValues;
182  }  }
183      
184  int  int
185  DataArrayView::noValues() const  DataArrayView::noValues() const
186  {  {
# Line 207  DataArrayView::createShapeErrorMessage(c Line 207  DataArrayView::createShapeErrorMessage(c
207  void  void
208  DataArrayView::setOffset(ValueType::size_type offset)  DataArrayView::setOffset(ValueType::size_type offset)
209  {  {
210      EsysAssert((m_data->size()>=(noValues()+offset)), "Invalid offset");      EsysAssert((m_data->size() >= (noValues()+offset)), "Invalid offset");
211      m_offset=offset;      m_offset=offset;
212  }  }
213    
214  DataArrayView::ShapeType  DataArrayView::ShapeType
215  DataArrayView::getResultSliceShape(const RegionType& region)  DataArrayView::getResultSliceShape(const RegionType& region)
216  {  {
217        int dimSize;
218      RegionType::const_iterator i;      RegionType::const_iterator i;
219      DataArrayView::ShapeType result;      DataArrayView::ShapeType result;
220      for (i=region.begin();i!=region.end();++i) {      for (i=region.begin();i!=region.end();i++) {
221        int dimSize=(i->second-i->first);        dimSize=((i->second) - (i->first));
222        if (dimSize!=0) {        if (dimSize!=0) {
223      result.push_back(dimSize);      result.push_back(dimSize);
224        }        }
# Line 225  DataArrayView::getResultSliceShape(const Line 226  DataArrayView::getResultSliceShape(const
226      return result;      return result;
227  }  }
228    
229    DataArrayView::RegionType
230    DataArrayView::getSliceRegion(const boost::python::object& key) const
231    {
232      int slice_rank, out_rank, i;
233      int this_rank=getRank();
234      /* allow for case where key is singular eg: [1], this implies we
235         want to generate a rank-1 dimension object, as opposed to eg: [1,2]
236         which implies we want to take a rank dimensional object with one
237         dimension of size 1 */
238      extract<tuple> key_tuple(key);
239      if (key_tuple.check()) {
240          slice_rank=extract<int> (key.attr("__len__")());
241      } else {
242          slice_rank=1;
243      }
244      /* ensure slice is correctly dimensioned */
245      if (slice_rank>=this_rank) {
246           out_rank=slice_rank;
247      } else {
248           out_rank=this_rank;
249      }
250      DataArrayView::RegionType out(out_rank);
251      /* calculate values for slice range */
252      if (key_tuple.check()) {
253        for (i=0;i<slice_rank;i++) {
254          out[i]=getSliceRange(key[i],getShape()[i]);
255        }
256      } else {
257        out[0]=getSliceRange(key,getShape()[0]);
258      }
259      for (i=slice_rank;i<this_rank;i++) {
260        out[i]=std::pair<int,int>(0,getShape()[i]);
261      }
262      return out;
263    }
264    
265    std::pair<int,int>
266    getSliceRange(const boost::python::object& key,
267                  const int shape)
268    {
269      /* default slice range is range of entire shape dimension */
270      int s0=0, s1=shape;;
271      extract<int> slice_int(key);
272      if (slice_int.check()) {
273        /* if the key is a single int set start=key and end=key */
274        /* in this case, we want to return a rank-1 dimension object from
275           this object, taken from a single index value for one of this
276           object's dimensions */
277        s0=slice_int();
278        s1=s0;
279      } else {
280        /* if key is a pair extract begin and end values */
281        extract<int> step(key.attr("step"));
282        if (step.check() && step()!=1) {
283           throw DataException("Error - Data does not support increments in slicing ");
284        } else {
285          extract<int> start(key.attr("start"));
286          if (start.check()) {
287            s0=start();
288          }
289          extract<int> stop(key.attr("stop"));
290          if (stop.check()) {
291            s1=stop();
292          }
293        }
294      }
295      return std::pair<int,int>(s0,s1);
296    }
297    
298  void  void
299  DataArrayView::copySlice(const DataArrayView& other,  DataArrayView::copySlice(const DataArrayView& other,
300                           const RegionType& region)                           const RegionType& region)
301  {  {
302      //      //
303      // version of slice that uses the default offset      // version of copySlice that uses the default offsets
304      copySlice(m_offset,other,other.m_offset,region);      copySlice(m_offset,other,other.m_offset,region);
305  }  }
306    
# Line 240  DataArrayView::copySlice(ValueType::size Line 310  DataArrayView::copySlice(ValueType::size
310                           ValueType::size_type otherOffset,                           ValueType::size_type otherOffset,
311                           const RegionType& region)                           const RegionType& region)
312  {  {
313    
314        //
315        // Make sure this object is not empty
316        EsysAssert(!isEmpty(),"Error - this data object is empty.");
317    
318      //      //
319      // Assume region is okay, Other asserts will detect range errors      // Modify region to copy from in order to
320      EsysAssert((other.getRank()==region.size()),"Error - Invalid slice region.");      // deal with the case where one range in the region contains identical indexes,
321      EsysAssert((!isEmpty()&&checkShape(getResultSliceShape(region))),      // eg: <<1,1><0,3><0,3>>
322             createShapeErrorMessage("Error - Couldn't copy slice due to shape mismatch.",getResultSliceShape(region)));      // This situation implies we want to copy from an object with rank greater than that of this
323      //      // object. eg: we want to copy the values from a two dimensional slice out of a three
324      // take a local copy of the region and modify for the case      // dimensional object into a two dimensional object.
325      // of 2:2 being equivalent to 2:3. The only difference in meaning being in      // We do this by taking a slice from the other object where one dimension of
326      // determining the output shape.      // the slice region is of size 1. So in the above example, we modify the above
327      RegionType localRegion=region;      // region like so: <<1,2><0,3><0,3>> and take this slice.
328      for (int i=0;i<localRegion.size();++i) {  
329        if (localRegion[i].first==localRegion[i].second) {      RegionType slice_region=region;
330      ++(localRegion[i].second);      for (int i=0;i<slice_region.size();i++) {
331          if (slice_region[i].first==slice_region[i].second) {
332            (slice_region[i].second)++;
333        }        }
334      }      }
335    
336        //
337        // Check the object to be sliced from is compatible with the region to be sliced,
338        // and that the region to be sliced is compatible with this object:
339        // 1: the region to be sliced should be the same rank as the other object.
340        // 2: the other object should have at least as many datapoints at the region requires.
341        // 3: the region should have the same number of datapoints as this object
342    
343        DataArrayView::ShapeType slice_shape=getResultSliceShape(slice_region);
344        EsysAssert(other.getRank()==slice_region.size(),
345                   "Error - slice rank incompatible with object to be sliced from.");
346        EsysAssert((noValues(slice_shape)<=other.noValues()),
347                   "Error - slice shape incompatible with object to be sliced from.");
348        EsysAssert((noValues(slice_shape)==noValues()),
349                   "Error - slice shape incompatible with this object.");
350    
351        //
352        // copy the values in the specified slice_region of the other object into this object
353    
354      int numCopy=0;      int numCopy=0;
355      switch (localRegion.size()) {      switch (slice_region.size()) {
356      case 0:      case 0:
357          /* this case should never be encountered, as python will never pass us an empty slice */
358        (*m_data)[thisOffset]=(*other.m_data)[otherOffset];        (*m_data)[thisOffset]=(*other.m_data)[otherOffset];
359        break;        break;
360      case 1:      case 1:
361        for (int i=localRegion[0].first;i<localRegion[0].second;++i) {        for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
362      (*m_data)[numCopy+thisOffset]=(*other.m_data)[i+otherOffset];      (*m_data)[numCopy+thisOffset]=(*other.m_data)[i+otherOffset];
363      ++numCopy;      numCopy++;
364        }        }
365        break;        break;
366      case 2:      case 2:
367        for (int j=localRegion[1].first;j<localRegion[1].second;++j) {        for (int j=slice_region[1].first;j<slice_region[1].second;j++) {
368      for (int i=localRegion[0].first;i<localRegion[0].second;++i) {      for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
369        (*m_data)[numCopy+thisOffset]=(*other.m_data)[other.relIndex(i,j)+otherOffset];        (*m_data)[numCopy+thisOffset]=(*other.m_data)[other.relIndex(i,j)+otherOffset];
370        ++numCopy;        numCopy++;
371      }      }
372        }        }
373        break;        break;
374      case 3:      case 3:
375        for (int k=localRegion[2].first;k<localRegion[2].second;++k) {        for (int k=slice_region[2].first;k<slice_region[2].second;k++) {
376      for (int j=localRegion[1].first;j<localRegion[1].second;++j) {      for (int j=slice_region[1].first;j<slice_region[1].second;j++) {
377        for (int i=localRegion[0].first;i<localRegion[0].second;++i) {        for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
378          (*m_data)[numCopy+thisOffset]=(*other.m_data)[other.relIndex(i,j,k)+otherOffset];          (*m_data)[numCopy+thisOffset]=(*other.m_data)[other.relIndex(i,j,k)+otherOffset];
379          ++numCopy;          numCopy++;
380        }        }
381      }      }
382        }        }
383        break;        break;
384      case 4:      case 4:
385        for (int m=localRegion[2].first;m<localRegion[2].second;++m) {        for (int l=slice_region[3].first;l<slice_region[3].second;l++) {
386      for (int k=localRegion[2].first;k<localRegion[2].second;++k) {      for (int k=slice_region[2].first;k<slice_region[2].second;k++) {
387        for (int j=localRegion[1].first;j<localRegion[1].second;++j) {        for (int j=slice_region[1].first;j<slice_region[1].second;j++) {
388          for (int i=localRegion[0].first;i<localRegion[0].second;++i) {          for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
389            (*m_data)[numCopy+thisOffset]=(*other.m_data)[other.relIndex(i,j,k,m)+otherOffset];            (*m_data)[numCopy+thisOffset]=(*other.m_data)[other.relIndex(i,j,k,l)+otherOffset];
390            ++numCopy;            numCopy++;
391          }          }
392        }        }
393      }      }
# Line 298  DataArrayView::copySlice(ValueType::size Line 395  DataArrayView::copySlice(ValueType::size
395        break;        break;
396      default:      default:
397        stringstream mess;        stringstream mess;
398        mess << "Error - (copySlice) Invalid rank.";        mess << "Error - (copySlice) Invalid rank: " << slice_region.size() << " for region.";
399        throw DataException(mess.str());        throw DataException(mess.str());
400      }      }
401  }  }
402      
403  void  void
404  DataArrayView::copySliceFrom(const DataArrayView& other,  DataArrayView::copySliceFrom(const DataArrayView& other,
405                               const RegionType& region)                               const RegionType& region)
# Line 318  DataArrayView::copySliceFrom(ValueType:: Line 415  DataArrayView::copySliceFrom(ValueType::
415                               ValueType::size_type otherOffset,                               ValueType::size_type otherOffset,
416                               const RegionType& region)                               const RegionType& region)
417  {  {
418    
419      //      //
420      // Assume region is okay, Other asserts will detect range errors      // Make sure this object is not empty
421      EsysAssert((getRank()==region.size()),"Error - Invalid slice region.");      EsysAssert(!isEmpty(),"Error - this data object is empty.");
422      EsysAssert((!isEmpty()&&other.checkShape(getResultSliceShape(region))),  
423             createShapeErrorMessage("Error - Couldn't copy slice due to shape mismatch.",      //
424                         getResultSliceShape(region)));      // Modify region to copy in order to
425      //      // deal with the case where one range in the region contains identical idexes,
426      // take a local copy of the region and modify for the case      // eg: <<1,1><0,3><0,3>>
427      // of 2:2 being equivalent to 2:3. The only difference in meaning being in      // This situation implies we want to copy from an object with rank less than that of this
428      // determining the output shape.      // object. eg: we want to copy the values from a two dimensional object into a two dimensional
429      RegionType localRegion=region;      // slice of a three dimensional object.
430      for (int i=0;i<localRegion.size();++i) {      // We do this by copying to a slice from this object where one dimension of
431        if (localRegion[i].first==localRegion[i].second) {      // the slice region is of size 1. So in the above example, we modify the above
432      ++(localRegion[i].second);      // region like so: <<1,2><0,3><0,3>> and copy into this slice.
433    
434        RegionType slice_region=region;
435        for (int i=0;i<slice_region.size();i++) {
436          if (slice_region[i].first==slice_region[i].second) {
437            (slice_region[i].second)++;
438        }        }
439      }      }
440    
441        //
442        // Check the object to be coped from is compatible with the slice region to be copied
443        // into, and that the region to be sliced into is compatible with this object:
444        // 1: the region to be sliced into should be the same rank as this object.
445        // 2: the other object should have exactly the same number of data points as the
446        //    region to be sliced into requires.
447        // 3: the region can be a higher rank than the other object, provided 2 holds.
448        // 4: this object must have at least as many data points as the region requires.
449    
450        //
451        // Check region size and shape
452        DataArrayView::ShapeType slice_shape=getResultSliceShape(slice_region);
453        EsysAssert((getRank()==slice_region.size()),"Error - Invalid slice region.");
454        EsysAssert((noValues(slice_shape)==other.noValues()),
455                   "Error - slice shape incompatible with object to be sliced from.");
456        EsysAssert(other.getRank()<=slice_region.size(),
457                   "Error - slice rank incompatible with object to be sliced from.");
458        EsysAssert((noValues(slice_shape)<=noValues()),
459                   "Error - slice shape incompatible with this object.");
460    
461        //
462        // copy the values in the other object into the specified slice_region of this object
463    
464      int numCopy=0;      int numCopy=0;
465      switch (localRegion.size()) {      switch (slice_region.size()) {
466      case 0:      case 0:
467          /* this case should never be encountered, as python will never pass us an empty slice */
468        (*m_data)[thisOffset]=(*other.m_data)[otherOffset];        (*m_data)[thisOffset]=(*other.m_data)[otherOffset];
469        break;        break;
470      case 1:      case 1:
471        for (int i=localRegion[0].first;i<localRegion[0].second;++i) {        for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
472      (*m_data)[i+thisOffset]=(*other.m_data)[numCopy+otherOffset];      (*m_data)[i+thisOffset]=(*other.m_data)[numCopy+otherOffset];
473      ++numCopy;      numCopy++;
474        }        }
475        break;        break;
476      case 2:      case 2:
477        for (int j=localRegion[1].first;j<localRegion[1].second;++j) {        for (int j=slice_region[1].first;j<slice_region[1].second;j++) {
478      for (int i=localRegion[0].first;i<localRegion[0].second;++i) {      for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
479        (*m_data)[relIndex(i,j)+thisOffset]=(*other.m_data)[numCopy+otherOffset];        (*m_data)[relIndex(i,j)+thisOffset]=(*other.m_data)[numCopy+otherOffset];
480        ++numCopy;        numCopy++;
481      }      }
482        }        }
483        break;        break;
484      case 3:      case 3:
485        for (int k=localRegion[2].first;k<localRegion[2].second;++k) {        for (int k=slice_region[2].first;k<slice_region[2].second;k++) {
486      for (int j=localRegion[1].first;j<localRegion[1].second;++j) {      for (int j=slice_region[1].first;j<slice_region[1].second;j++) {
487        for (int i=localRegion[0].first;i<localRegion[0].second;++i) {        for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
488          (*m_data)[relIndex(i,j,k)+thisOffset]=(*other.m_data)[numCopy+otherOffset];          (*m_data)[relIndex(i,j,k)+thisOffset]=(*other.m_data)[numCopy+otherOffset];
489          ++numCopy;          numCopy++;
490        }        }
491      }      }
492        }        }
493        break;        break;
494      case 4:      case 4:
495        for (int m=localRegion[2].first;m<localRegion[2].second;++m) {        for (int l=slice_region[3].first;l<slice_region[3].second;l++) {
496      for (int k=localRegion[2].first;k<localRegion[2].second;++k) {      for (int k=slice_region[2].first;k<slice_region[2].second;k++) {
497        for (int j=localRegion[1].first;j<localRegion[1].second;++j) {        for (int j=slice_region[1].first;j<slice_region[1].second;j++) {
498          for (int i=localRegion[0].first;i<localRegion[0].second;++i) {          for (int i=slice_region[0].first;i<slice_region[0].second;i++) {
499            (*m_data)[relIndex(i,j,k,m)+thisOffset]=(*other.m_data)[numCopy+otherOffset];            (*m_data)[relIndex(i,j,k,l)+thisOffset]=(*other.m_data)[numCopy+otherOffset];
500            ++numCopy;            numCopy++;
501          }          }
502        }        }
503      }      }
# Line 377  DataArrayView::copySliceFrom(ValueType:: Line 505  DataArrayView::copySliceFrom(ValueType::
505        break;        break;
506      default:      default:
507        stringstream mess;        stringstream mess;
508        mess << "Error - (copySliceFrom) Invalid rank: " << localRegion.size() << " for region.";        mess << "Error - (copySliceFrom) Invalid rank: " << slice_region.size() << " for region.";
509        throw DataException(mess.str());        throw DataException(mess.str());
510      }      }
511  }  }
512      
513  DataArrayView::ShapeType  DataArrayView::ShapeType
514  DataArrayView::determineResultShape(const DataArrayView& left,  DataArrayView::determineResultShape(const DataArrayView& left,
515                                      const DataArrayView& right)                                      const DataArrayView& right)
516  {  {
517      DataArrayView::ShapeType temp;      DataArrayView::ShapeType temp;
518      for (int i=0; i<(left.getRank()-1); ++i) {      for (int i=0; i<(left.getRank()-1); i++) {
519        temp.push_back(left.getShape()[i]);        temp.push_back(left.getShape()[i]);
520      }      }
521      for (int i=1; i<right.getRank(); ++i) {      for (int i=1; i<right.getRank(); i++) {
522        temp.push_back(right.getShape()[i]);        temp.push_back(right.getShape()[i]);
523      }      }
524      return temp;      return temp;
# Line 410  DataArrayView::toString(const string& su Line 538  DataArrayView::toString(const string& su
538        temp << finalSuffix << (*this)();        temp << finalSuffix << (*this)();
539        break;        break;
540      case 1:      case 1:
541        for (int i=0;i<getShape()[0];++i) {        for (int i=0;i<getShape()[0];i++) {
542      temp << "(" << i << ") " << finalSuffix << (*this)(i);      temp << "(" << i << ") " << finalSuffix << (*this)(i);
543      if (i!=(getShape()[0]-1)) {      if (i!=(getShape()[0]-1)) {
544        temp << endl;        temp << endl;
# Line 418  DataArrayView::toString(const string& su Line 546  DataArrayView::toString(const string& su
546        }        }
547        break;        break;
548      case 2:      case 2:
549        for (int i=0;i<getShape()[0];++i) {        for (int i=0;i<getShape()[0];i++) {
550      for (int j=0;j<getShape()[1];++j) {      for (int j=0;j<getShape()[1];j++) {
551        temp << "(" << i << "," << j << ") " << finalSuffix << (*this)(i,j);        temp << "(" << i << "," << j << ") " << finalSuffix << (*this)(i,j);
552        if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1))) {        if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1))) {
553          temp << endl;          temp << endl;
# Line 428  DataArrayView::toString(const string& su Line 556  DataArrayView::toString(const string& su
556        }        }
557        break;        break;
558      case 3:      case 3:
559        for (int i=0;i<getShape()[0];++i) {        for (int i=0;i<getShape()[0];i++) {
560      for (int j=0;j<getShape()[1];++j) {      for (int j=0;j<getShape()[1];j++) {
561        for (int k=0;k<getShape()[2];++k) {        for (int k=0;k<getShape()[2];k++) {
562          temp << "("          temp << "(" << i << "," << j << "," << k << ") " << finalSuffix << (*this)(i,j,k);
563           << i << ","          if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1) && k==(getShape()[2]-1))) {
          << j << ","  
          << k << ") "  
          << finalSuffix << (*this)(i,j,k);  
         //  
         // don't put an endl after the last value  
         if (!(i==(getShape()[0]-1) &&  
           j==(getShape()[1]-1) &&  
           k==(getShape()[2]-1))) {  
564            temp << endl;            temp << endl;
565          }          }
566        }        }
# Line 448  DataArrayView::toString(const string& su Line 568  DataArrayView::toString(const string& su
568        }        }
569        break;        break;
570      case 4:      case 4:
571        // break;        for (int i=0;i<getShape()[0];i++) {
572        for (int j=0;j<getShape()[1];j++) {
573          for (int k=0;k<getShape()[2];k++) {
574            for (int l=0;l<getShape()[3];l++) {
575              temp << "(" << i << "," << j << "," << k << "," << l << ") " << finalSuffix << (*this)(i,j,k,l);
576              if (!(i==(getShape()[0]-1) && j==(getShape()[1]-1) && k==(getShape()[2]-1) && l==(getShape()[3]-1))) {
577                temp << endl;
578              }
579                }
580          }
581        }
582          }
583          break;
584      default:      default:
585        stringstream mess;        stringstream mess;
586        mess << "Error - (toString) Invalid rank: " << getRank();        mess << "Error - (toString) Invalid rank: " << getRank();
# Line 462  DataArrayView::shapeToString(const DataA Line 594  DataArrayView::shapeToString(const DataA
594  {  {
595      stringstream temp;      stringstream temp;
596      temp << "(";      temp << "(";
597      for (int i=0;i<shape.size();++i) {      for (int i=0;i<shape.size();i++) {
598        temp << shape[i];        temp << shape[i];
599        if (shape.size()-i != 1) {        if (i < shape.size()-1) {
600      temp << ",";      temp << ",";
601        }        }
602      }      }
# Line 589  DataArrayView::matMult(const DataArrayVi Line 721  DataArrayView::matMult(const DataArrayVi
721      }      }
722  }  }
723    
 DataArrayView::RegionType  
 DataArrayView::getSliceRegion(const boost::python::object& key) const  
 {  
     int slice_len=0,i=0,rank=getRank(),out_len=0;  
     extract<tuple> key_tuple(key);  
     if (key_tuple.check()) {  
         slice_len=extract<int>(key.attr("__len__")());  
     } else {  
         slice_len=1;  
     }  
     if (slice_len>=rank) {  
          out_len=slice_len;  
     } else {  
          out_len=rank;  
     }  
     DataArrayView::RegionType out(out_len);  
     if (key_tuple.check()) {  
          for (i=0;i<slice_len;i++) out[i]=getSliceRange(getShape()[i],key[i]);  
     } else {  
          out[0]=getSliceRange(getShape()[0],key);  
     }  
     for (i=slice_len;i<rank;i++) out[i]=std::pair<int,int>(0,getShape()[i]);  
     // throw DataException("Error - number of slices is bigger then the rank.");  
     return out;  
 }  
   
 std::pair<int,int>  
 getSliceRange(const int s,  
               const boost::python::object& key)  
 {  
    int s1=s;  
    int s0=0;  
    /* if the key is an int we set start=end=key */  
    extract<int> slice_int(key);  
    if (slice_int.check()) {  
          s0=slice_int();  
          s1=s0;  
    } else {  
        extract<int> step(key.attr("step"));  
        if (step.check() && step()!=1) {  
             throw DataException("Error - Data does not support increments in slicing ");  
        } else {  
           extract<int> start(key.attr("start"));  
           if (start.check()) s0=start();  
           extract<int> stop(key.attr("stop"));  
           if (stop.check()) s1=stop();  
        }  
    }  
    return std::pair<int,int>(s0,s1);  
 }  
   
724  bool operator==(const DataArrayView& left, const DataArrayView& right)  bool operator==(const DataArrayView& left, const DataArrayView& right)
725  {  {
726      //      //

Legend:
Removed from v.82  
changed lines
  Added in v.97

  ViewVC Help
Powered by ViewVC 1.1.26