Skip to content

Commit

Permalink
Add exceptions module.
Browse files Browse the repository at this point in the history
  • Loading branch information
tompollard committed Jun 13, 2024
1 parent 038466c commit bd27742
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
6 changes: 6 additions & 0 deletions tableone/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Exceptions and warnings"""


class InputError(Exception):
"""Custom exception for input validation errors."""
pass
2 changes: 1 addition & 1 deletion tableone/preprocessors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from tableone.validators import InputError
from tableone.exceptions import InputError


def ensure_list(arg, arg_name):
Expand Down
2 changes: 1 addition & 1 deletion tableone/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from statsmodels.stats import multitest

from tableone.modality import hartigan_diptest
from tableone.validators import InputError
from tableone.exceptions import InputError


class Statistics:
Expand Down
2 changes: 1 addition & 1 deletion tableone/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd

from tableone.statistics import Statistics
from tableone.validators import InputError
from tableone.exceptions import InputError


class Tables:
Expand Down
7 changes: 2 additions & 5 deletions tableone/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import pandas as pd


class InputError(Exception):
"""Custom exception for input validation errors."""
pass
from tableone.exceptions import InputError


class DataValidator:
Expand Down Expand Up @@ -169,5 +166,5 @@ def check_columns_exist(self, columns: list, categorical: list, continuous: list
all_specified = cat_set.union(cont_set)
if not all_specified.issubset(set(columns)):
missing = list(all_specified - set(columns))
msg = "Specified categorical/continuous columns not found in the DataFrame: f"{missing}"
msg = f"Specified categorical/continuous columns not found in the DataFrame: {missing}"
raise ValueError(msg)

0 comments on commit bd27742

Please sign in to comment.