def test_colors_like_rgb_triple_as_row(self): c = [[1.0, 0.0, 1.0]] v = np.ones((4, 3)) vc = color.colors_like(c, v, colormap=self.colormap) expected_c = np.array([1.0, 0.0, 1.0]) * v np.testing.assert_array_equal(expected_c, vc) self.assertEqual(vc.dtype, np.float64)
def test_colors_like_with_name(self): c = 'red' v = np.ones((4, 3)) vc = color.colors_like(c, v, colormap=self.colormap) expected_c = np.array([1.0, 0.0, 0.0]) * v np.testing.assert_array_equal(expected_c, vc) self.assertEqual(vc.dtype, np.float64)
def test_colors_like_with_list(self): c = [1.0, 0.0, 1.0, 0.0] v = np.ones((4, 3)) vc = color.colors_like(c, v, colormap=self.colormap) expected_c = np.array([self.jet_1, self.jet_0, self.jet_1, self.jet_0]) np.testing.assert_array_equal(expected_c, vc) self.assertEqual(vc.dtype, np.float64)
def test_colors_like_none_or_empty(self): for c in [None, [], (), np.array([])]: v = np.ones((4, 3)) vc = color.colors_like(c, v, colormap=self.colormap) self.assertIsNone(vc)
def test_colors_like_with_full_array_transposed(self): c = np.random.rand(10, 3) v = np.ones((10, 3)) vc = color.colors_like(c.T, v) np.testing.assert_array_equal(c, vc) self.assertEqual(vc.dtype, np.float64)
def vc(self, val): val = color.colors_like(val, self.v) self.__dict__['vc'] = val
def fc(self, val): val = color.colors_like(val, self.f) self.__dict__['fc'] = val