3.2 Wrappers for QwtArray<T>

Warning: The documentation is for the future PyQwt-5.0 which is only available from CVS. A snapshot, PyQwt5-20061017.tar.gz, is available. Please refer, to the documentation in the snapshot when you use the snapshot.

PyQwt has a partial interface to the following C++ QwtArray templates:

  1. QwtArrayDouble for QwtArray<double>
  2. QwtArrayInt for QwtArray<int>
  3. QwtArrayQwtDoublePoint for QwtArray<QwtDoublePoint> when PyQwt has been built against PyQt3 or for QwtArray<QPointF> when PyQwt has been built against PyQt4.

Those classes have at least 3 constructors - taking QwtArrayDouble as an example:

  1. array = QwtArrayDouble()
  2. array = QwtArrayDouble(int)
  3. array = QwtArrayDouble(otherArray)

QwtArrayDouble and QwtArrayInt have also a constructor which takes a sequence of items convertable to a C++ double and a C++ long:

All those classes have 16 member functions - taking QwtArrayDouble as example:

  1. array = array.assign(otherArray)
  2. item = array.at(index)
  3. index = array.bsearch(item)
  4. index = contains(item)
  5. array = otherArray.copy()
  6. result = array.count()
  7. array.detach()
  8. array = array.duplicate(otherArray)
  9. bool = array.fill(item, index=-1)
  10. index = array.find(item, index=0)
  11. bool = array.isEmpty()
  12. bool = array.isNull()
  13. bool = array.resize(index)
  14. result = array.size()
  15. array.sort()
  16. bool = array.truncate(index)

Iterators are not yet implemented. However, the implementation of the Python slots __getitem__, __len__ and __setitem__ let you use those classes almost as a sequence. For instance:

>>> import PyQt4.Qwt5 as Qwt
>>> import numpy as NP
>>> a = Qwt.QwtArrayDouble(NP.arange(10, 20, 4))
>>> for i in a:                                  # thanks to __getitem__
...  print i
...
10.0
14.0
18.0
>>> for i in range(len(a)):                      # thanks to __len__
...  print a[i]                                  # thanks to __getitem__
...
10.0
14.0
18.0
>>> for i in range(len(a)):                      # thanks to __len__
...  a[i] = 10+3*i                               # thanks to __setitem__
...
>>> for i in a:                                  # thanks to __getitem__
...  print i
...
10.0
13.0
16.0
>>>