Skip to content

Commit

Permalink
[Fix] summarize_changes: was_deleted count
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed Jul 22, 2019
1 parent ebdf770 commit 5b9f40a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ankipandas/ankidf.py
Expand Up @@ -886,7 +886,7 @@ def was_added(self, other: pd.DataFrame = None, _force=False):
new_indices = set(self.index) - other_ids
return self.index.isin(new_indices)

def was_deleted(self, other: pd.DataFrame = None, _force=False):
def was_deleted(self, other: pd.DataFrame = None, _force=False) -> List:
""" Compare with original table, return deleted indizes.
Args:
Expand Down Expand Up @@ -1195,7 +1195,7 @@ def summarize_changes(self, output="print") -> Optional[dict]:
"n": len(self),
"n_modified": sum(self.was_modified(na=False)),
"n_added": sum(self.was_added()),
"n_deleted": sum(self.was_deleted()),
"n_deleted": len(self.was_deleted()),
}
as_dict["has_changed"] = (
as_dict["n_modified"] or as_dict["n_added"] or as_dict["n_deleted"]
Expand Down
2 changes: 1 addition & 1 deletion ankipandas/collection.py
Expand Up @@ -164,7 +164,7 @@ def _prepare_write_data(
continue
if key in ["notes", "cards", "revs"]:
if not delete:
ndeleted = sum(value.was_deleted())
ndeleted = len(value.was_deleted())
if ndeleted:
raise ValueError(
"You specified delete=False, but {} rows of item "
Expand Down

0 comments on commit 5b9f40a

Please sign in to comment.