Skip to content

Commit 251e8f9

Browse files
authored
Merge pull request #1528 from GillesDuvert/patch_congrid
congrid was complaining if last dimension was 1
2 parents c5c7bae + 2955585 commit 251e8f9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/pro/congrid.pro

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ if (npar lt 2) or (npar gt 4) or KEYWORD_SET(help) then begin
6666
print,' the pixel at (0,[0,[0]]) is clipped to 1/4 size.'
6767
print,' Default is that pixel start (not center) is at index.'
6868
print,' CUBIC=cubic: use a cubic interpolation. -0 to -1. -0.5 is recommended.'
69-
print,' /MINUS_ONE: option will be ignored. MISSING can be used instead.'
7069
print, ' /HELP gives this help.'
7170
print,' NOTE: CONGRID performs a resampling. Does not conserve Fluxes.'
7271
return,''
@@ -76,6 +75,11 @@ ON_ERROR, 2 ;Return to caller if error
7675
;
7776
ndim = SIZE(t, /N_DIMENSIONS)
7877
dims = SIZE(t, /DIMENSIONS)
78+
; remove spurious dimensions 1:
79+
while dims[ndim-1] eq 1 do begin
80+
ndim--
81+
dims=dims[0:-2]
82+
endwhile
7983
;
8084
if(ndim EQ 0) then MESSAGE, 'Array must have 1, 2, or 3 dimensions.'
8185
if(ndim gt 3) then $

testsuite/interactive_tests/test_congrid.pro

+14
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ end
135135
;
136136
; ---------------------------------
137137
;
138+
pro test_congrid_last_dimension_1,cumul_errors
139+
catch,problem
140+
if problem ne 0 then begin
141+
BANNER_FOR_TESTSUITE, 'TEST_CONGRID_last_dimension_1', 1, /short
142+
ERRORS_CUMUL, cumul_errors, 1
143+
return
144+
endif
145+
z=indgen(256) & zz=reform(z, 256, 1)
146+
zzz=congrid(zz,100,1)
147+
end
148+
;
149+
; ---------------------------------
150+
;
138151
pro TEST_CONGRID, help=help, noexit=noexit, test=test
139152
;
140153
if KEYWORD_SET(help) then begin
@@ -153,6 +166,7 @@ TEST_CONGRID_BASIC, cumul_errors, nbp=121, /byte
153166
TEST_CONGRID_ON_IMAGES, cumul_errors
154167
;
155168
TEST_CONGRID_ON_PLOT, cumul_errors
169+
TEST_CONGRID_LAST_DIMENSION_1,cumul_errors
156170
;
157171
; AC 2022-Dec-15 : cleanup of the device + reset color table
158172
;

0 commit comments

Comments
 (0)