simplyvikram / google-chartwrapper

Automatically exported from code.google.com/p/google-chartwrapper
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Can't render numpy arrays #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

In [59]: import numpy
In [60]: l=numpy.array([1,2,3])
In [61]: g=GChartWrapper.LineXY(l)
In [62]: `g`

What is the expected output? What do you see instead?

I get the error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/data/patrik/sims/Sbc11i4-u4/set5/<ipython console> in <module>()

/usr/lib/python2.5/site-packages/GChartWrapper/GChart.py in __str__(self)
    278         Returns the rendered URL of the chart
    279         """
--> 280         self.render()
    281         params = '&'.join(['%s=%s'%x for x in self.data.items() if
x[1]])
    282         return self.apiurl + params.replace(' ','+')

/usr/lib/python2.5/site-packages/GChartWrapper/GChart.py in render(self)
    205         assert('cht' in self.data), 'No chart type defined, use
type method'
    206         self.data['cht'] = self.check_type(self.data['cht'])
--> 207         if self._dataset:
    208             self.data['chd'] = encoder.encode(self._dataset)
    209         elif not 'choe' in self.data:

ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()

It seems it's trying to test the dataset by implicitly converting it to a
bool, but you can't do that with numpy arrays since the comparison is done
element-wise.

What version of the product are you using? On what operating system?

v 0.5 on a Fedora 8 x86_64 machine, python 2.5.1, numpy 1.0.3.1.

Please provide any additional information below.

Original issue reported on code.google.com by sunrise%...@gtempaccount.com on 13 Oct 2008 at 12:20

GoogleCodeExporter commented 9 years ago
hrm...

Original comment by justquick on 13 Oct 2008 at 1:36

GoogleCodeExporter commented 9 years ago
hows about this:

        if 'any' in dir(self._dataset) and self._dataset.any():

Look to the new svn for this change

Original comment by justquick on 26 Oct 2008 at 3:15