[SciPy-user] object_arrtype addition error
Ryan Krauss
ryanlists at gmail.com
Tue Nov 29 10:41:41 CST 2005
But how can Python know how much space to save for the array if it
doesn't know the data type?
On 11/29/05, Chris Fonnesbeck <fonnesbeck at gmail.com> wrote:
> On 11/29/05, Chris Fonnesbeck <fonnesbeck at gmail.com> wrote:
> > On 11/29/05, Chris Fonnesbeck <fonnesbeck at gmail.com> wrote:
> > > On 11/28/05, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> > > > Chris Fonnesbeck wrote:
> > > >
> > > > >Under scipy_core, I have a dictionary that contains what I thought
> > > > >were floating point numbers, but are actually 'object_arrtype':
> > > > >
> > > > >
> > > > >
> > > > One question is why these are object array scalars (entries in an object
> > > > array), instead of floating point numbers in the first place. Perhaps
> > > > there is something going on there.
> > > >
> > >
> > > Its just my PyMC code calculating the quantiles of the trace (the big
> > > array of sampled values), and throwing those values into a dictionary:
> > >
> >
> > I figured it out. The trace array is intitialized as:
> >
> > self._trace = array([None]*size)
> >
> > Which, of course, is of type object_arrtype. When each element is
> > replaced by a proper value, the type does not change. I suppose I have
> > to initialize to float values, though I liked using None's under
> > numeric because if for some reason the whole array was not populated,
> > I would get an error if I tried to do anything useful with the array.
> >
>
> This brings up a question, then, about how to initialize an array when
> you dont know ahead of time what type it will contain. I like to
> initialize a large array at the beginning and populate it, rather than
> iteratively append to a growing array (that's the Pythonic way,
> right?).
>
> C.
>
> --
> Chris Fonnesbeck
> Atlanta, GA
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>
More information about the SciPy-user
mailing list