Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve error handling of column.stability when given a column that contains only None #388

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/safeds/data/tabular/containers/_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def stability(self) -> float:
\frac{\text{number of occurrences of most common non-null value}}{\text{number of non-null values}}
$$

The stability cannot be calculated for a column with only null values.
The stability is not definded for a column with only null values.

Returns
-------
Expand All @@ -520,7 +520,7 @@ def stability(self) -> float:
raise ColumnSizeError("> 0", "0")

if self.all(lambda x: x is None):
raise ValueError("Stability cannot be calculated for a column with only null values.")
raise ValueError("Stability is not definded for a column with only null values.")

return self._data.value_counts()[self.mode()[0]] / self._data.count()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def test_should_raise_column_size_error_if_column_is_empty() -> None:

def test_should_raise_value_error_if_column_contains_only_none() -> None:
column: Column[Any] = Column("A", [None, None])
with pytest.raises(ValueError, match="Stability cannot be calculated for a column with only null values."):
with pytest.raises(ValueError, match="Stability is not definded for a column with only null values."):
column.stability()