bugGNU Octave - Bugs: bug #59135, jsondecode converts logical arrays...

 
 

bug #59135: jsondecode converts logical arrays to numeric arrays

Submitted by:  Rik <rik5>
Submitted on:  Fri 18 Sep 2020 08:11:39 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

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 28 Sep 2020 03:30:51 PM UTC, comment #4: 

Thank you Abdallah.  I verified the patch and checked it in here http://hg.savannah.gnu.org/hgweb/octave/rev/ffa6c50c2eaa.

I made a few small changes.  Octave uses spaces, rather than tabs, because the tabstop setting is never the same between computers and this always leads to mis-indented code.  Also, in the commit message one usually writes what was done and where it was done (function name), rather than just the result.  So I changed "Fix bug" (result) to "* jsondecode.cc (decode_array_of_arrays): Check value of is_bool and return
either boolNDArray (logical) or NDArray (numeric)."

I'm marking this bug as fixed and closing it.  Unfortunately, while testing I found that multi-dimensional logical arrays are encoded to multi-dimensional numeric arrays.  I'll file a new bug report about that.

Rik <rik5>
Project Administrator
Sat 26 Sep 2020 12:57:32 PM UTC, comment #3: 
Abdallah Khaled Elshamy <abdallah_elshamy>
Fri 18 Sep 2020 10:49:32 PM UTC, comment #2: 

@Abdallah: Thank you, that would be great if you could take a look.

Rik <rik5>
Project Administrator
Fri 18 Sep 2020 10:17:06 PM UTC, comment #1: 

I will be happy to help with that since I wrote this function during my GSoC project.

I will be working on it soon.

Abdallah Khaled Elshamy <abdallah_elshamy>
Fri 18 Sep 2020 08:11:39 PM UTC, original submission:  

The following is from a BIST test for jsondecode:

 json = '[[true, true], [false, true]]';
exp  = logical ([1, 1; 0, 1]);
obs  = jsondecode (json);
assert (isa (obs, 'logical'));
assert (isequal (obs, exp));
!!!!! test failed
assert (isa (obs, 'logical')) failed

The decoded matrix type should be logical, but instead is of class "double".  This does not happen for logical scalars.

octave:1> isa (jsondecode ('true'), "logical")
ans = 1

Rik <rik5>
Project Administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by abdallah_elshamy (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-09-28 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2020-09-27 siko1056 StatusConfirmed => Patch Submitted

    Back to the top


    Powered by Savane 3.5