Numpy universal functions are "vectorized" functions operating on elements (element by element) on a Numpy array.
Questions tagged [numpy-ufunc]
198 questions
0
votes
2 answers
Creating numpy functions and converting to tensor
I am trying to create function using numpy something like f=(x-a1)^2+(y-a2)^2+a3
Where a1,a2,a3 are random generated numbers and x,y are parameters.
But I cant work with it, I want to find f(0,0) where [0,0] is [x,y] and [a1,a2,a3] were set…

Станислав Китаев
- 147
- 9
0
votes
0 answers
get numpy matrix rows have intersection with array
I have huge list of int32 numpy 1d arrays. Is there an efficient way to get indexes of rows having non-empty intersection with test array? Basically I'm looking for faster replacement for pythonic expression:
indexes = [
i for i, n in…

demon.mhm
- 469
- 4
- 18
0
votes
2 answers
how to refer to all rows in numpy.ufunc.at
How to refer to all rows or a slice for given columns in numpy.ufunc.at
this works for columns:
c = np.array([[1,2,4],[5,3,4]])
np.add.at(c, [[0,1],], 999)
print(c)
out:
[[1000 1001 1003]
[1004 1002 1003]]
but, these both fail
c =…

figs_and_nuts
- 4,870
- 2
- 31
- 56
0
votes
0 answers
Declaring vectorized ufunc with numba, signature error: 'Float' instance not allowed
I'm trying to write a function that can be vectorized by numba to act as a ufunc on a set of arrays:
from numba import float32, float64, vectorize
@vectorize([float32, float32, float32, float32(float32, float32, float32, float32, float32, float32,…

James Adams
- 8,448
- 21
- 89
- 148
0
votes
1 answer
Is there a way to serialize a sympy ufuncify-ied function?
Is there a way to serialize or save a function that has been binarized using the ufuncify tool from SymPy's autowrap module?
There is a solution here using dill: How to serialize sympy lambdified function?, but this only works for lambdified…

Ken
- 114
- 1
- 4
0
votes
1 answer
"ufunc 'hyp2f1' not supported for the input types" error
When I'm trying to run the following code:
import math
from scipy import special as spec
import numpy as np
from sympy import *
y = Symbol('y')
x = spec.hyp2f1(1.5, 2.5, 1, y**2)
ans = x.diff(y)
print ans
I get…

ani87
- 17
- 5
0
votes
1 answer
Append npy file to another npy file with same number of columns in both files
npy files size are around 5 gb and RAM is around 5gb so cannot load both numpy arrays. How to load one npy file and append its rows to other npy file without loading it

charanReddy
- 137
- 1
- 11
0
votes
1 answer
Calculate mean & var numpy genfromtxt dataframe - TypeError ufunc add
I have simple text files containing floating numbers, e.g.:
3.235235
0.2346236
1.235235
I'm trying to calculate mean & variance for every file using the following code:
import numpy
import os
def main():
for filename in os.listdir("./"):
…

Adiel
- 1,203
- 3
- 18
- 31
0
votes
1 answer
How can a numpy.ufunc.reduceat indices be generated from Python Slice Object
Say I have a slice like x[p:-q:n] or x[::n] I want to use this to generate the index to be passed into numpy.ufunc.reduceat(x, [p, p + n, p + 2 * n, ...]) or numpy.ufunc.reduceat(x, [0, n, 2 * n, ...]). What is the easiest and efficient way to get…

Suminda Sirinath S. Dharmasena
- 1,831
- 3
- 26
- 35
0
votes
1 answer
np.ndarray bitwise_or operator on ndarrays fails
I want to initialize a numpy array of size (n,m) that can only contain zeros or ones.
Furthermore, I want to later to np.bitwise_or with the array.
For example, If I try:
import numpy as np
myArray = np.zeros([4,4])
myRow = myArray[1,]
myCol =…

Dnaiel
- 7,622
- 23
- 67
- 126
0
votes
1 answer
Pandas / Numpy Won't Play Nice
I am attempting to install Pandas and Numpy together so that they will work. I am currently getting the error "numpy.ufunction has the wrong size, try recompiling". Which seems to indicate that the version of Numpy that Pandas needs is incorrect.…

user2320821
- 1,141
- 3
- 13
- 19
-1
votes
2 answers
how to avoid loops when using numpy
I have an numpy array with size of 10x250000 and I need to change values of it during the program but using "for loop" make my program very slow. it is the mentioned section of program. (L2 , L1 and T are other arrays)…

shanster
- 23
- 4
-1
votes
1 answer
Converting to str a numpy and join with pandas series
I need help to add some random integers and some prefixed str to a pandas series. I' ll better explain:
I' ve got my pandas series called variables and would like to add to it random integers from 1 to 10 and also a plus and a space.
Let' s say at a…
-1
votes
2 answers
loop of ufunc does not support argument 0 of type float which has no callable exp method
I am having trouble with an optimization that used to work with a previous version of python...
I have a function fp = lambda c, x: (c[0])+ (c[1]*((1- np.exp(-x/c[4]))/(x/c[4])))+ (c[2]*((((1-np.exp(-x/c[4]))/(x/c[4])))- (np.exp(-x/c[4]))))+…

Santiago Etchepare Sierra
- 1
- 1
- 1
- 2
-1
votes
1 answer
How to check for NaNs in a numpy ndarray which contains strings
Normally I can check for NaNs with numpy.isnan() :
import numpy as np
arr1 = np.array([[1, 2], [3, 4], [np.nan, 5]])
print(type(arr1))
print(np.isnan(arr1))
[[False False]
[False False]
[ True False]]
But how can I…

Nibood_the_slightly_advanced
- 287
- 4
- 15