Skip to content

Tag: numpy

How to vectorize a function with lists as argument?

I need help vectorizing a function in numpy. In Julia, I can do something like that: which returns It takes one sublist at a time from the iterables and expands nothing. In Python, I just can’t get to have a similar behaviour. I tried: but it returns: If I do: I get back: I tried with excluded parameter…

Numpy array assignment along axis and index

I have a 3D volume and I modify slices along different axis. (np.take is equivalent of writing self.volume[idx], self.volume[:, idx] and self.volume[:, :, idx]) Finally, I want to assign a new slice in my volume along the axis : This is where I need some help. I can’t figure out a cleaner way of doing t…

Reflecting 4d symmetric data

I’ve found out that there is no example of how to reflect symmetric 4d data, which can be very useful when 3d simulations wants to be performed using a symmetric plane to reduce calculations(e.g. ANSYS, COMSOL, etc). This example shows a data file structure corresponding to a COMSOL simulation, which ha…