mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
TabularData: Simplify drop internals.
Update `subset` type hint.
This commit is contained in:
committed by
Gao
parent
646097a735
commit
d4861d535a
@@ -391,7 +391,7 @@ def show_experiments(
|
||||
td.drop(*cols_to_drop)
|
||||
|
||||
if pcp:
|
||||
subset = [x for x in td.keys() if x != "Experiment"]
|
||||
subset = {x for x in td.keys() if x != "Experiment"}
|
||||
td.dropna(
|
||||
"rows",
|
||||
how="all",
|
||||
|
||||
+7
-7
@@ -137,13 +137,10 @@ class TabularData(MutableSequence[Sequence["CellT"]]):
|
||||
return len(self.columns), len(self)
|
||||
|
||||
def drop(self, *col_names: str) -> None:
|
||||
to_remove = set()
|
||||
for col in col_names:
|
||||
if not self.is_protected(col):
|
||||
to_remove.add(col)
|
||||
for col in to_remove:
|
||||
self._keys.remove(col)
|
||||
self._columns.pop(col)
|
||||
self._keys.remove(col)
|
||||
self._columns.pop(col)
|
||||
|
||||
def rename(self, from_col_name: str, to_col_name: str) -> None:
|
||||
self._columns[to_col_name] = self._columns.pop(from_col_name)
|
||||
@@ -215,7 +212,10 @@ class TabularData(MutableSequence[Sequence["CellT"]]):
|
||||
]
|
||||
|
||||
def dropna(
|
||||
self, axis: str = "rows", how="any", subset: Optional[List] = None
|
||||
self,
|
||||
axis: str = "rows",
|
||||
how="any",
|
||||
subset: Optional[Iterable[str]] = None,
|
||||
):
|
||||
if axis not in ["rows", "cols"]:
|
||||
raise ValueError(
|
||||
@@ -266,7 +266,7 @@ class TabularData(MutableSequence[Sequence["CellT"]]):
|
||||
def drop_duplicates(
|
||||
self,
|
||||
axis: str = "rows",
|
||||
subset: Optional[List] = None,
|
||||
subset: Optional[Iterable[str]] = None,
|
||||
ignore_empty: bool = True,
|
||||
):
|
||||
if axis not in ["rows", "cols"]:
|
||||
|
||||
@@ -791,8 +791,8 @@ def test_show_experiments_pcp(tmp_dir, mocker):
|
||||
show_experiments(all_experiments, pcp=True)
|
||||
|
||||
td.drop.assert_called_with("Created")
|
||||
td.dropna.assert_called_with("rows", how="all", subset=[])
|
||||
td.drop_duplicates.assert_called_with("rows", subset=[])
|
||||
td.dropna.assert_called_with("rows", how="all", subset=set())
|
||||
td.drop_duplicates.assert_called_with("rows", subset=set())
|
||||
|
||||
kwargs = td.to_parallel_coordinates.call_args[1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user