Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update round(::Missing) to match float version (#30971)
* Update round(::Missing) to match float version `round()` was updated to accept `digits` and `base` as keyword arguments. It looks like the `Missing` version was... missed? 😈 This prevents e.g. `round(A, digits=4)` and `round(A, 4)` (old signature) from working on `Union{Missing, Float64}` arrays `A`. * Fix tests for updated round(::Missing, ...) * Test elementwise rounding on Union{T, Missing}[...] When the signature of `Base.round()` and friends (ceil,floor,trunc) was changed to accept keyword arguments for `digits` and `base` instead of positional arguments, the implementations for `Missing` were missed. Test these functions elementwise on arrays of Floats and Missing values to make sure their signatures are compatible with the versions for numbers. * Only accept Integer base in rounding * Cover missing Missing variants of round() etc. Accept `sigdigits` keyword argument in addition to `digits` and `base`. Also accept `RoundingMode` positional argument. * More variants for round(::Missing) tests Test that there are Missing versions of remaining variants of round() and friends. * Remove extraneous kwargs from trunc,floor,ceil * Clean up trunc,floor,ceil defs for Missing Continue to call `round()`, despite it just returning `missing`, so that errors happen with kwargs or types that are invalid. * Pass RoundingMode to round() in Missing versions * Check RoundingMode is being passed on for Missing * Use isequal and === * Test round() with sigdigits on missing-value arrays Also, separate tests for digits and sigdigits: Combining these arguments is not valid for floats, although it currently goes through for Missing. Finally, use a sensible base for the digits and sigdigits tests. * Fix new round() ambiguities with Missing and Rational * Reduce Rational pollution of round() methods The specification to `RoundingMode`s made it difficult to define `round()` for `Missing`. * Remove now-unneeded Missing,Rational methods * Simplify Missing rounding tests Remove duplicate tests but still test elementwise to help ensure we stay in sync with Float methods in the future. Add some comments to explain what is going on. * Remove redundant rounded_array `isequal(test_array, rounded_array) == true`, so just use `test_array`. * Remove Missing, Rational specializations My (possibly incomplete) tests suggest these are no longer needed. * Restore Rational, Missing rounding functions Still needed these to avoid ambiguities after all.
- Loading branch information