def test_copy_paste_with_constant_string(): features = pd.DataFrame(index=range(3)) text_manager = TextManager(string={'constant': 'A'}, features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) np.testing.assert_array_equal(text_manager.values, 'A')
def test_copy_paste_with_manual_string(): features = pd.DataFrame(index=range(3)) text_manager = TextManager(string=['A', 'B', 'C'], features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) np.testing.assert_array_equal(text_manager.values, ['A', 'B', 'C', 'A', 'C'])
def test_copy_paste_with_constant_color(): color = {'constant': 'blue'} features = pd.DataFrame(index=range(3)) text_manager = TextManager(color=color, features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) actual = text_manager.color._values assert_colors_equal(actual, 'blue')
def test_copy_paste_with_derived_color(): color = {'feature': 'colors'} features = pd.DataFrame({'colors': ['green', 'red', 'magenta']}) text_manager = TextManager(color=color, features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) actual = text_manager.color._values assert_colors_equal(actual, ['green', 'red', 'magenta', 'green', 'magenta'])
def test_copy_paste_with_manual_color(): color = ['magenta', 'red', 'yellow'] features = pd.DataFrame(index=range(3)) text_manager = TextManager(color=color, features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) actual = text_manager.color._values assert_colors_equal(actual, ['magenta', 'red', 'yellow', 'magenta', 'yellow'])
def test_copy_paste_with_derived_string(): features = pd.DataFrame({'class': ['A', 'B', 'C']}) text_manager = TextManager(string='class: {class}', features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) np.testing.assert_array_equal( text_manager.values, ['class: A', 'class: B', 'class: C', 'class: A', 'class: C'], )
def test_view_text_with_constant_text(): features = pd.DataFrame(index=range(3)) text_manager = TextManager(string={'constant': 'A'}, features=features) copied = text_manager._copy([0, 2]) text_manager._paste(**copied) actual = text_manager.view_text([0, 1]) # view_text promises to return an Nx1 array, not just something # broadcastable to an Nx1, so explicitly check the length # because assert_array_equal broadcasts scalars automatically assert len(actual) == 2 np.testing.assert_array_equal(actual, ['A', 'A'])