Re: IDL removes dimensions of size 1 automatically [message #41132] |
Wed, 29 September 2004 17:07  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Reimar Bauer wrote:
> David Fanning wrote:
>
>> Mark Hadfield writes:
>>
>>
>>> I support the idea of a compiler option to turn this behaviour off. I
>>> suspect, however, that implementing it would open up a Pandora's box
>>> of worms, as the saying goes.
>>
>>
>> I think you must be doing a literal translation from the German. :-)
>>
>
>
> Die B�chse der Pandora
Mit Wurmen?
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|
|
Re: IDL removes dimensions of size 1 automatically [message #41148 is a reply to message #41145] |
Wed, 29 September 2004 08:01   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
David Fanning wrote:
> Mark Hadfield writes:
>
>
>> I support the idea of a compiler option to turn this behaviour off. I
>> suspect, however, that implementing it would open up a Pandora's box of
>> worms, as the saying goes.
>
>
> I think you must be doing a literal translation from
> the German. :-)
>
Die B�chse der Pandora
Nach der griechischen Mythologie wurde die verf�hrerische Pandora von
Hephaistos erschaffen. Zeus gab ihr ein Gef�� mit, die B�chse der
Pandora, das zahlreiche �bel enthielt, als Bestrafung f�r den Diebstahl
des Prometheus, der den Menschen das Feuer gebracht hatte. Als Pandora
das Gef�� �ffnete, verteilten sich sofort diese �bel �ber die gesamte
Erde. Einzig die Hoffung blieb in Pandoras B�chse zur�ck.
( http://www.noeastro.de/Astrologie/Astro_Aktuell/Astro_News/s tammzellen.jsp)
David, did you have enjoyed the soccer match yesterday?
Reimar
|
|
|
|
|
Re: IDL removes dimensions of size 1 automatically [message #41183 is a reply to message #41179] |
Sun, 26 September 2004 01:36   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Benjamin Hornberger wrote:
> Hi all,
>
> I had a hard time finding a bug which came from IDL's behaviour to
> remove dimensions of size 1 automatically sometimes.
>
> IDL> a=[[1u,1u]]
> IDL> help,a
> A UINT = Array[2]
> IDL> ;; IDL doesn't even let me specify this (2,1) element array
> IDL> a=reform(a,2,1)
> IDL> help,a
> A UINT = Array[2, 1]
> IDL> b=fix(a)
> IDL> help,b
> B INT = Array[2]
> IDL> ;; IDL removed my second dimension even though I just wanted to
> change the type
> IDL> c=2*a
> IDL> help,c
> C INT = Array[2]
> IDL> print,c
> 2 2
> IDL> ;; again IDL kicked out my second dimension
>
> I found this very annoying. Does anyone know more about it? Why is it
> like that? In which situations will IDL do that?
>
> Thanks for any comments,
>
> Benjamin
Dear Benjamin
this is regular discussed here. It's not a bug because this is described in
all documents about array handling from RSI.
I have had a lot of problems by this too. You could do a feature request to
to get a compiler option implemented which controls this too.
Here are an additional examples about this:
IDL> c=reform(make_array(10,1),10,1)
IDL> help,c
C FLOAT = Array[10, 1]
IDL> D=C
IDL> help,D
D FLOAT = Array[10]
The solution is:
IDL> c=reform(make_array(10,1),10,1)
IDL> s=size(c,/dim)
IDL> d=reform(c,s)
IDL> help,d
D FLOAT = Array[10, 1]
Reimar
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|
|
|
Re: IDL removes dimensions of size 1 automatically [message #41189 is a reply to message #41183] |
Fri, 24 September 2004 13:16   |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Paul Van Delst wrote:
> Benjamin Hornberger wrote:
>
>> Hi all,
>>
>> I had a hard time finding a bug which came from IDL's behaviour to
>> remove dimensions of size 1 automatically sometimes.
>>
>> IDL> a=[[1u,1u]]
>> IDL> help,a
>> A UINT = Array[2]
>> IDL> ;; IDL doesn't even let me specify this (2,1) element array
>> IDL> a=reform(a,2,1)
>> IDL> help,a
>> A UINT = Array[2, 1]
>> IDL> b=fix(a)
>> IDL> help,b
>> B INT = Array[2]
>> IDL> ;; IDL removed my second dimension even though I just wanted to
>> change the type
>> IDL> c=2*a
>> IDL> help,c
>> C INT = Array[2]
>> IDL> print,c
>> 2 2
>> IDL> ;; again IDL kicked out my second dimension
>>
>> I found this very annoying. Does anyone know more about it? Why is it
>> like that? In which situations will IDL do that?
>
>
> Only trailing dimensions of size 1 are removed.
>
> IDL> x=fltarr(20,1,1,1,1)
> IDL> help, x
> X FLOAT = Array[20]
> IDL> x=fltarr(1,1,1,1,20)
> IDL> help, x
> X FLOAT = Array[1, 1, 1, 1, 20]
> IDL> x=fltarr(20,1,3,1,1)
> IDL> help, x
> X FLOAT = Array[20, 1, 3]
>
> This has always been the case (in my experience) - much to the
> consternation of some IDL users, and to the joy to others. YMMV.
>
And,... when you think that the trailing dimension is important then use REFORM
liberally...
IDL> a = reform(intarr(2,1),2,1)
IDL> help, a
A INT = Array[2, 1]
IDL> dim = SIZE(a, /dim)
IDL> b = REFORM(a,dim)
IDL> help, b
B INT = Array[2, 1]
IDL> b = REFORM(a*2,dim)
IDL> help, b
B INT = Array[2, 1]
Ben
|
|
|
Re: IDL removes dimensions of size 1 automatically [message #41190 is a reply to message #41189] |
Fri, 24 September 2004 11:14   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Benjamin Hornberger wrote:
> Hi all,
>
> I had a hard time finding a bug which came from IDL's behaviour to
> remove dimensions of size 1 automatically sometimes.
>
> IDL> a=[[1u,1u]]
> IDL> help,a
> A UINT = Array[2]
> IDL> ;; IDL doesn't even let me specify this (2,1) element array
> IDL> a=reform(a,2,1)
> IDL> help,a
> A UINT = Array[2, 1]
> IDL> b=fix(a)
> IDL> help,b
> B INT = Array[2]
> IDL> ;; IDL removed my second dimension even though I just wanted to
> change the type
> IDL> c=2*a
> IDL> help,c
> C INT = Array[2]
> IDL> print,c
> 2 2
> IDL> ;; again IDL kicked out my second dimension
>
> I found this very annoying. Does anyone know more about it? Why is it
> like that? In which situations will IDL do that?
Only trailing dimensions of size 1 are removed.
IDL> x=fltarr(20,1,1,1,1)
IDL> help, x
X FLOAT = Array[20]
IDL> x=fltarr(1,1,1,1,20)
IDL> help, x
X FLOAT = Array[1, 1, 1, 1, 20]
IDL> x=fltarr(20,1,3,1,1)
IDL> help, x
X FLOAT = Array[20, 1, 3]
This has always been the case (in my experience) - much to the consternation of some IDL
users, and to the joy to others. YMMV.
paulv
|
|
|
|