def setup(self): # Expanding an array into a higher-rank array val = np.array([ [1., 2., 3.], [4., 5., 6.], ]) array = self.declare_input('array', val=val) expanded_array = ot.expand(array, (2, 4, 3, 1), 'ij->iajb') self.register_output('expanded_array', expanded_array)
def setup(self): # Test array expansion val = np.array([ [1., 2., 3.], [4., 5., 6.], ]) array = self.declare_input('array', val=val) expanded_array = ot.expand(array, (2, 4, 3, 1), 'ij->ijab') self.register_output('expanded_array', expanded_array)
def setup(self): n = 20 u = self.declare_input('u', shape=(n, ), val=np.arange(n).reshape((n, ))) v = self.declare_input('v', shape=(n - 4, ), val=np.arange(n - 4).reshape((n - 4, ))) w = self.declare_input('w', shape=(4, ), val=16 + np.arange(4).reshape((4, ))) x = self.create_output('x', shape=(n, )) x[0:n] = 2 * (u + 1) y = self.create_output('y', shape=(n, )) y[0:n - 4] = 2 * (v + 1) y[n - 4:n] = w - 3 # Get value from indices z = self.create_output('z', shape=(3, )) z[0:3] = ot.expand(x[2], (3, )) self.register_output('x0_5', x[0:5]) self.register_output('x3_', x[3:]) self.register_output('x2_4', x[2:4])
def setup(self): # Expanding a scalar into an array scalar = self.declare_input('scalar', val=1.) expanded_scalar = ot.expand(scalar, (2, 3)) self.register_output('expanded_scalar', expanded_scalar)
def setup(self): scalar = self.declare_input('scalar', val=1.) expanded_scalar = ot.expand((2, 3), scalar) self.register_output('expanded_scalar', expanded_scalar)