NumPy chararray and whitespace

O

OKB (not okblacke)

Hi. I'm trying to use NumPy's chararray class for an array of
characters. I notice that when I try to set a chararray element to a
space, it actually gets set to an empty string. I found some pages
online indicating that the chararray strips trailing whitespace from its
values.

I am really, really, hoping this is not a hard-coded, unalterable
behavior. Is there a way to get NumPy chararray to include the
characters I tell it to, without modificiation?

Thanks,
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
R

Robert Kern

OKB said:
Hi. I'm trying to use NumPy's chararray class for an array of
characters. I notice that when I try to set a chararray element to a
space, it actually gets set to an empty string. I found some pages
online indicating that the chararray strips trailing whitespace from its
values.

You should ask numpy questions on the numpy mailing list.

http://www.scipy.org/Mailing_Lists
I am really, really, hoping this is not a hard-coded, unalterable
behavior. Is there a way to get NumPy chararray to include the
characters I tell it to, without modificiation?

Sure. Just subclass chararray and redefine __getitem__ to do what you want.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,829
Messages
2,569,737
Members
45,521
Latest member
maryb

Latest Threads

Top