bugGNU Octave - Bugs: bug #61728, inv: more consistent messages on...

 
 

bug #61728: inv: more consistent messages on invalid input

Submitter:  A.R. Burgers <arb>
Submitted:  Sat 25 Dec 2021 10:35:54 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 03 Jan 2022 09:05:13 PM UTC, comment #2: 

I disallowed logical inputs to inv() since they don't make much sense and Matlab also throws an error in this case.  See changeset http://hg.savannah.gnu.org/hgweb/octave/rev/33f77d94b4c9.

I also added two BIST tests for invalid input types to check that the code is working in this changeset http://hg.savannah.gnu.org/hgweb/octave/rev/50bf281760e0.

I think this issue report has been fully addressed.  Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Fri 31 Dec 2021 12:20:23 PM UTC, comment #1: 

Looks good to me.
I pushed your patch here:
https://hg.savannah.gnu.org/hgweb/octave/rev/3b2558676d0e

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Sat 25 Dec 2021 10:35:54 PM UTC, original submission:  

dev's inv function produces this for invalid input:


octave:1> inv({})
ans = [](0x0)
octave:2> inv({2})
error: inv: wrong type argument 'cell'
octave:4> inv('a')
error: invalid conversion from string to real matrix
octave:3> inv([])
ans = [](0x0)


matlab produces this:

inv({})
Error using inv
Invalid data type. Input matrix must be double or single.

inv({2})
Error using inv
Invalid data type. Input matrix must be double or single.

inv('a')
Error using inv
Invalid data type. Input matrix must be double or single.

inv([])
ans =[]


The different octave messaging happens because invalid input is processed as numerical data is until an error is encountered, which happens at different stages for different types of input. The attached patch does a check on invalid input at the start of the function. Came across this when looking closer at bug #61689.
All inv tests are passed with this modification. Still allows integral data (int/uint/bool), which matlab doesn't.

with the attached patch octave produces this:


octave:2> inv({})
error: inv: wrong type argument 'cell'
octave:3> inv({2})
error: inv: wrong type argument 'cell'
octave:4> inv('a')
error: inv: wrong type argument 'sq_string'
octave:5> inv([])
ans = [](0x0)


A.R. Burgers <arb>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #52567:  inv.txt added by arb (1KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by arb (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-03 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-12-31 mmuetzel StatusNone Ready For Test
    2021-12-25 arb Attached File- Added inv.txt, #52567

    Back to the top

    Powered by Savane 3.13-aa77.
    Corresponding source code