Skip to content

Commit

Permalink
feat: move exceptions back to common package
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed May 6, 2023
1 parent 56a1fc4 commit 62ffa48
Show file tree
Hide file tree
Showing 57 changed files with 107 additions and 125 deletions.
2 changes: 1 addition & 1 deletion src/safeds/data/tabular/containers/_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from safeds.data.image.containers import Image
from safeds.data.image.typing import ImageFormat
from safeds.data.tabular.exceptions import (
from safeds.exceptions import (
ColumnLengthMismatchError,
ColumnSizeError,
IndexOutOfBoundsError,
Expand Down
2 changes: 1 addition & 1 deletion src/safeds/data/tabular/containers/_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pandas as pd

from safeds.data.tabular.exceptions import UnknownColumnNameError
from safeds.exceptions import UnknownColumnNameError
from safeds.data.tabular.typing import ColumnType, Schema

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion src/safeds/data/tabular/containers/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from safeds.data.image.containers import Image
from safeds.data.image.typing import ImageFormat
from safeds.data.tabular.exceptions import (
from safeds.exceptions import (
ColumnLengthMismatchError,
ColumnSizeError,
DuplicateColumnNameError,
Expand Down
23 changes: 0 additions & 23 deletions src/safeds/data/tabular/exceptions/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/safeds/data/tabular/transformation/_imputer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sklearn.impute import SimpleImputer as sk_SimpleImputer

from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.data.tabular.transformation._table_transformer import TableTransformer
from safeds.data.tabular.typing import ImputerStrategy

Expand Down
2 changes: 1 addition & 1 deletion src/safeds/data/tabular/transformation/_label_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sklearn.preprocessing import OrdinalEncoder as sk_OrdinalEncoder

from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.data.tabular.transformation._table_transformer import (
InvertibleTableTransformer,
)
Expand Down
2 changes: 1 addition & 1 deletion src/safeds/data/tabular/transformation/_one_hot_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sklearn.preprocessing import OneHotEncoder as sk_OneHotEncoder

from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.exceptions import TransformerNotFittedError, UnknownColumnNameError
from safeds.data.tabular.transformation._table_transformer import (
InvertibleTableTransformer,
)
Expand Down
2 changes: 1 addition & 1 deletion src/safeds/data/tabular/typing/_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

from safeds.data.tabular.exceptions import UnknownColumnNameError
from safeds.exceptions import UnknownColumnNameError
from safeds.data.tabular.typing._column_type import ColumnType

if TYPE_CHECKING:
Expand Down
40 changes: 40 additions & 0 deletions src/safeds/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Custom exceptions that can be raised by Safe-DS."""

from safeds.exceptions._data import (
ColumnLengthMismatchError,
ColumnSizeError,
DuplicateColumnNameError,
IndexOutOfBoundsError,
NonNumericColumnError,
SchemaMismatchError,
TransformerNotFittedError,
UnknownColumnNameError,
)
from safeds.exceptions._ml import (
DatasetContainsTargetError,
DatasetMissesFeaturesError,
LearningError,
ModelNotFittedError,
PredictionError,
UntaggedTableError,
)

__all__ = [
# Data exceptions
"ColumnLengthMismatchError",
"ColumnSizeError",
"DuplicateColumnNameError",
"IndexOutOfBoundsError",
"NonNumericColumnError",
"SchemaMismatchError",
"TransformerNotFittedError",
"UnknownColumnNameError",

# ML exceptions
"DatasetContainsTargetError",
"DatasetMissesFeaturesError",
"LearningError",
"ModelNotFittedError",
"PredictionError",
"UntaggedTableError",
]
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/safeds/ml/classical/_util_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any

from safeds.data.tabular.containers import Table, TaggedTable
from safeds.ml.exceptions import (
from safeds.exceptions import (
DatasetContainsTargetError,
DatasetMissesFeaturesError,
LearningError,
Expand Down
2 changes: 1 addition & 1 deletion src/safeds/ml/classical/classification/_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sklearn.metrics import accuracy_score as sk_accuracy_score

from safeds.data.tabular.containers import Table, TaggedTable
from safeds.ml.exceptions import UntaggedTableError
from safeds.exceptions import UntaggedTableError

if TYPE_CHECKING:
from typing import Any
Expand Down
4 changes: 2 additions & 2 deletions src/safeds/ml/classical/regression/_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from sklearn.metrics import mean_squared_error as sk_mean_squared_error

from safeds.data.tabular.containers import Column, Table, TaggedTable
from safeds.data.tabular.exceptions import ColumnLengthMismatchError
from safeds.ml.exceptions import UntaggedTableError
from safeds.exceptions import ColumnLengthMismatchError
from safeds.exceptions import UntaggedTableError

if TYPE_CHECKING:
from sklearn.base import RegressorMixin
Expand Down
19 changes: 0 additions & 19 deletions src/safeds/ml/exceptions/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import ColumnLengthMismatchError, NonNumericColumnError
from safeds.exceptions import ColumnLengthMismatchError, NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import IndexOutOfBoundsError
from safeds.exceptions import IndexOutOfBoundsError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import IndexOutOfBoundsError
from safeds.exceptions import IndexOutOfBoundsError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import ColumnSizeError
from safeds.exceptions import ColumnSizeError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/safeds/data/tabular/containers/_column/test_mean.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import ColumnSizeError
from safeds.exceptions import ColumnSizeError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from safeds.data.image.containers import Image
from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError

from tests.helpers import resolve_resource_path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import ColumnSizeError
from safeds.exceptions import ColumnSizeError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/safeds/data/tabular/containers/_column/test_sum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column
from safeds.data.tabular.exceptions import NonNumericColumnError
from safeds.exceptions import NonNumericColumnError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column, Table
from safeds.data.tabular.exceptions import ColumnSizeError, DuplicateColumnNameError
from safeds.exceptions import ColumnSizeError, DuplicateColumnNameError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column, Table
from safeds.data.tabular.exceptions import ColumnSizeError, DuplicateColumnNameError
from safeds.exceptions import ColumnSizeError, DuplicateColumnNameError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from _pytest.python_api import raises
from safeds.data.tabular.containers import Row, Table
from safeds.data.tabular.exceptions import SchemaMismatchError
from safeds.exceptions import SchemaMismatchError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Row, Table
from safeds.data.tabular.exceptions import SchemaMismatchError
from safeds.exceptions import SchemaMismatchError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column, Table
from safeds.data.tabular.exceptions import ColumnLengthMismatchError
from safeds.exceptions import ColumnLengthMismatchError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import ColumnLengthMismatchError
from safeds.exceptions import ColumnLengthMismatchError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Row, Table
from safeds.data.tabular.exceptions import SchemaMismatchError
from safeds.exceptions import SchemaMismatchError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Column, Table
from safeds.data.tabular.exceptions import UnknownColumnNameError
from safeds.exceptions import UnknownColumnNameError


@pytest.mark.parametrize(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Row, Table
from safeds.data.tabular.exceptions import IndexOutOfBoundsError
from safeds.exceptions import IndexOutOfBoundsError


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/safeds/data/tabular/containers/_table/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import ColumnLengthMismatchError
from safeds.exceptions import ColumnLengthMismatchError
from safeds.data.tabular.typing import Integer, Schema


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import TransformerNotFittedError
from safeds.exceptions import TransformerNotFittedError
from safeds.data.tabular.transformation import OneHotEncoder


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from safeds.data.tabular.containers import Table
from safeds.data.tabular.exceptions import UnknownColumnNameError
from safeds.exceptions import UnknownColumnNameError


@pytest.mark.parametrize(
Expand Down
Loading

0 comments on commit 62ffa48

Please sign in to comment.