Skip to content

Commit

Permalink
maint: Merge default to bytecode-interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
arungiridhar committed Oct 22, 2024
2 parents 897d60b + 51d6312 commit f93299c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
8 changes: 4 additions & 4 deletions etc/NEWS.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Summary of important user-visible changes for version 10 (yyyy-mm-dd):
- `issorted` now accepts the MODE option "monotonic", which has the same
behavior as the option "either".

- `movfun` and `movslice`: Functions now accept `wlen` equal to 1 or [0,0],
- `movfun` and `movslice`: Functions now accept `wlen` equal to 1 or [0,0],
non-integer values of `wlen`, and values of `wlen` that create window lengths
exceeding the size of the target array. `movfun` also accepts values of `dim`
larger than the number of non-singleton dimensions in the target array. The
Expand All @@ -107,9 +107,9 @@ Summary of important user-visible changes for version 10 (yyyy-mm-dd):
been updated for compatibility such that any window containing NaN or NA will
return NaN rather than passing those values to the calculating function.
`omitmissing` and `includemissing` are now accepted as aliases for `omitnan`
and `includenan`. These changes affect all moving window functions (`movmad`,
`movmax`, `movmean`, `movmedian`, `movmin`, `movprod`, `movstd`, `movsum`, and
`movvar`) (bug #66156).
and `includenan`. These changes affect all moving window functions
(`movmad`, `movmax`, `movmean`, `movmedian`, `movmin`, `movprod`, `movstd`,
`movsum`, and `movvar`) (bug #66156).

- `movmin` and `movmax`: These functions now have their default behavior set to
`omitnan`. NaN and NA values will be ignored unless a moving window contains
Expand Down
8 changes: 4 additions & 4 deletions libinterp/corefcn/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,17 +1177,17 @@ by @samp{error: }.
The optional @var{id} argument allows programmers to tag an error
with a specific identifier so that users can later retrieve it (using
@code{lasterr} or @var{lasterror}) and know the origin of the error.
The identifier must contain at least one colon character (@qcode{":"})
@code{lasterr} or @code{lasterror}) and know the origin of the error.
The identifier must contain at least one colon character (@qcode{':'})
and must not contain any whitespace characters. It should be a string of
the form @qcode{"NAMESPACE:WARNING-NAME"}. Octave's own errors use the
the form @qcode{"NAMESPACE:ERROR-NAME"}. Octave's own errors use the
@qcode{"Octave"} namespace (@pxref{XREFerror_ids,,@code{error_ids}}).
For example:
@example
@group
error ("MyNameSpace:wrong-type-argument",
"foo: argument should be numeric");
"fcn_name: argument should be numeric");
@end group
@end example
Expand Down
51 changes: 26 additions & 25 deletions scripts/statistics/movmad.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@
## @var{wlen} on data @var{x}.
##
## The moving window length input @var{wlen} can either be a numeric scalar
## or a 2-element numeric array @w{@qcode{[@var{nb}, @var{na}]}}. The elements
## or a 2-element numeric array @w{@code{[@var{nb}, @var{na}]}}. The elements
## included in the moving window depend on the size and value of @var{wlen}
## as well as whether the @qcode{"SamplePoints"} option has been specified.
## For full details of element inclusion,
## @pxref{XREFmovslice,,@code{movslice}}.
##
## If the optional argument @var{dim} is given, operate along this dimension.
##
## The optional argument @var{nancond} is a string that controls how
## @code{NaN} and @code{NA} values affect the output of @qcode{"movmad"}. The
## value @qcode{"includenan"} causes @code{NaN} and @code{NA} values to be
## included in the moving window, and any window slice containing @code{NaN}
## or @code{NA} values will return @code{NaN} for that element. The value
## @qcode{"omitnan"} (default) causes @qcode{"movmad"} to ignore any
## @code{NaN} or @code{NA} values resulting in fewer elements being used to
## calculate the mad for that window slice. If @qcode{"omitnan"} is specified
## and a window slice contains all @code{NaN} or @code{NA} values,
## @qcode{"movmad"} returns @code{NaN} for that element. The values
## @qcode{"includemissing"} and @qcode{"omitmissing"} may be used synonymously
## with @qcode{"includenan"} and @qcode{"omitnan"}, respectively.
## The optional argument @var{nancond} is a string that controls how @code{NaN}
## and @code{NA} values affect the output of @qcode{"movmad"}. The value
## @qcode{"includenan"} causes @code{NaN} and @code{NA} values to be included
## in the moving window, and any window slice containing @code{NaN} or
## @code{NA} values will return @code{NaN} for that element. The value
## @qcode{"omitnan"} (default) causes @qcode{"movmad"} to ignore any @code{NaN}
## or @code{NA} values resulting in fewer elements being used to calculate the
## mad for that window slice. If @qcode{"omitnan"} is specified and a window
## slice contains all @code{NaN} or @code{NA} values, @qcode{"movmad"} returns
## @code{NaN} for that element. The values @qcode{"includemissing"} and
## @qcode{"omitmissing"} may be used synonymously with @qcode{"includenan"} and
## @qcode{"omitnan"}, respectively.
##
## The calculation can be controlled by specifying @var{property}/@var{value}
## pairs:
##
## @itemize
## @item
## The @qcode{"mode"} property can take the value @qcode{"median"} (default)
## or @qcode{"mean"} to control whether @qcode{"movmad"} performs median or
## mean absolute deviation calculations on the data.
## The @qcode{"mode"} property can take the value @qcode{"median"} (default) or
## @qcode{"mean"} to control whether @qcode{"movmad"} performs median or mean
## absolute deviation calculations on the data.
##
## @item
## Additional valid properties are @qcode{"Endpoints"} and
## @qcode{"SamplePoints"}. For full descriptions of these properties and
## valid options, @pxref{XREFmovfun,,@code{movfun}}.
## @qcode{"SamplePoints"}. For full descriptions of these properties and valid
## options, @pxref{XREFmovfun,,@code{movfun}}.
## @end itemize
##
## Programming Note: This function is a wrapper which calls @code{movfun}.
## For full documentation of inputs and options,
## @pxref{XREFmovfun,,@code{movfun}}.
## Programming Note: This function is a wrapper which calls @code{movfun}. For
## full documentation of inputs and options, @pxref{XREFmovfun,,@code{movfun}}.
##
## Compatibility Note: Prior to Octave 10 this function only calculated mean
## absolute deviation. To achieve code compatibility, the default has been
## changed to median absolute deviation. The @qcode{"mode"} proprety is now
## absolute deviation. For @sc{matlab} compatibility, the default has been
## changed to median absolute deviation. The @qcode{"mode"} property is now
## provided to enable access to both @qcode{"mad"} calculation methods. This
## property should not be expected to be functional outside of Octave code.
##
Expand All @@ -96,7 +96,7 @@
## deviation. If multiple, last "mode" input takes precedence.
## __parse_movargs__ should have already checked for prop/value pairing.
## Use output to send Opt = 1 via anonymous function for median case, or
## use default opt = 0 for mean case. strip mode property arguments before
## use default opt = 0 for mean case. Strip mode property arguments before
## sending to movfun.


Expand All @@ -107,7 +107,7 @@
mode_loc = find (mode_check);
mode_type = varargin{mode_loc(end) + 1};

switch lower (mode_type)
switch (lower (mode_type))
case "mean"
fcn = @mad;

Expand All @@ -126,6 +126,7 @@

endfunction


## mean absolute deviation tests
%!assert (movmad (1:5, 3, "mode", "mean"), [1/2, 2/3, 2/3, 2/3, 1/2], eps)
%!assert (movmad (1:5, [1, 1], "mode", "mean"), [1/2, 2/3, 2/3, 2/3, 1/2], eps)
Expand Down

0 comments on commit f93299c

Please sign in to comment.