Source code for openmdao.test_suite.components.options_feature_array

"""
A component that multiplies an array by an input value, where
the array is given as an option of type 'numpy.ndarray'.
"""
import numpy as np

import openmdao.api as om


[docs]class ArrayMultiplyComp(om.ExplicitComponent):
[docs] def initialize(self): self.options.declare('array', types=np.ndarray)
[docs] def setup(self): array = self.options['array'] self.add_input('x', 1.) self.add_output('y', shape=array.shape) self.declare_partials(of='*', wrt='*')
[docs] def compute(self, inputs, outputs): outputs['y'] = self.options['array'] * inputs['x']