File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ All notable changes to this project will be documented in this file.
87
87
- #2078 : Fix translation of classes containing comments.
88
88
- #2041 : Include all type extension methods by default.
89
89
- #2082 : Allow the use of a list comprehension to initialise an array.
90
+ - #2094 : Fix slicing of array allocated in an if block.
90
91
91
92
### Changed
92
93
Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ def set_changeable_shape(self):
245
245
Indicate that the exact shape is unknown, e.g. if the allocate is done in
246
246
an If block.
247
247
"""
248
- self ._shape = [ PyccelArrayShapeElement (self , LiteralInteger (i )) for i in range (self .rank )]
248
+ self ._shape = tuple ( PyccelArrayShapeElement (self , LiteralInteger (i )) for i in range (self .rank ))
249
249
250
250
def set_init_shape (self , shape ):
251
251
"""
Original file line number Diff line number Diff line change @@ -167,6 +167,26 @@ def f(c : 'float'):
167
167
c = np .random .random ()
168
168
assert f (c ) == g (c )
169
169
170
+ #==============================================================================
171
+ def test_creation_in_if_heap_shape (language ):
172
+
173
+ def f (c : 'float' ):
174
+ import numpy as np
175
+ if c > 0.5 :
176
+ x = np .ones (2 , dtype = int )
177
+ else :
178
+ x = np .ones (7 , dtype = int )
179
+
180
+ y = x [1 :- 1 ]
181
+ return y .sum ()
182
+
183
+ g = epyccel (f , language = language )
184
+
185
+ # Check result of pyccelized function
186
+ import numpy as np
187
+ c = np .random .random ()
188
+ assert f (c ) == g (c )
189
+
170
190
#==============================================================================
171
191
def test_Reassign_to_Target ():
172
192
You can’t perform that action at this time.
0 commit comments