octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51187] ISMEMBER fails if the string ends in a


From: Philip Nienhuis
Subject: [Octave-bug-tracker] [bug #51187] ISMEMBER fails if the string ends in a space:
Date: Tue, 13 Jun 2017 12:46:15 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46

Follow-up Comment #14, bug #51187 (project octave):

W/o reopening (yet), hereś an excerpt from an email thread I had with TMW
tech support:

<QUOTE>
                                                      It is not specifically
documented that for "ismember", character matrices the trailing spaces are
ignored. Also, it is not documented that the behavior for character matrices
is different than for character vectors. It should be though and this is one
of the things I will be discussing with our documentation team.
</QUOTE>

So we get this:

>>format compact          % skip empty lines in output
>>ismember ('a ', {'a '})  % both arguments trailing space
ans =
  logical
   1
>> ismember ('a ', {'a'})   % only first arg has trailing space
ans =
  logical
   0
>> ismember ('a ', cellstr ('a '))   % both args trailing space, in 2nd arg
truncated by ‘cellstr’
ans =
  logical
   0
>> ismember (['a '; 'b '], cellstr ('a '))   % arg #1 char array with trailing
spaces
ans =
  2×1 logical array
   1
   0
>> size ('a ')
ans =
     1     2
>> size (['a '; 'b '])
ans =
     2     2


TMW (IMO correctly) mentioned that char arrays are actually a legacy type; one
motive for truncating trailing spaces in char arrays by ismmber() is because
there's no way to distinguish genuine input spaces from spaces originating
from padding the char array to get rectangular.

I cannot check Octave's behavior now (busy bisecting s/th) but I think we'd
better follow Matlab in truncating trailing spaces in char arrays, no matter
how inconsistent.
Or, we could add a "legacy" flag (r2016b still has it) but as you mentioned
that may be a bit far out for an obscure "bug" like this
If you want I could have a shot at it, though.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51187>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]