Zhenquan Hu
Zhenquan Hu

Reputation: 13

Reduce dimension of numpy array by defined function

With a self defined function:

    def myfunc(x1,x2, ... ,x10):                 # list
        ... 
        matrix operation on x1, x2 ..., x10      
        ...
        return X                                 # one value

What is the right way to use array operation to transfer A to B by calling myfunc() like this:

    A.myfunc() >> B

Upvotes: 1

Views: 1146

Answers (1)

Joran Beasley
Joran Beasley

Reputation: 114018

import copy
def myfunc(x1,x2, ... ,x10):                 # list
    ... 
    matrix operation on copy.deepcopy(x1), copy.deepcopy(x2) ..., copy.deepcopy(x10)      
    ...
    return X      

B = myfunc(a,b,c,d...)

I think ... is what you are looking for

arrays are mutable so in your matrix operation you are likely modifying the original arrays... it sounds like you just want to return a new dataset without modifying the existing x1..x10 arrays

of coarse there is probably a 75% chance I didnt understand what you were asking ...

Upvotes: 1

Related Questions