ETA444 / datasafari

DataSafari simplifies complex data science tasks into straightforward, powerful one-liners.
https://datasafari.dev
GNU General Public License v3.0
2 stars 0 forks source link

Implement error handling for evaluate_contingency_table() #86

Closed ETA444 closed 4 months ago

ETA444 commented 4 months ago

Implementation Summary

evaluate_contingency_table() is equipped with robust error handling mechanisms to ensure the validity and integrity of input data and parameters before proceeding with statistical test evaluations. This approach enhances the function's reliability and usability by preventing common errors and ensuring appropriate feedback is provided to the user.

Detailed Error Handling Breakdown

Input Type Validation

if not isinstance(contingency_table, pd.DataFrame):
    raise TypeError("evaluate_contingency_table(): The 'contingency_table' parameter must be a pandas DataFrame.")
if not isinstance(min_sample_size_yates, int):
    raise TypeError("evaluate_contingency_table(): The 'min_sample_size_yates' parameter must be an integer.")
if not isinstance(pipeline, bool):
    raise TypeError("evaluate_contingency_table(): The 'pipeline' parameter must be a boolean.")
if not isinstance(quiet, bool):
    raise TypeError("evaluate_contingency_table(): The 'quiet' parameter must be a boolean.")

Input Value Validation

if contingency_table.empty:
    raise ValueError("evaluate_contingency_table(): The 'contingency_table' parameter must not be empty.")
if min_sample_size_yates <= 0:
    raise ValueError("evaluate_contingency_table(): The 'min_sample_size_yates' parameter must be a positive integer.")

Conclusion

The error handling implemented in evaluate_contingency_table() meticulously checks for common input errors, ensuring that only appropriate and correctly formatted data is processed. This thorough validation process not only prevents runtime errors but also guides users in correcting input mistakes, thereby facilitating a more effective and user-friendly statistical analysis experience.

Link to Full Code