Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List of NumPy math supported functions for omnisci #38

Closed
84 of 100 tasks
guilhermeleobas opened this issue Feb 28, 2020 · 4 comments
Closed
84 of 100 tasks

List of NumPy math supported functions for omnisci #38

guilhermeleobas opened this issue Feb 28, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request heavydb Related to heavydb server

Comments

@guilhermeleobas
Copy link
Contributor

guilhermeleobas commented Feb 28, 2020

The following numpy functions are tested by creating UDF definitions taking with scalar inputs.

Trigonometric functions

  • np.sin(x)
  • np.cos(x)
  • np.tan(x)
  • np.arcsin(x)
  • np.arccos(x)
  • np.arctan(x)
  • np.hypot(x,y) - see forbidden name section below
  • np.arctan2(x,y)
  • np.radians
  • np.degrees
  • np.deg2rad
  • np.rad2deg

Hyperbolic functions

  • np.sinh(x) - see forbidden name section below
  • np.cosh(x) - see forbidden name section below
  • np.tanh(x) - see forbidden name section below
  • np.arcsinh(x)
  • np.arccosh(x)
  • np.arctanh(x)

Rounding

  • np.around(a)
  • np.round_(a) - see forbidden name section below
  • np.rint(x) - see forbidden name section below
  • np.fix(x) - not supported by Numba
  • np.floor(x)
  • np.ceil(x)
  • np.trunc(x) - see forbidden name section below
  • np.rint(x)
  • np.spacing(x)
  • np.nextafter(x, y)

Sums, products, differences

Needs a better list/array support.

  • np.prod(x)
  • np.sum(x)

Needs support for returning an omnisci array

  • np.nanprod(x)
  • np.nansum(x)
  • np.cumprod(x)
  • np.cumsum(x)
  • np.nancumprod(x)
  • np.nancumsum(x)
  • np.diff(x)
  • np.ediff1d(x)
  • np.gradient(x)
  • np.cross(x)
  • np.trapz(x)

Exponents and logarithms

  • np.exp(x)
  • np.expm1(x) - see forbidden name section below
  • np.exp2(x) - see forbidden name section below
  • np.log(x)
  • np.log10(x)
  • np.log2(x) - see forbidden name section below
  • np.log1p(x) - see forbidden name section below
  • np.logaddexp(x, y)
  • np.logaddexp2(x, y)
  • np.frexp - not supported by Numba, returns (<float>, <int>)
  • np.ldexp(x)

Rational routines

  • np.lcm(x1, x2) - see forbidden name section below
  • np.gcd(x1, x2) - see forbidden name section below
  • np.left_shift(x1, x2)
  • np.right_shift(x1, x2)

Arithmetic operations

  • np.absolute(x)
  • np.conjugate(x)
  • np.fabs(x)
  • np.fmin(x, y)
  • np.fmax(x, y)
  • np.minimum(x, y)
  • np.maximum(x, y)
  • np.negative(x)
  • np.positive(x) - not supported by Numba
  • np.sign(x)
  • np.reciprocal(x)
  • np.add(x1, x2)
  • np.subtract(x1, x2)
  • np.multiply(x1, x2)
  • np.divide(x1, x2)
  • np.true_divide(x1, x2)
  • np.floor_divide(x1, x2)
  • np.power(x1, x2)
  • np.float_power(x1, x2) - not supported by Numba
  • np.square(x)
  • np.sqrt(x)
  • np.cbrt(x) - not supported by Numba, np.cbrt cannot support in nopython mode  numba/numba#5385
  • np.remainder(x1, x2)
  • np.fmod(x1, x2)
  • np.mod(x1, x2)
  • np.modf(x)
  • np.divmod(x1, x2) - not supported by Numba, returns tuple
  • np.copysign(x, y)
  • np.heaviside(x, y) - not supported by Numba, np.heaviside in no_python mode numba/numba#4706

Logical functions

  • np.isfinite(x)
  • np.isinf(x)
  • np.isnan(x)
  • np.isnat(x)
  • np.signbit(x)
  • np.less(x, y)
  • np.less_equal(x, y)
  • np.greater(x, y)
  • np.greater_equal(x, y)
  • np.equal(x, y)
  • np.not_equal(x, y)
  • np.logical_not(x)
  • np.logical_or(x, y)
  • np.logical_xor(x, y)
  • np.logical_and(x, y)

Forbidden UDF names (OmnisciDB 5.1 or earlier)

The following names cannot be used as the names of UDF function definitions:

  • fmod
  • sinh
  • cosh
  • tanh
  • rint
  • trunc
  • expm1
  • exp2
  • log2
  • log1p
  • gcd
  • lcm
  • around
  • hypot

https://github.com/omnisci/omniscidb-internal/pull/4133 removes the above restriction.

@guilhermeleobas guilhermeleobas added the enhancement New feature or request label Feb 28, 2020
@pearu pearu added this to the Release 0.2.1 milestone Mar 16, 2020
@pearu pearu modified the milestones: Release 0.2.1, Release 0.3.0 Mar 26, 2020
@guilhermeleobas guilhermeleobas changed the title List of NumPy math supported functions List of NumPy math supported functions for omnisci Jun 1, 2020
@guilhermeleobas
Copy link
Contributor Author

guilhermeleobas commented Jun 2, 2020

We need to test if those functions works when applied to an array. For instance:

@omnisci(double[](int64))
def apply_sin(size):
    arr = Array(size, 'double')
    for i in range(size):
        arr[i] = nb_types.double(i)
    return np.sin(arr)

query = 'select apply_sin(5);`
result, _ = omni.sql_execute(query)
out = list(result)[0]
print(out) # should print [ 0.        ,  0.84147098,  0.90929743,  0.14112001, -0.7568025 ]

Edit: They do not work on arrays.

@guilhermeleobas
Copy link
Contributor Author

Closing this issue in favor of #31

@guilhermeleobas
Copy link
Contributor Author

I will re-open this issue and update it to contain a table of math functions we support on CPU and CUDA.

@guilhermeleobas guilhermeleobas added the heavydb Related to heavydb server label Oct 20, 2020
@guilhermeleobas guilhermeleobas self-assigned this Oct 22, 2020
@guilhermeleobas
Copy link
Contributor Author

Closing again in favor of #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request heavydb Related to heavydb server
Projects
None yet
Development

No branches or pull requests

2 participants