Cleanup TransferFunction input sanitization. #134
Closed
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.
This started out to address #112 & #130, but I found a few other small edge cases.
To simplify unit testing I broke the input cleaning out to a separate function and added as many test cases as I could think of.
Deep copy
It performs a deep copy on args before anything else.
Test Code:
Before:
After:
Validate All Input Types:
The previous input validation would only check the first element if it was a valid input type. This means you could feed in extra bad values in other positions and it would accept it, only to fail later.
Test Code:
Before:
It would accept the values (and mutate the inputs):
But fail when you tried to access the system:
After
It fails immediately:
Added more valid types.
If you passed an numpy array as an input it would possibly fail depending on which architecture you were using it on.
int
resolves toint64
on 64-bit systems. It now accepts valid types ofint, int8, int16, int32, int64, float, float16, float32, float64, float128
. (If for some reason your transfer function parts were generated in another function).Code:
Before:
After:
Added Tuple as valid collection for MIMO systems
It was easy enough to add and a valid ordered Python collection.
Given:
Previously this was the only valid MIMO input:
Now all of these are also valid: