Class RoundingUtilsTest
java.lang.Object
ubic.gemma.core.util.RoundingUtilsTest
Unit tests for
RoundingUtils, the JSON-side counterpart of TsvUtils.format(double).- Author:
- paul
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidRounding in place would corrupt the loaded entity's array or the cached matrix's backing store, which is the hazard the sample-correlation rounding was written around.voidvoidvoidvoidvoidMath.round(NaN) is 0.0, which on a mean-variance or correlation payload reads as "this value is zero" rather than "not known".voidvoidThe point of the exercise: four significant digits has to actually shorten the serialized form, or the bytes on the wire do not move.voidvoidvoidThe reason the rule is significant digits and not decimal places: a corrected p-value of 1e-300 has to come back as 1e-300, and any fixed number of decimals flattens it to zero.void
-
Constructor Details
-
RoundingUtilsTest
public RoundingUtilsTest()
-
-
Method Details
-
testAlreadyShorterThanFourDigitsIsUnchanged
@Test public void testAlreadyShorterThanFourDigitsIsUnchanged() -
testZeroKeepsItsSign
@Test public void testZeroKeepsItsSign() -
testNegativeIsRoundedNotTruncated
@Test public void testNegativeIsRoundedNotTruncated() -
testNonFiniteValuesAreLeftAlone
@Test public void testNonFiniteValuesAreLeftAlone()Math.round(NaN) is 0.0, which on a mean-variance or correlation payload reads as "this value is zero" rather than "not known". The infinities have the same hazard in the other direction. -
testVerySmallValuesSurvive
@Test public void testVerySmallValuesSurvive()The reason the rule is significant digits and not decimal places: a corrected p-value of 1e-300 has to come back as 1e-300, and any fixed number of decimals flattens it to zero. -
testLargeValuesKeepTheirMagnitude
@Test public void testLargeValuesKeepTheirMagnitude() -
testRoundedValueSerializesShort
@Test public void testRoundedValueSerializesShort()The point of the exercise: four significant digits has to actually shorten the serialized form, or the bytes on the wire do not move. -
testBoxedOverloadPassesNullThrough
@Test public void testBoxedOverloadPassesNullThrough() -
testArrayIsCopiedNotRoundedInPlace
@Test public void testArrayIsCopiedNotRoundedInPlace()Rounding in place would corrupt the loaded entity's array or the cached matrix's backing store, which is the hazard the sample-correlation rounding was written around. -
testMatrixIsCopiedRowByRow
@Test public void testMatrixIsCopiedRowByRow() -
testNullArraysArePassedThrough
@Test public void testNullArraysArePassedThrough() -
testSerializerEmitsRoundedNumberAndSkipsNull
-
testSerializerLeavesTheInMemoryValueExact
-