mat2str uses depreciated is_complex

View: New views
4 Messages — Rating Filter:   Alert me  

mat2str uses depreciated is_complex

by Richard Bovey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In octave 3.0.1 mat2str.m uses the depreciated is_complex.m function.

I'm using Windows XP.

An example session below.

Regards,
Richard

-----------------

>> OCTAVE_VERSION
ans = 3.0.1
>> mat2str([1 1])
warning: is_complex is obsolete and will be removed from a future version of Octave; please use iscomplex instead
ans = [1,1]

Re: mat2str uses depreciated is_complex

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, May 20, 2008 at 11:08 AM, Richard Bovey
<Richard.Bovey@...> wrote:
>
> In octave 3.0.1 mat2str.m uses the depreciated is_complex.m function.
>

I fixed that and added a few tests and also found some bugs when the
tests failed.

2008-05-20  Kim Hansen  <kimhanse@...>

        * strings/mat2str.m: Change is_complex to iscomplex, add
tests, add missing ;

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437

[mat2str.patch]

diff --git a/scripts/strings/mat2str.m b/scripts/strings/mat2str.m
--- a/scripts/strings/mat2str.m
+++ b/scripts/strings/mat2str.m
@@ -74,9 +74,9 @@
     error ("mat2str: X must be two dimensional");
   endif
 
-  x_is_complex = is_complex (x);
+  x_iscomplex = iscomplex (x);
 
-  if (! x_is_complex)
+  if (! x_iscomplex)
     fmt = sprintf ("%%.%dg", n(1));
   else
     if (length (n) == 1 )
@@ -92,7 +92,7 @@
     s = "[]";
   elseif (nel == 1)
     ## Scalar X, don't print brackets
-    if (! x_is_complex)
+    if (! x_iscomplex)
       s = sprintf (fmt, x);
     else
       s = sprintf (fmt, real (x), imag (x));
@@ -100,11 +100,11 @@
   else
     ## Non-scalar X, print brackets
     fmt = [fmt, ","];
-    if (! x_is_complex)
+    if (! x_iscomplex)
       s = sprintf (fmt, x.');
     else
-      x = x.';
-      s = sprintf (fmt, [real(x(:))'; imag(x(:))']);
+      t = x.';
+      s = sprintf (fmt, [real(t(:))'; imag(t(:))']);
     endif
 
     s = ["[", s];
@@ -115,6 +115,11 @@
   endif
 
   if (strcmp ("class", cls))
-    s = [class(x), "(", s, ")"]
+    s = [class(x), "(", s, ")"];
   endif
 endfunction
+
+%!assert (mat2str ([-1/3 + i/7; 1/3 - i/7], [4 2]), "[-0.3333+0.14i;0.3333-0.14i]")
+%!assert (mat2str ([-1/3 +i/7; 1/3 -i/7], [4 2]), "[-0.3333+0i,0+0.14i;0.3333+0i,-0-0.14i]")
+%!assert (mat2str (int16 ([1 -1]), 'class'), "int16([1,-1])")
+


_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: mat2str uses depreciated is_complex

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, May 20, 2008 at 1:39 PM, Kim Hansen <kimhanse@...> wrote:

> On Tue, May 20, 2008 at 11:08 AM, Richard Bovey
> <Richard.Bovey@...> wrote:
>>
>> In octave 3.0.1 mat2str.m uses the depreciated is_complex.m function.
>>
>
> I fixed that and added a few tests and also found some bugs when the
> tests failed.
>
> 2008-05-20  Kim Hansen  <kimhanse@...>
>
>        * strings/mat2str.m: Change is_complex to iscomplex, add
> tests, add missing ;
The same change as sent earlier, now with "hg export" changeset attached.

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437


_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

mat2str.hg (2K) Download Attachment

Re: mat2str uses depreciated is_complex

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 21-May-2008, Kim Hansen wrote:

| On Tue, May 20, 2008 at 1:39 PM, Kim Hansen <kimhanse@...> wrote:
| > On Tue, May 20, 2008 at 11:08 AM, Richard Bovey
| > <Richard.Bovey@...> wrote:
| >>
| >> In octave 3.0.1 mat2str.m uses the depreciated is_complex.m function.
| >>
| >
| > I fixed that and added a few tests and also found some bugs when the
| > tests failed.
| >
| > 2008-05-20  Kim Hansen  <kimhanse@...>
| >
| >        * strings/mat2str.m: Change is_complex to iscomplex, add
| > tests, add missing ;
|
| The same change as sent earlier, now with "hg export" changeset attached.

I applied this change.

Thanks,

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave