Hi !
I want to aggregate two Points x and z.
import openturns as ot
x = ot.Point([1.0, 2.0, 3.0])
y = ot.Point([4.0, 5.0])
I would like to produce the Point([1.0, 2.0, 3.0, 4.0, 5.0]) by concatenating the values from x and y.
The first version that came to my mind was the “naive” way, using two for loops.
dimX = x.getDimension()
dimY = y.getDimension()
dim = dimX + dimY
z = ot.Point(dim)
for i in range(dimX):
z[i] = x[i]
for i in range(dimY):
z[i + dimX] = y[i]
Looking at the API more closely, I found the add method, which simplifies the scripts a bit:
z = ot.Point(x)
for i in range(dimY):
z.add(y[i])
However, I have two regrets:
- we cannot add a full
Pointin one single statement withz.add(y)so that we cannot avoid aforloop here (without using Numpy), - the verb
addreally meansappend(addmay be confused with the vector addition).
Is there any other method that I missed in the API?
Regards,
Michaël