packages feed

linear-tests 0.1.1.0 → 0.1.2.0

raw patch · 9 files changed

+40/−12 lines, 9 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Linear.V3.Arbitrary: NonZeroV3 :: V3 a -> NonZeroV3 a
+ Linear.V3.Arbitrary: [unNonZeroV3] :: NonZeroV3 a -> V3 a
+ Linear.V3.Arbitrary: instance (Test.QuickCheck.Arbitrary.Arbitrary a, Linear.Epsilon.Epsilon a, GHC.Float.Floating a) => Test.QuickCheck.Arbitrary.Arbitrary (Linear.V3.Arbitrary.NonZeroV3 a)
+ Linear.V3.Arbitrary: instance GHC.Show.Show a => GHC.Show.Show (Linear.V3.Arbitrary.NonZeroV3 a)
+ Linear.V3.Arbitrary: newtype NonZeroV3 a
+ Linear.V4.Arbitrary: NonZeroV4 :: V4 a -> NonZeroV4 a
+ Linear.V4.Arbitrary: [unNonZeroV4] :: NonZeroV4 a -> V4 a
+ Linear.V4.Arbitrary: instance (Test.QuickCheck.Arbitrary.Arbitrary a, Linear.Epsilon.Epsilon a, GHC.Float.Floating a) => Test.QuickCheck.Arbitrary.Arbitrary (Linear.V4.Arbitrary.NonZeroV4 a)
+ Linear.V4.Arbitrary: instance GHC.Show.Show a => GHC.Show.Show (Linear.V4.Arbitrary.NonZeroV4 a)
+ Linear.V4.Arbitrary: newtype NonZeroV4 a

Files

ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for linear-tests +## 0.1.2 [2020.03.27]+- Added `NonZeroV3` and `NonZeroV4`+ ## 0.1.1 [2020.02.16] - Added `InvertibleM33` - Added `BasisV3`
README.md view
@@ -1,8 +1,6 @@-[![CircleCI](https://circleci.com/gh/pdlla/linear-tests.svg?style=svg)](https://circleci.com/gh/pdlla/linear-tests)- # linear-tests This library provides [QuickCheck](https://hackage.haskell.org/package/QuickCheck) `Arbitrary` instances of data types in the [linear](http://hackage.haskell.org/package/linear) package.  The property tests in this package test both the newly defined `Arbitrary` instances as well as methods in the linear package itself. It's hard to distinguish between the two types of test so they are all just lumped together. -The current instances are just ones I (and hopefully others) find useful. Feel free to add your own and submit a PR. +The current instances are just ones I (and hopefully others) find useful. Feel free to add your own and submit a PR.
linear-tests.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 7d0fbb63b1f76fdccf74b6a953e18091d9a95568447c823ca6244cc4a413b720+-- hash: a47f9bb7aa67c051f663274d346bb9eccfcd437b97b8bf43dc8420896c5c4b20  name:           linear-tests-version:        0.1.1.0+version:        0.1.2.0 synopsis:       Linear Algebra description:    Please see the README on GitHub at <https://github.com/pdlla/linear-tests#readme> category:       Math, Algebra, Testing
src/Linear/Matrix/Arbitrary.hs view
@@ -12,7 +12,6 @@  import           Linear.Epsilon import           Linear.Matrix-import           Linear.Metric import qualified Linear.V3           as V3 import qualified Linear.V4           as V4 import           Test.QuickCheck
src/Linear/V3/Arbitrary.hs view
@@ -2,16 +2,13 @@  module Linear.V3.Arbitrary (   UnitV3(..)+  , NonZeroV3(..)   , CartesianUnitV3(..)   , BasisV3(..) ) where -import           Control.Lens      hiding (elements)--import           Linear.Conjugate import           Linear.Epsilon import           Linear.Metric-import qualified Linear.Quaternion as Q import           Linear.V3 import           Linear.Vector @@ -20,6 +17,14 @@ -- | `Arbitrary V3` has no restrictions on components instance (Arbitrary a) => Arbitrary (V3 a) where   arbitrary = V3 <$> arbitrary <*> arbitrary <*> arbitrary++-- | `Arbitrary NonZero` is never the zero vector+newtype NonZeroV3 a = NonZeroV3 {unNonZeroV3 :: V3 a} deriving (Show)++instance (Arbitrary a, Epsilon a, Floating a) => Arbitrary (NonZeroV3 a) where+  arbitrary = do+    v <- arbitrary `suchThat` (not . nearZero)+    return $ NonZeroV3 v  -- | `Arbitrary UnitV3` always has norm 1 newtype UnitV3 a = UnitV3 {unUnitV3 :: V3 a}  deriving (Show)
src/Linear/V4/Arbitrary.hs view
@@ -2,6 +2,7 @@  module Linear.V4.Arbitrary (   UnitV4(..)+  , NonZeroV4(..) ) where  import           Linear.Epsilon@@ -13,6 +14,14 @@ -- | `Arbitrary V4` has no restrictions on components instance (Arbitrary a) => Arbitrary (V4 a) where   arbitrary = V4 <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary++-- | `Arbitrary NonZero` is never the zero vector+newtype NonZeroV4 a = NonZeroV4 {unNonZeroV4 :: V4 a} deriving (Show)++instance (Arbitrary a, Epsilon a, Floating a) => Arbitrary (NonZeroV4 a) where+  arbitrary = do+    v <- arbitrary `suchThat` (not . nearZero)+    return $ NonZeroV4 v  -- | `Arbitrary UnitV4` always has norm 1 newtype UnitV4 a = UnitV4 {unUnitV4 :: V4 a}  deriving (Show)
test/Linear/QuaternionSpec.hs view
@@ -33,8 +33,8 @@ prop_Quaternion_conjugate :: (Epsilon a, RealFloat a, Conjugate a) => Q.Quaternion a -> Bool prop_Quaternion_conjugate q = nearZero $ distance (q * conjugate q) (Q.Quaternion 1 (V.V3 0 0 0)) -identityQuaternion :: (RealFloat a) => Q.Quaternion a-identityQuaternion = 1 -- Quaternion 1 (V3 0 0 0)+--identityQuaternion :: (RealFloat a) => Q.Quaternion a+--identityQuaternion = 1 -- Quaternion 1 (V3 0 0 0)  spec :: Spec spec = specTyped @Double
test/Linear/V3Spec.hs view
@@ -17,6 +17,10 @@  import           Linear.V3.Arbitrary +-- | test for the property `|v| != 0`+prop_NonZeroV3_isNonZero :: (Epsilon a, Floating a) => NonZeroV3 a -> Bool+prop_NonZeroV3_isNonZero (NonZeroV3 v) = not . nearZero $ norm v+ -- | test for the property `|v| = 1` prop_UnitV3_isUnit :: (Epsilon a, Floating a) => UnitV3 a -> Bool prop_UnitV3_isUnit (UnitV3 v) = nearZero $ norm v - 1@@ -53,6 +57,9 @@ specTyped = do   describe "V3" $ do     describe "Arbitrary" $ do+      describe "NonZeroV3" $ do+        it "satisfies the property `|v| != 0`" $ do+          property $ prop_NonZeroV3_isNonZero @a       describe "UnitV3" $ do         it "satisfies the property `|v| = 1`" $ do           property $ prop_UnitV3_isUnit @a
test/Linear/V4Spec.hs view
@@ -17,6 +17,10 @@ import           Linear.V4.Arbitrary  +-- | test for the property `|v| != 0`+prop_NonZeroV4_isNonZero :: (Epsilon a, Floating a) => NonZeroV4 a -> Bool+prop_NonZeroV4_isNonZero (NonZeroV4 v) = not . nearZero $ norm v+ -- | test for the property `|v| = 1` prop_UnitV4_isUnit :: (Epsilon a, Floating a) => UnitV4 a -> Bool prop_UnitV4_isUnit (UnitV4 v) = nearZero $ norm v - 1@@ -28,6 +32,9 @@ specTyped = do   describe "V4" $ do     describe "Arbitrary" $ do+      describe "NonZeroV4" $ do+        it "satisfies the property `|v| != 0`" $ do+          property $ prop_NonZeroV4_isNonZero @a       describe "UnitV4" $ do         it "satisfies the property `|v| = 1`" $ do           property $ prop_UnitV4_isUnit @a