2828BLOSC = True
2929ZARR = False
3030HDF5 = False
31+ SPARSE = False
3132
3233NDIMS = 2 # must be at least 2
3334
@@ -59,9 +60,10 @@ def genarray(r, ndims=2, verbose=True):
5960for d in target_sizes :
6061 arr , arrsize = genarray (d , ndims = NDIMS )
6162 genuine_sizes += [arrsize ]
62- idx = rng .integers (low = 0 , high = arr .shape [0 ], size = (arr .shape [0 ]// 4 ,))
63+ sparseness = 1000 if SPARSE else arr .shape [0 ]// 4
64+ idx = rng .integers (low = 0 , high = arr .shape [0 ], size = (sparseness ,))
6365 sorted_idx = np .sort (np .unique (idx ))
64- col = rng .integers (low = 0 , high = arr .shape [0 ], size = (arr . shape [ 0 ] // 4 ,))
66+ col = rng .integers (low = 0 , high = arr .shape [0 ], size = (sparseness ,))
6567 col_sorted = np .sort (np .unique (col ))
6668 mask = rng .integers (low = 0 , high = 2 , size = (arr .shape [0 ],)) == 1
6769
@@ -134,7 +136,7 @@ def timer(arr):
134136 error_kw = dict (lw = 2 , capthick = 2 , ecolor = 'k' ))
135137 labs += label
136138
137- filename = f"results{ labs } { NDIMS } D"
139+ filename = f"results{ labs } { NDIMS } D" + "sparse" if SPARSE else f"results { labs } { NDIMS } D"
138140
139141with open (f"{ filename } .pkl" , 'wb' ) as f :
140142 pickle .dump (result_tuple , f )
@@ -143,7 +145,7 @@ def timer(arr):
143145plt .legend ()
144146plt .xticks (x - width , np .round (genuine_sizes , 2 ))
145147plt .ylabel ("Time (s)" )
146- plt .title (f"Fancy indexing performance comparison, { NDIMS } D" )
148+ plt .title (f"Fancy indexing performance comparison, { NDIMS } D" + f" { " sparse" if SPARSE else "" } " )
147149plt .gca ().set_yscale ('log' )
148150plt .savefig (f'plots/fancyIdx{ filename } .png' , format = "png" )
149151plt .show ()
0 commit comments