[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead of NaN |
Date: |
Sun, 25 Aug 2013 08:07:26 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1 |
Follow-up Comment #4, bug #39838 (project octave):
A couple of things. First, the call to
str2double (['2'; ''; "1"])
is actually somewhat misleading. At first glance, it looks like you might be
passing a 3x1 char into str2double, but in fact, if you evaluate the argument
by itself, it turns out that the empty string is zero by zero, and so is
ignored in the vertcat operation.
It seems like probably the correct behavior is just to match what Matlab does
here? It looks to me like matlab's procedure is well described as:
1. if it's a cell, return an array of the same size, with NaN for any element
that's not a string or doesn't convert correctly.
2. if it's a char array:
2a. If any dimension is zero, return a scalar NaN.
2b. Otherwise return a column vector with one result per row of the char
array. Any position that couldn't be converted should be NaN, obviously.
3. For any other input, regardless of size, return a scalar NaN.
This primarily differs from octave's current implementation on item 2a and
item 3, where octave currently prefers to match the size of non-string input
and the number of rows of empty strings.
I'll put together a quick patch tomorrow.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?39838>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/