Last active
September 12, 2022 07:49
-
-
Save FrancescAlted/9fbfe7a953b3b092cdd1ff63cdd61856 to your computer and use it in GitHub Desktop.
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment