python-gdchart2: Can't use a list as data for setData method
Benoit Caron
bencaron at gmail.com
Wed Nov 26 19:54:16 UTC 2008
Package: python-gdchart2
Version: 0.beta1-3.4
Severity: normal
Tags: patch
Generating a PieChart works as advertised in the documentation, by
giving the data values to the setData method one by one:
myPie = gdchart.Pie3D()
myPie.setData(1, 2, 3, 4, 5)
myPie.setLabels(["One", "Two", "Three", "Four", "Five"])
But one can't build a list of data by other mean and then use it as
argument:
# assume both list have same length
mydatalist, mydatalabels = getDataFromSomeSource()
myPie = gdchart.Pie3D()
myPie.setData(mydatalist)
myPie.setLabels(mydatalabels)
This results in this exception:
GDChartError: List of labels must have same length as data.
called like this, myPie._data contains:
myPie._data
([906.98000000000002, 2.5600000000000001, 92.459999999999994],)
setData method is defined like this:
364 def setData(self, *data):
365 """
366 Set pie data to be graphed.
367 mypie.setData(1, 2, 3, 4)
368 """
369 self._datalen = len(data)
370 self._data = data
371 self._conformanceCheck()
If defined like this:
364 def setData(self, data):
It will work correctly, but the call to setData will _always_ need to be
done as an array. So, documentation will need to be:
myPie.setData([1, 2, 3, 4, 5])
Which would be more consistent with the way setLabels works anyway.
Should I send the patch/bug report upstream to Debian?
-- System Information:
Debian Release: lenny/sid
APT prefers intrepid-updates
APT policy: (500, 'intrepid-updates'), (500, 'intrepid-security'), (500, 'intrepid')
Architecture: i386 (i686)
Kernel: Linux 2.6.27-7-generic (SMP w/2 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-gdchart2 depends on:
ii libc6 2.8~20080505-0ubuntu7 GNU C Library: Shared libraries
ii libfreetype6 2.3.7-2ubuntu1 FreeType 2 font engine, shared lib
ii libgd2-noxpm 2.0.36~rc1~dfsg-3ubuntu1 GD Graphics Library version 2 (wit
ii libgdchart-gd2- 0.11.5-6 Generate graphs using the GD libra
ii libjpeg62 6b-14 The Independent JPEG Group's JPEG
ii libpng12-0 1.2.27-1 PNG library - runtime
ii python 2.5.2-1ubuntu1 An interactive high-level object-o
ii python-support 0.8.4 automated rebuilding support for P
ii zlib1g 1:1.2.3.3.dfsg-12ubuntu1 compression library - runtime
python-gdchart2 recommends no packages.
-- no debconf information
More information about the ubuntu-users
mailing list