[MINOR] Add ToString test for decimal-formatting in toString builtin#2503
Merged
Conversation
Adds five new test cases that exercise toString(X, rows=, cols=,
decimal=) with values that hit common formatting edge cases:
integer-valued scalars, mid-range decimals, requested decimals
beyond the value's precision, rounding at the last requested digit,
and small near-zero values.
- New DML script ToString12.dml driving toString with parameterized
value and decimal-count
- New testPrintWithDecimal{1..5} cases and a toStringTestHelper2
helper in ToStringTest
DecimalFormat defaults maximumFractionDigits to 3, and toString only set the minimum, so decimal=2 on 5.244058 printed "5.244" (3 digits) instead of "5.24". Set the maximum fraction digits alongside the minimum in the matrix, tensor, and frame toString paths so decimal=N produces exactly N decimals. This makes testPrintWithDecimal2 pass.
The matrix, tensor, and frame toString paths each built an identical non-grouping DecimalFormat and pinned min/max fraction digits to the requested decimal count. Consolidate that into a single private helper so the exact-fraction-digit configuration lives in one place.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2503 +/- ##
============================================
+ Coverage 71.37% 71.54% +0.16%
- Complexity 48749 48959 +210
============================================
Files 1571 1573 +2
Lines 188912 189331 +419
Branches 37067 37147 +80
============================================
+ Hits 134845 135461 +616
+ Misses 43601 43388 -213
- Partials 10466 10482 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The decimal-formatting path was only exercised for matrices. Add direct frame and tensor toString tests that print FP64 values needing clamping (decimal=2 on 5.244058 -> 5.24), padding (22 -> 22.0000) and rounding (-> 5.2441), covering the frame and tensor formatting paths and guarding the exact-fraction-digit behavior.
Cover the decimal < 0 path in DataConverter.createDecimalFormat, where DecimalFormat is left unconstrained (no min/max fraction digits). The new frame and tensor cases assert integer values are unpadded and fractional values keep the default three-digit cap, closing the partial-coverage branch in the shared helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds five new test cases that exercise toString(X, rows=, cols=, decimal=) with values that hit common formatting edge cases: integer-valued scalars, mid-range decimals, requested decimals beyond the value's precision, rounding at the last requested digit, and small near-zero values.