gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
270 stars 61 forks source link

A detail in SIZE(/struct) for HASH() and LIST() #1807

Closed alaingdl closed 2 months ago

alaingdl commented 3 months ago

Working in cleaning some other tests, I got this small mistake for HASH() and LIST().

h = HASH('a',1,'b',2,'c',3)
strucobj = SIZE(h,/struct)
print,(strucobj).dimensions

GDL return : 
           0           0           0           0           0           0           0           0
IDL return :
           3           0           0           0           0           0           0           0
(8 dimensions, 3 elements in the first one)

and for LIST()

l = LIST('a',1,'b',2,'c',3)
strucobj = SIZE(l,/struct)
print,(strucobj).dimensions

GDL return : 
           0           0           0           0           0           0           0           0
IDL return :
           6           0           0           0           0           0           0           0
(8 dimensions, 6 elements in the first one)

The value is OK for arrays (1, [1], [1,2], ...)

alaingdl commented 3 months ago

just to confirm that this problem don't exist for true structures, e.g. (as in test_structures.pro)

 structarray=REPLICATE({test, value:0.0},10)
 size(STRUCTARRAY,/stru)
 size(STRUCTARRAY[0],/stru)

same outputs in IDL & GDL :)

(but I will try to add that somewhere in the test suite)

alaingdl commented 3 months ago

ok, also print,(strucobj).n_dimensions is wrong in both cases (but OK for structures ...)

alaingdl commented 2 months ago

These bugs are corrected in #1815

Please open a new issue if related problems found, with related snippets.