Fix reconstruct: throw ArgumentError on invalid input type #239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses the issue #238 by improving the error handling in the fallback reconstruct method for dimensionality reduction models. Now, whenever it is called with an input which is not an AbstractVecOrMat of real numbers, an ArgumentError is thrown with a clear message which helps user to know the invalid input type and the expected input type.This closes the issue #238
Approach
Following is the way of my approach which ensures users receive clear, actionable feedback and aligns with Julia's best practices for error handling.Confirmed that the fallback reconstruct method previously gave a misleading error when it was called with an invalid input type.
Replace the generic error with a more meaningful, specific and reasonable error which clearly states the received and expected types.
Updated the necessary documentation and docstring for it.
Added and verified tests to ensure the new error is raised for invalid input types.
Tests
All tests pass.Notes
I have attached images showing that the tests are passing
Images:
Feedbacks are welcome.