[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63410] mean input checking misses dim = Inf,
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #63410] mean input checking misses dim = Inf, poor error messaging |
Date: |
Wed, 23 Nov 2022 13:42:48 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?63410>
Summary: mean input checking misses dim = Inf, poor error
messaging
Project: GNU Octave
Submitter: nrjank
Submitted: Wed 23 Nov 2022 01:42:46 PM EST
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Unexpected Error or Warning
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: 8.0.90
Discussion Lock: Any
Operating System: Any
Fixed Release: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Wed 23 Nov 2022 01:42:46 PM EST By: Nicholas Jankowski <nrjank>
(not sure which item group this should go in)
as noticed in patch #10288, mean.m fails to consistently throw an error if
Nan or Inf is passed as a dim input.
In 7.3.0:
>> mean([1,2,3],NaN)
error: mean: DIM must be an integer and a valid dimension
error: called from
mean at line 134 column 9
>> mean([1,2,3],Inf)
error: conversion of inf to octave_idx_type value failed
error: called from
mean at line 150 column 5
testing the mean function from 8.0.90 and 9.1.0 (within 7.3.0, so not certain
the difference isn't due to the mixed environment):
>> mean([1,2,3],NaN)
error: conversion of nan to octave_idx_type value failed
error: called from
mean at line 166 column 9
>> mean([1,2,3],Inf)
error: conversion of inf to octave_idx_type value failed
error: called from
mean at line 166 column 9
in any case, the type checking for dim should catch both nan and inf.
Looking at the code, it looks like mean got a lot of rework from 7->8. In
7.3.0 the following dim check catches Nan but misses Inf:
if (dim != fix (dim) || dim < 1)
error ("mean: DIM must be an integer and a valid dimension");
endif
in 8+, the dim check was changed to:
if (! (isvector (dim) && all (dim)) || any (rem (dim, 1)))
error ("mean: DIM must be a positive integer scalar or vector");
endif
which misses both. rem(Inf,1) and rem(NaN,1) both return NaN, and any(NaN) =
0.
patch #10288 suggested dim!=fix(dim) changed to mod(dim,1)~=0 would catch both
Inf and NaN. I think that would apply here as well. Will try it and add some
BISTs to see if anything else slips through.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63410>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #63410] mean input checking misses dim = Inf, poor error messaging,
Nicholas Jankowski <=
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Rik, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Rik, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Markus Mützel, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Markus Mützel, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Rik, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/24