testing-tensor-0.1.0: Pure implementation of tensors, for use in tests.
Safe HaskellSafe-Inferred
LanguageGHC2021

Test.Tensor.TestValue

Description

Test values

Intended for unqualified import.

Synopsis

Documentation

data TestValue Source #

Test values

Test values are suitable for use in QuickCheck tests involving floating point numbers, if you want to ignore rounding errors.

Instances

Instances details
Arbitrary TestValue Source #

Arbitrary instance

The definition of arbitrary simply piggy-backs on the definition for Float, but in shrinking we avoid generating nearly equal values, and prefer values closer to integral values. Compare:

   shrink @TestValue 100.1
== [0,50,75,88,94,97]

versus

   shrink @Float 100.1
== [100.0,0.0,50.0,75.0,88.0,94.0,97.0,99.0,0.0,50.1,75.1,87.6,93.9,97.0,98.6,99.4,99.8,100.0]
Instance details

Defined in Test.Tensor.TestValue

Num TestValue Source # 
Instance details

Defined in Test.Tensor.TestValue

Fractional TestValue Source # 
Instance details

Defined in Test.Tensor.TestValue

Real TestValue Source # 
Instance details

Defined in Test.Tensor.TestValue

Show TestValue Source #

Show instance

We have more precision available for smaller values, so we show more decimals. However, larger values the show instance does not reflect the precision: 1000 and 1001 are shown as 1000 and 1001, even though they are considered to be equal.

show @TestValue 0     == "0"     -- True zero
show @TestValue 1     == "1"     -- True one
show @TestValue 0.001 == "0.00"
show @TestValue 0.009 == "0.01"
show @TestValue 1.001 == "1.0"
show @TestValue 11    == "11"
Instance details

Defined in Test.Tensor.TestValue

Eq TestValue Source #

Test values are equipped with a crude equality

              (==)
--------------------
1.0    1.1    False
1.00   1.01   True
10     11     False
10.0   10.1   True
100    110    False
100    101    True
Instance details

Defined in Test.Tensor.TestValue

Ord TestValue Source # 
Instance details

Defined in Test.Tensor.TestValue

Random TestValue Source # 
Instance details

Defined in Test.Tensor.TestValue

Methods

randomR :: RandomGen g => (TestValue, TestValue) -> g -> (TestValue, g) #

random :: RandomGen g => g -> (TestValue, g) #

randomRs :: RandomGen g => (TestValue, TestValue) -> g -> [TestValue] #

randoms :: RandomGen g => g -> [TestValue] #