Invalid x_train Type: Ensures a TypeError is raised when x_train is neither a DataFrame nor an ndarray.
Invalid y_train Type: Checks for a TypeError if y_train is not a Series or ndarray.
Invalid task_type: Verifies that providing a non-string task_type raises a TypeError, and an incorrect string raises a ValueError.
Invalid models Type: Asserts a TypeError is raised if models is not a dictionary.
Invalid priority_metrics Type: Checks for a TypeError when priority_metrics is not a list.
Invalid priority_tuners Type: Verifies a TypeError for non-list priority_tuners.
Invalid custom_param_grids Type: Asserts a TypeError if custom_param_grids is not a dictionary.
Invalid n_jobs, cv, verbose, and random_state Types: Ensures TypeErrors are raised if these parameters are not integers.
Invalid cv Value: Confirms a ValueError if cv is less than 1.
Invalid Iteration Values: Checks for ValueErrors when n_iter_random or n_iter_bayesian are less than 1.
Value Error Tests:
Mismatched x_train and y_train Shapes: Ensures a ValueError is raised if x_train and y_train do not have compatible shapes.
Empty x_train or y_train: Confirms ValueErrors are raised if x_train or y_train are empty.
Duplicate or Invalid priority_metrics: Verifies that ValueErrors are raised for duplicate values or invalid metric names in priority_metrics.
Incompatible Metrics for Task Type: Checks for ValueErrors if metrics not suitable for the specified task_type are provided.
Excessive n_top_models: Ensures a ValueError if n_top_models exceeds the number of available models for the specified task.
Unrecognized priority_tuners: Verifies a ValueError for unrecognized tuner names.
Inappropriate refit_metric: Checks for a ValueError if refit_metric is not suitable for the given task_type.
Functionality tests: ... *
Example Test Code
Here's an example of testing invalid x_train type:
def test_model_tuning_core_invalid_x_train_type(sample_data_mrc_mtc):
"""
Tests if model_tuning_core raises TypeError when 'x_train' is not a DataFrame or ndarray.
"""
_, y_train_classification, _ = sample_data_mrc_mtc
with pytest.raises(TypeError):
model_tuning_core(x_train="invalid_type", y_train=y_train_classification, task_type='classification', models={'model': LogisticRegression()})
This test ensures that the function properly checks x_train's data type and raises an appropriate error if it's not a DataFrame or ndarray.
Access the Full Test Suite*
For a comprehensive view of all tests, including their implementations and additional configurations, you can access the full test suite here.
Test Descriptions
Type Error Tests:
x_train
Type: Ensures a TypeError is raised whenx_train
is neither a DataFrame nor an ndarray.y_train
Type: Checks for a TypeError ify_train
is not a Series or ndarray.task_type
: Verifies that providing a non-stringtask_type
raises a TypeError, and an incorrect string raises a ValueError.models
Type: Asserts a TypeError is raised ifmodels
is not a dictionary.priority_metrics
Type: Checks for a TypeError whenpriority_metrics
is not a list.priority_tuners
Type: Verifies a TypeError for non-listpriority_tuners
.custom_param_grids
Type: Asserts a TypeError ifcustom_param_grids
is not a dictionary.n_jobs
,cv
,verbose
, andrandom_state
Types: Ensures TypeErrors are raised if these parameters are not integers.cv
Value: Confirms a ValueError ifcv
is less than 1.n_iter_random
orn_iter_bayesian
are less than 1.Value Error Tests:
x_train
andy_train
Shapes: Ensures a ValueError is raised ifx_train
andy_train
do not have compatible shapes.x_train
ory_train
: Confirms ValueErrors are raised ifx_train
ory_train
are empty.priority_metrics
: Verifies that ValueErrors are raised for duplicate values or invalid metric names inpriority_metrics
.task_type
are provided.n_top_models
: Ensures a ValueError ifn_top_models
exceeds the number of available models for the specified task.priority_tuners
: Verifies a ValueError for unrecognized tuner names.refit_metric
: Checks for a ValueError ifrefit_metric
is not suitable for the giventask_type
.Functionality tests: ... *
Example Test Code
Here's an example of testing invalid
x_train
type:This test ensures that the function properly checks
x_train
's data type and raises an appropriate error if it's not a DataFrame or ndarray.Access the Full Test Suite*
For a comprehensive view of all tests, including their implementations and additional configurations, you can access the full test suite here.