Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# 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 |
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
# 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 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 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 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
@udf.scalar() | |
def circle_filter(val: udf.float32, row: udf.int64, col: udf.int64, | |
nrows: udf.int64, ncols: udf.int64) | |
-> udf.float32: | |
x = (2. * row / nrows) - 1. | |
y = (2. * col / ncols) - 1. | |
if ((x ** 2 + y ** 2) <= 1) and val >= 0.5: | |
return 1. | |
return math.nan |
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
@udf.scalar() | |
def circle_filter(val: udf.float32, row: udf.int64, col: udf.int64, | |
nrows: udf.int64, ncols: udf.int64) -> udf.float32: | |
x = (2. * row / nrows) - 1. | |
y = (2. * col / ncols) - 1. | |
if ((x ** 2 + y ** 2) <= 1) and val >= 0.5: | |
return 1. | |
return math.nan |
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
import iarray as ia | |
shape = (40_000, 40_000) | |
ia.set_config_defaults(dtype=np.float32, fp_mantissa_bits=15) | |
rand_data = ia.random.random_sample(shape) |
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
@udf.scalar() | |
def square_filter(val: udf.float32) -> udf.float32: | |
if val >= 0.5: | |
return 1. | |
return math.nan |