bugGNU Octave - Bugs: bug #47526, set with mixed struct and...

 
 

bug #47526: set with mixed struct and property-value-pairs errors

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Thu 24 Mar 2016 05:58:45 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
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 26 Mar 2016 05:08:50 AM UTC, comment #6: 

I applied your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/38c0c1f5cf57).  I added the bug number to the commit message as this helps us track which changeset fixed a problem.

Rik <rik5>
Group administrator
Thu 24 Mar 2016 11:24:48 PM UTC, comment #5: 

Some more tests with Matlab:
This is working (3 patches in red, green and blue):

figure
h_patch(1) = patch ();
figure
h_patch(2) = patch ();
figure
h_patch(3) = patch ();

props = {'FaceColor'};
fc ={'r', 'g', 'b'}';

set (h_patch, props, fc)


This fails:

figure
h_patch(1) = patch ();
figure
h_patch(2) = patch ();
figure
h_patch(3) = patch ();

pv{1}.facecolor = 'r';
pv{2}.facecolor = 'g';
pv{3}.facecolor = 'b';

set (h_patch, pv')


The error is

Error using hg.patch/set
Only one object may be passed to set for information about
possible property values.


To sum it up: Passing a cell of structs fails. Passing an array of structs does work. However, only the value in the last element is set.
This behavior is similar if the same property is set several times with property value pairs. The following will produce a blue patch:

h_patch = patch ();
set (h_patch, 'FaceColor', 'r', 'FaceColor', 'g', 'FaceColor', 'b')


Octave seems to behave the same.
The only thing that does not seem to work in Octave is passing a mix of structs and property value pairs. This case should be fixed with the patch without breaking the other cases.

Markus Mützel <mmuetzel>
Group administrator
Thu 24 Mar 2016 08:45:56 PM UTC, comment #4: 

Fascinating.  So it appears that a mix is good, but a struct array is bad.

Rik <rik5>
Group administrator
Thu 24 Mar 2016 08:19:41 PM UTC, comment #3: 

A quick check in Matlab showed that the structs and property value pairs can be freely mixed. The following example works correctly:

set (h, prop1, value1, struct1, struct2, prop2, value2, struct3)



As to mapping an array of structs to an array of handles: The following example turns all patches to blue:

figure
h_patch(1) = patch ();
figure
h_patch(2) = patch ();
figure
h_patch(3) = patch ();

pv(1).facecolor = 'r';
pv(2).facecolor = 'g';
pv(3).facecolor = 'b';

set (h_patch, pv)



Markus Mützel <mmuetzel>
Group administrator
Thu 24 Mar 2016 06:48:15 PM UTC, comment #2: 

If it does, it appears to be undocumented.

But then again, things like


set (h, p1, v1, p2, v2, ...)


don't seem to be documented either, and I'm pretty sure that works.

It is, however, documented that you can do


set (handles, props, vals)


with handles props and vals all being cell arrays.  I'm not sure how particular it is about sizes, though it appears to be possible to set different values for a given property for each handle.

Also, I don't know whether calls like


set (handles, struct_array)


are supposed to work if struct array has the right dimensions for the vector of handles.  I would assume so, since this could be converted directly to the


set (handles, props, values)


form.

John W. Eaton <jwe>
Group administrator
Thu 24 Mar 2016 06:25:42 PM UTC, comment #1: 

Do you have access to Matlab?  Can you test whether mixed struct/pairs are supported?

Rik <rik5>
Group administrator
Thu 24 Mar 2016 05:58:45 PM UTC, original submission:  

When setting properties, they can be passed as structures or as property value pairs. While setting the properties in either the one or the other form works, it fails when both are mixed:

[x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2);
val = x.^2 + y.^2 + z.^2;
fv = isosurface (x, y, z, val, 1);
h_patch = patch ();
set (h_patch, fv) % works fine
set (h_patch, "FaceColor", "g") % works fine

set (h_patch, fv, "FaceColor", "g")


The last line throws the error:

error: set: invalid number of arguments



Attached please find a patch fixing this error.

Markus Mützel <mmuetzel>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #36752:  set_struct_pv.patch added by mmuetzel (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-26 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-03-24 rik5 StatusNeed Info Confirmed
    2016-03-24 jwe Release4.0.1-rc1 dev
    2016-03-24 rik5 StatusNone Need Info
    2016-03-24 mmuetzel Attached File- Added set_struct_pv.patch, #36752

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code