Ejemplo n.º 1
0
 def test_true(self):
     self.assertTrue(get_single_value(np.ones((2, 2))[:, None]) == 1)
     self.assertTrue(get_single_value(np.zeros((1,))[:, None]) == 0)
     self.assertTrue(get_single_value(np.zeros((1,))) == 0)
     self.assertTrue(get_single_value(-1) == -1)
     self.assertTrue(get_single_value(0) == 0)
     self.assertTrue(get_single_value(1) == 1)
     self.assertTrue(get_single_value(-1.0) == -1.0)
     self.assertTrue(get_single_value(0.0) == 0.0)
     self.assertTrue(get_single_value(1.0) == 1.0)
Ejemplo n.º 2
0
    def get_input_data(self, parameter_name):
        if parameter_name in self._extra_protocol:
            value = np.array(self._extra_protocol[parameter_name], copy=False)

            if all_elements_equal(value):
                return get_single_value(value)

            if value.ndim >= 3:
                value = create_roi(value, self.mask)
            return value

        if parameter_name in self._protocol:
            if all_elements_equal(self._protocol[parameter_name]):
                return get_single_value(self._protocol[parameter_name])
            return self._protocol[parameter_name]

        raise ValueError('No input data could be find for the parameter "{}".'.format(parameter_name))
Ejemplo n.º 3
0
def _bounds_to_array(bounds):
    """Create a CompositeArray to hold the bounds."""
    elements = []
    for value in bounds:
        if all_elements_equal(value):
            elements.append(Scalar(get_single_value(value), ctype='mot_float_type'))
        else:
            elements.append(Array(value, ctype='mot_float_type', as_scalar=True))
    return CompositeArray(elements, 'mot_float_type', address_space='local')