1515 MachineReal ,
1616 Symbol ,
1717 SymbolNull ,
18+ SymbolList ,
19+ SymbolRule ,
1820 from_python ,
1921)
2022from mathics .builtin .colors import (
@@ -194,7 +196,7 @@ def extract(im, evaluation):
194196 else :
195197 continue
196198
197- yield Expression ("Rule" , String (_Exif ._names .get (k , name )), value )
199+ yield Expression (SymbolRule , String (_Exif ._names .get (k , name )), value )
198200
199201
200202class ImageImport (_ImageBuiltin ):
@@ -217,15 +219,15 @@ def apply(self, path, evaluation):
217219 pillow = PIL .Image .open (path .get_string_value ())
218220 pixels = numpy .asarray (pillow )
219221 is_rgb = len (pixels .shape ) >= 3 and pixels .shape [2 ] >= 3
220- exif = Expression ("List" , * list (_Exif .extract (pillow , evaluation )))
222+ exif = Expression (SymbolList , * list (_Exif .extract (pillow , evaluation )))
221223
222224 image = Image (pixels , "RGB" if is_rgb else "Grayscale" )
223225 return Expression (
224226 "List" ,
225- Expression ("Rule" , String ("Image" ), image ),
226- Expression ("Rule" , String ("ColorSpace" ), String (image .color_space )),
227- Expression ("Rule" , String ("ImageSize" ), from_python (image .dimensions ())),
228- Expression ("Rule" , String ("RawExif" ), exif ),
227+ Expression (SymbolRule , String ("Image" ), image ),
228+ Expression (SymbolRule , String ("ColorSpace" ), String (image .color_space )),
229+ Expression (SymbolRule , String ("ImageSize" ), from_python (image .dimensions ())),
230+ Expression (SymbolRule , String ("RawExif" ), exif ),
229231 )
230232
231233
@@ -569,7 +571,7 @@ def apply_resize_width_height(self, image, width, height, evaluation, options):
569571 h = self ._get_image_size_spec (old_h , height )
570572 if h is None or w is None :
571573 return evaluation .message (
572- "ImageResize" , "imgrssz" , Expression ("List" , width , height )
574+ "ImageResize" , "imgrssz" , Expression (SymbolList , width , height )
573575 )
574576
575577 # handle Automatic
@@ -696,7 +698,7 @@ def apply(self, image, orig, dest, evaluation):
696698
697699 if method is None :
698700 return evaluation .message (
699- "ImageReflect" , "bdrfl2" , Expression ("Rule" , orig , dest )
701+ "ImageReflect" , "bdrfl2" , Expression (SymbolRule , orig , dest )
700702 )
701703
702704 return Image (method (image .pixels ), image .color_space )
@@ -1041,7 +1043,7 @@ def apply(self, image, r, t, evaluation):
10411043
10421044
10431045def _matrix (rows ):
1044- return Expression ("List" , * [Expression ("List" , * r ) for r in rows ])
1046+ return Expression (SymbolList , * [Expression (SymbolList , * r ) for r in rows ])
10451047
10461048
10471049class BoxMatrix (_ImageBuiltin ):
@@ -1467,7 +1469,7 @@ def apply(self, image, evaluation):
14671469 else :
14681470 for i in range (pixels .shape [2 ]):
14691471 images .append (Image (pixels [:, :, i ], "Grayscale" ))
1470- return Expression ("List" , * images )
1472+ return Expression (SymbolList , * images )
14711473
14721474
14731475class ColorCombine (_ImageBuiltin ):
@@ -1755,7 +1757,7 @@ def result():
17551757 else :
17561758 yield Expression (out_palette_head , * prototype )
17571759
1758- return Expression ("List" , * itertools .islice (result (), 0 , at_most ))
1760+ return Expression (SymbolList , * itertools .islice (result (), 0 , at_most ))
17591761
17601762
17611763# pixel access
@@ -1893,7 +1895,7 @@ def apply(self, image, x, y, evaluation):
18931895 return evaluation .message ("PixelValue" , "nopad" )
18941896 pixel = pixels_as_float (image .pixels )[height - y , x - 1 ]
18951897 if isinstance (pixel , (numpy .ndarray , numpy .generic , list )):
1896- return Expression ("List" , * [MachineReal (float (x )) for x in list (pixel )])
1898+ return Expression (SymbolList , * [MachineReal (float (x )) for x in list (pixel )])
18971899 else :
18981900 return MachineReal (float (pixel ))
18991901
@@ -1940,7 +1942,7 @@ def apply(self, image, val, d, evaluation):
19401942 result = sorted (
19411943 (j + 1 , height - i , k + 1 ) for i , j , k in positions .tolist ()
19421944 )
1943- return Expression ("List" , * (Expression ("List" , * arg ) for arg in result ))
1945+ return Expression (SymbolList , * (Expression (SymbolList , * arg ) for arg in result ))
19441946
19451947
19461948# image attribute queries
@@ -1968,7 +1970,7 @@ class ImageDimensions(_ImageBuiltin):
19681970
19691971 def apply (self , image , evaluation ):
19701972 "ImageDimensions[image_Image]"
1971- return Expression ("List" , * image .dimensions ())
1973+ return Expression (SymbolList , * image .dimensions ())
19721974
19731975
19741976class ImageAspectRatio (_ImageBuiltin ):
@@ -2297,8 +2299,8 @@ def storage_type(self):
22972299 def options (self ):
22982300 return Expression (
22992301 "List" ,
2300- Expression ("Rule" , String ("ColorSpace" ), String (self .color_space )),
2301- Expression ("Rule" , String ("MetaInformation" ), self .metadata ),
2302+ Expression (SymbolRule , String ("ColorSpace" ), String (self .color_space )),
2303+ Expression (SymbolRule , String ("MetaInformation" ), self .metadata ),
23022304 )
23032305
23042306
0 commit comments