This file has been truncated, but you can view the full file.
This file contains 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
<div> | |
<style> | |
/* CSS for nbsphinx extension */ | |
/* remove conflicting styling from Sphinx themes */ | |
div.nbinput.container div.prompt *, | |
div.nboutput.container div.prompt *, | |
div.nbinput.container div.input_area pre, | |
div.nboutput.container div.output_area pre, | |
div.nbinput.container div.input_area .highlight, |
This file contains 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
@jit() | |
def udf_iarray(out: Array(float32, 3), | |
p1: Array(float32, 3), | |
p2: Array(float32, 3), | |
p3: Array(float32, 3)) -> int: | |
l = p1.window_shape[0] | |
m = p1.window_shape[1] | |
n = p1.window_shape[2] |
This file contains 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
precip_udf_expr = ia.expr_from_udf(udf_iarray, [precip1, precip2, precip3], favor=ia.Favor.SPEED) | |
precip_out = precip_udf_expr.eval() |
This file contains 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
precip_expr = ia.expr_from_string("(p1 + p2 + p3) / 3", | |
{'p1': precip1, 'p2': precip2, 'p3': precip3}, | |
) | |
precip_mean = precip_expr.eval() |
This file contains 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
precip_expr = ia.expr_from_string("(p1 + p2 + p3) / 3", | |
{'p1': precip1, 'p2': precip2, 'p3': precip3}, | |
) | |
precip_mean = precip_expr.eval(urlpath="mean-3m.iarr", mode="w") |
This file contains 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
precip_trans_expr = ia.tan(precip1) * (ia.sin(precip1) * ia.sin(precip2) + ia.cos(precip2)) + ia.sqrt(precip3) * 2 | |
precip_trans = precip_trans_expr.eval(urlpath="trans-3m.iarr", mode="w") |
This file contains 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) |
This file contains 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 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 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) |