bugGNU Octave - Bugs: bug #60492, [octave forge] (signal) error in...

 
 

bug #60492: [octave forge] (signal) error in clustersegment with input not strictly 0s and 1s

Submitter:  Geert van Boxtel <geertvanboxtel>
Submitted:  Sat 01 May 2021 09:23:11 AM UTC
   
 
Category:  Octave Package Severity:  2 - Minor
Priority:  3 - Low Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 16 Jun 2021 10:42:37 PM UTC, comment #2: 

If I understood correctly the desire is that the function works even if the input data is not just 1s and 0s.

What is then the natural (low surprise) way to convert the input data to logical?

Doing 'logical(x)' implicitly assumes all non-zero values are 1, but for float numbers we have numerical issues.

What about making the function more strict and failing if the contents is not just 0s and 1s and provide a good message for it?

Juan Pablo Carbajal <juanpi>
Group Member
Sat 01 May 2021 08:23:08 PM UTC, comment #1: 

Agree, this function could be a little friendlier if the input data is not in the exact form that is expected.

Note that the docs say that the input vector is expected to be entirely ones and zeros. So if you try this instead, you get the expected result:


>> clustersegment (logical (x))
ans =

   2
   4


I would accept patches to make this function automatically convert the input into the expected ones and zeros, using 'logical()' or '!= 0' or '!!', any of these are probably equally efficient.

Mike Miller <mtmiller>
Group Member
Sat 01 May 2021 09:23:11 AM UTC, original submission:  

signal v1.4.1
OS: Ubuntu Linux 20.04.2 LTS 64 bit

x = [0, 1.2, 3, -8, 0];
clustersegment(x)
error: clustersegment: =: nonconformant arguments (op1 is 2x1, op2 is 1x3)
error: called from
    clustersegment at line 56 column 30

The error disappears when x is a column matrix instead of a row matrix, but the function then produces the wrong results

>> clustersegment(x')

ans =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
  [1,3] = [](0x0)
  [1,4] = [](0x0)
  [1,5] = [](0x0)
}

Correct result should be
ans =

   2
   4

Geert van Boxtel <geertvanboxtel>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by juanpi (Posted a comment)
  • -email is unavailable- added by geertvanboxtel (Submitted the item)
  • -email is unavailable- added by geertvanboxtel
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-01 mtmiller Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Confirmed
        Release5.2.0 dev
        Summary[octave forge] (signal) error in clustersegment [octave forge] (signal) error in clustersegment with input not strictly 0s and 1s
    2021-05-01 mmuetzel Carbon-CopyRemoved 102357 -
    2021-05-01 mmuetzel Summarysignal: error in clustersegment [octave forge] (signal) error in clustersegment
    2021-05-01 geertvanboxtel Carbon-Copy- Added geertvanboxtel

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code