This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import iarray as ia | |
| from iarray import udf | |
| import math | |
| # Params for array construction | |
| shape = (40_000, 40_000) | |
| ia.set_config_defaults(dtype=np.float32, fp_mantissa_bits=15) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Benchmark comparing npy, npz, jdb and blosc2 storage formats | |
| import sys | |
| import numpy as np | |
| import jdata as jd | |
| import blosc2 | |
| from time import time | |
| N = 10_000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Examples on getting orthogonal slices | |
| import iarray as ia | |
| import numpy as np | |
| dtype = np.float32 | |
| ia.set_config_defaults(dtype=dtype) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Calling scalar UDFs from expressions. | |
| # This is for 1-dim arrays. | |
| from time import time | |
| import numpy as np | |
| import iarray as ia | |
| from iarray import udf |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| c = ia.matmul(am, bm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from iarray.udf import jit, Array, float64, int64 | |
| # Create second array via an UDF | |
| @jit() | |
| def tri(out: Array(float64, 2), x: Array(float64, 2), k: int64) -> int64: | |
| n = out.window_shape[0] | |
| m = out.window_shape[1] | |
| row_start = out.window_start[0] | |
| col_start = out.window_start[1] | |
| for i in range(n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Random values with lossy compression to get some decent compression ratio | |
| am = ia.random.normal(amshape, 3, 2, chunks=amchunks, blocks=amblocks, urlpath=filename, fp_mantissa_bits=10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nrows = 100_000 # number of rows in matrix am | |
| ncols = 25000 # number of columns in first matrix | |
| ncols2 = 1000 # number of columns in second matrix | |
| shape = (nrows, ncols, ncols2) | |
| amshape = (shape[0], shape[1]) | |
| bmshape = (shape[1], shape[2]) | |
| # Obtain optimal chunk and block shapes | |
| mparams = ia.matmul_params(amshape, bmshape, dtype=np.float64) |