Commit f0d88dd
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.1 parent 52bafeb commit f0d88dd
3 files changed
+33
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
111 | 121 | | |
112 | | - | |
| 122 | + | |
113 | 123 | | |
114 | 124 | | |
115 | 125 | | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
119 | | - | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
371 | 372 | | |
372 | | - | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
388 | | - | |
389 | | - | |
| 387 | + | |
390 | 388 | | |
391 | 389 | | |
392 | 390 | | |
| |||
400 | 398 | | |
401 | 399 | | |
402 | 400 | | |
403 | | - | |
| 401 | + | |
404 | 402 | | |
405 | 403 | | |
406 | 404 | | |
| |||
414 | 412 | | |
415 | 413 | | |
416 | 414 | | |
417 | | - | |
| 415 | + | |
418 | 416 | | |
419 | 417 | | |
420 | 418 | | |
421 | 419 | | |
422 | 420 | | |
423 | 421 | | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | 422 | | |
430 | 423 | | |
431 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
193 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
194 | 204 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
| |||
0 commit comments