Skip to content

Commit

Permalink
Remove old tests, revert unnecessary modifications, add a new exception
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaarnio committed Sep 28, 2023
1 parent c424228 commit 390564f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 109 deletions.
7 changes: 0 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
16 changes: 8 additions & 8 deletions eis_toolkit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class CoordinatesOutOfBoundsException(Exception):
"""Exception error class for out of bound coordinates."""


class ClassificationFailedException(Exception):
"""Exception error class for classification failures."""


class EmptyDataFrameException(Exception):
"""Exception error class raised if the dataframe is empty."""

Expand Down Expand Up @@ -46,16 +50,12 @@ class InvalidWktFormatException(Exception):
"""Exception error for invalid WKT format."""


class InvalidColumnIndexException(Exception):
"""Exception error for index out of range."""


class UnFavorableClassDoesntExistException(Exception):
"""Exception error class for failure to generalize classes using the given studentised contrast threshold value. Class 1 (unfavorable class) doesn't exist"""
class MatchingCrsException(Exception):
"""Exception error class for CRS matches."""


class FavorableClassDoesntExistException(Exception):
"""Exception error class for failure to generalize classes using the given studentised contrast threshold value. Class 2 (favorable class) doesn't exist"""
class MatchingRasterGridException(Exception):
"""Exception error class for raster grid matches."""


class NotApplicableGeometryTypeException(Exception):
Expand Down
9 changes: 7 additions & 2 deletions eis_toolkit/prediction/weights_of_evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from beartype import beartype
from beartype.typing import List, Literal, Optional, Sequence, Tuple, Union

from eis_toolkit import exceptions
from eis_toolkit.vector_processing.rasterize_vector import rasterize_vector


Expand Down Expand Up @@ -89,8 +90,12 @@ def _reclassify_by_studentized_contrast(df: pd.DataFrame, studentized_contrast_t
"""Create generalized classes based on the studentized contrast threhsold value."""
index = df.idxmax()["Contrast"]

if df.loc[index, "Studentized contrast"] < studentized_contrast_threshold:
raise Exception("Failed, studentized contrast is {}".format(df.loc[index, "Studentized contrast"]))
if df.loc[index, "Studentized contrast"] < studentized_contrast_threshold or index == len(df.index) - 1:
raise exceptions.ClassificationFailedException(
"Failed to create generalized classes with given studentized contrast treshold ({})".format(
df.loc[index, "Studentized contrast"]
)
)

df["Generalized class"] = 1
for i in range(0, index + 1):
Expand Down
46 changes: 0 additions & 46 deletions tests/prediction/wofe/wofe_calculate_responses_test.py

This file was deleted.

46 changes: 0 additions & 46 deletions tests/prediction/wofe/wofe_calculate_weights_test.py

This file was deleted.

0 comments on commit 390564f

Please sign in to comment.