def test_dict_like_interfaces(): td = TabularData(["col-1", "col-2"]) td.extend([["foo", "bar"], ["foobar", "foobar"]]) assert td.keys() == ["col-1", "col-2"] assert dict(td.items()) == { "col-1": ["foo", "foobar"], "col-2": ["bar", "foobar"], } assert td.as_dict() == [ {"col-1": "foo", "col-2": "bar"}, {"col-1": "foobar", "col-2": "foobar"}, ] assert td.as_dict(["col-1"]) == [{"col-1": "foo"}, {"col-1": "foobar"}]
def test_to_parallel_coordinates(tmp_dir, mocker): (tmp_dir / "foo").mkdir() td = TabularData(["categorical", "scalar"]) td.extend([["foo", "0.1"], ["bar", "2"]]) write = mocker.patch("dvc_render.html.render_html") renderer_class = mocker.patch( "dvc_render.plotly.ParallelCoordinatesRenderer" ) renderer = renderer_class.return_value td.to_parallel_coordinates(output_path="foo") renderer_class.assert_called_with( td.as_dict(), color_by=None, fill_value=td._fill_value ) write.assert_called_with(renderers=[renderer], output_file="foo")