Mercurial > octave
annotate scripts/general/flipud.m @ 33624:e0c037a01fde default tip
redirect stdout and stderr into experimental terminal widget
* command-widget.cc (command_widget): open temp files for redirecting
stdout and stderr, setup a file system watcher for signals on changes
to these files;
(~command_widget): close and remove the temp. files;
(insert_interpreter_output): use the style as second argument
(print_stream): add new contents of temp. files for stdout and stderr
to the end of the terminal contents;
(notice_settings): set the terminal preferences to the new lexer of
the console;
(console): create and set new lexer;
(new_command_line): use prompt style for the prompt;
(execute_command): use second command line argument for the style;
(append_string): use style as second argument and style the added
text accordingly;
* command-widget.h (console) append_string with second argument for style,
(command_widget): now with destructor, new method print_stream,
insert_interpreter_output with second argument for style, new class
variables for temp. file descriptors and file system watcher
* console-lexer.cc/h: new lexer derived from QScintillas default lexer
for styling the terminal output, styles used so far: Default, Error,
and Prompt
* gui-preferences-cs.h: new constants for error and prompt colors
* libgui/src/module.mk: new files console_lexer.cc/h
* qt-interpreter-events.cc (display_exception): interpreter_output_signal
with second argument for the style, here Error style
* qt-interpreter-events.h: interpreter_output_signal with second
argument for the style
* terminal-dock-widget.h: interpreter_output_signal with second
argument for the style
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 25 May 2024 14:36:01 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 1993-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
2313 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
2313 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
2313 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
2313 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
245 | 25 |
3369 | 26 ## -*- texinfo -*- |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
27 ## @deftypefn {} {@var{B} =} flipud (@var{A}) |
19126
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
28 ## Flip array upside down. |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
29 ## |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
30 ## Return a copy of @var{A} with the order of the rows reversed. In other |
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
31 ## words, @var{A} is flipped upside-down about a horizontal axis. For example: |
3426 | 32 ## |
3369 | 33 ## @example |
34 ## @group | |
35 ## flipud ([1, 2; 3, 4]) | |
36 ## @result{} 3 4 | |
37 ## 1 2 | |
38 ## @end group | |
39 ## @end example | |
4869 | 40 ## |
19154 | 41 ## @seealso{fliplr, flip, rot90, rotdim} |
3369 | 42 ## @end deftypefn |
4 | 43 |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
44 function B = flipud (A) |
4 | 45 |
28891
de5f2f9a64ff
maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents:
28886
diff
changeset
|
46 if (nargin < 1) |
6046 | 47 print_usage (); |
4 | 48 endif |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
49 B = flip (A, 1); |
4 | 50 |
51 endfunction | |
7411 | 52 |
53 | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 %!assert (flipud ([1, 2; 3, 4]), [3, 4; 1, 2]) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 %!assert (flipud ([1, 2; 3, 4; 5, 6]), [5, 6; 3, 4; 1, 2]) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 %!assert (flipud ([1, 2, 3; 4, 5, 6]), [4, 5, 6; 1, 2, 3]) |
19126
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
57 %!assert (flipud ([1 2 3]), [1 2 3]) |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
58 |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
59 ## Test NDArrays |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
60 %!test |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
61 %! a(:,:,1) = [ 1 2 3; 4 5 6]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
62 %! a(:,:,2) = [ 7 8 9; 10 11 12]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
63 %! b(:,:,1) = [ 4 5 6; 1 2 3]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
64 %! b(:,:,2) = [10 11 12; 7 8 9]; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
65 %! assert (flipud (a), b); |
19126
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
66 |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
67 ## Test NDArray with singleton dimensions |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
68 %!test |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
69 %! a(:,:,:,1) = [ 1 2 3; 4 5 6]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
70 %! a(:,:,:,2) = [ 7 8 9; 10 11 12]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
71 %! b(:,:,:,1) = [ 4 5 6; 1 2 3]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
72 %! b(:,:,:,2) = [10 11 12; 7 8 9]; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
73 %! assert (flipud (a), b); |
19126
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
74 |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
75 ## Test for 1 row, i.e., returns the same |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
76 %!test |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
77 %! a(1,:,:,1) = [ 1 2 3 4]; |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
78 %! a(1,:,:,2) = [ 5 6 7 8]; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
79 %! assert (flipud (a), a); |
7411 | 80 |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
81 %!error <Invalid call> flipud () |