Improve diagnostics when conversion between mtypes is not defined
Is your feature request related to a problem? Please describe.
While inspecting the implementation of the convert function in skpro/datatypes/_convert.py, I noticed that when a conversion between two mtypes is not defined, the code raises a NotImplementedError with a minimal error message.
Example error: NotImplementedError: no conversion defined from type X to Y
However, this error message does not provide enough diagnostic information for debugging conversion failures. It does not include:
- the type of the object being converted
- available conversion pairs registered in the converter registry
- possible compatible mtypes
This can make debugging datatype conversion issues difficult when working with pipelines or extending the datatype system.
Describe the solution you'd like
Improve the error diagnostics when a conversion between two mtypes is not defined.
For example, enhance the NotImplementedError message to include additional context such as:
- the detected object type
- the source and target mtypes
- available conversion pairs in the registry
Example improvement: raise NotImplementedError( f"No conversion defined from '{from_type}' to '{to_type}'. " f"Available conversions: {list(convert_dict.keys())}" )
This would help developers better understand why a conversion failed and what conversions are currently supported.
Describe alternatives you've considered
One alternative approach could be improving documentation of supported mtype conversions so users know which conversions are valid.
However, improving the runtime error message would provide immediate feedback and help developers debug conversion issues more efficiently.
Additional context
Relevant file:
skpro/datatypes/_convert.py
The improvement would occur in the section where the converter key (from_type, to_type, as_scitype) is checked against the conversion registry.
Improving diagnostics here would make debugging conversion failures easier for developers and contributors extending the datatype system.
Likely AI generated since there is no failing code or usage problem reported.