In my current project when I run my tests (with pytest) I get this output (besides others):
ml_framework/tests/test_impute.py: 8 warnings
ml_framework/tests/test_transform_pipeline.py: 9 warnings
ml_framework/tests/test_data_transforms.py: 27 warnings
ml_framework/tests/test_jsonizer.py: 4 warnings
/home/sondracek/anaconda3/envs/p3.8/lib/python3.8/site-packages/sklearn/utils/validation.py:70: FutureWarning: Pass standardize=False as keyword args. From version 1.0 (renaming of 0.25) passing these as positional arguments will result in an error
warnings.warn(f"Pass {args_msg} as keyword args. From version "
This FutureWarning is quite clear - from version 1.0 (I'm using 0.24 at the moment) there will be change to some parameters and I will not be able to pass standardize as positional arguments.
But the question is - How can I locate where should I change this positional argument to a keyword one?
I could go to validation.py that is mentioned in the warning output, but there is general _deprecate_positional_args function which does not tell me which code call it.
In this particular case I'm guessing this will come from PowerTransformer imported from sklearn.preprocessing which is used in my code, has standardize parameter and is tested in the listed tests. Is there a general way how to find the cause of that easily for any FutureWarning? Or do I need to check all my codes and try to find it somehow?
Pytest let you raise a
FutureWarningas an error, this way it points to the code location where the warning was raised, the simplest way is through the warning flagor inside
test_script.pythrough pytestmarkyou can read more about specifying the action being taken on a Warning here and here.
Example
Considering the following dummy example
test_transform.pyscriptand running on terminal
the logs show me exactly that
PowerTransformerraised theFutureWarning.