Skip to content

Commit 8689f54

Browse files
committed
Update features tests and docs.
1 parent 6d38305 commit 8689f54

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

src/ArrayFire/Features.hs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import ArrayFire.FFI
2222
import ArrayFire.Exception
2323

2424
-- | Construct 'Features'
25+
--
26+
-- >>> features = createFeatures (createFeatures 10)
27+
--
2528
createFeatures
2629
:: Int
2730
-> Features
@@ -35,42 +38,81 @@ createFeatures (fromIntegral -> n) =
3538
pure (Features fptr)
3639

3740
-- | Retain 'Features'
41+
--
42+
-- >>> features = retainFeatures (createFeatures 10)
43+
--
3844
retainFeatures
3945
:: Features
4046
-> Features
4147
retainFeatures = (`op1f` af_retain_features)
4248

4349
-- | Get number of 'Feature's
50+
--
51+
-- link
52+
--
53+
-- >>> getFeaturesNum (createFeatures 10)
54+
-- 10
55+
--
4456
getFeaturesNum
4557
:: Features
4658
-> Int
4759
getFeaturesNum = fromIntegral . (`infoFromFeatures` af_get_features_num)
4860

4961
-- | Get 'Feature' X-position
62+
--
63+
-- >>> getFeaturesXPos (createFeatures 10)
64+
-- ArrayFire Array
65+
-- [10 1 1 1]
66+
-- 0.0000 0.0000 0.0000 0.0000 0.0000 2.1250 0.0000 2.2500 0.0000 0.0000
67+
--
5068
getFeaturesXPos
5169
:: Features
5270
-> Array a
5371
getFeaturesXPos = (`featuresToArray` af_get_features_xpos)
5472

5573
-- | Get 'Feature' Y-position
74+
--
75+
-- >>> getFeaturesYPos (createFeatures 10)
76+
-- ArrayFire Array
77+
-- [10 1 1 1]
78+
-- 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
79+
--
5680
getFeaturesYPos
5781
:: Features
5882
-> Array a
5983
getFeaturesYPos = (`featuresToArray` af_get_features_ypos)
6084

6185
-- | Get 'Feature' Score
86+
--
87+
-- >>> getFeaturesScore (createFeatures 10)
88+
-- ArrayFire Array
89+
-- [10 1 1 1]
90+
-- 0.0000 1.8750 0.0000 2.0000 0.0000 2.1250 0.0000 2.2500 nan nan
91+
--
6292
getFeaturesScore
6393
:: Features
6494
-> Array a
6595
getFeaturesScore = (`featuresToArray` af_get_features_score)
6696

6797
-- | Get 'Feature' orientation
98+
--
99+
-- >>> getFeaturesOrientation (createFeatures 10)
100+
-- ArrayFire Array
101+
-- [10 1 1 1]
102+
-- 0.0000 1.8750 0.0000 2.0000 0.0000 2.1250 0.0000 2.2500 0.0000 0.0000
103+
--
68104
getFeaturesOrientation
69105
:: Features
70106
-> Array a
71107
getFeaturesOrientation = (`featuresToArray` af_get_features_orientation)
72108

73109
-- | Get 'Feature' size
110+
--
111+
-- >>> getFeaturesSize (createFeatures 10)
112+
-- ArrayFire Array
113+
-- [10 1 1 1]
114+
-- nan nan nan nan nan nan nan nan nan nan
115+
--
74116
getFeaturesSize
75117
:: Features
76118
-> Array a

test/ArrayFire/FeaturesSpec.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,3 @@ spec =
1111
it "Should get features number an array" $ do
1212
let feats = createFeatures 10
1313
getFeaturesNum feats `shouldBe` 10
14-
-- let vec = vector @Double 10 $ repeat (acos 2)
15-
-- getFeaturesSize feats `shouldBe` vec
16-
-- getFeaturesOrientation feats `shouldBe` vec
17-
-- getFeaturesXPos feats `shouldBe` vec
18-
-- getFeaturesYPos feats `shouldBe` vec

test/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ main = do
3232
-- checks (Proxy :: Proxy (A.Array A.Word8))
3333
-- checks (Proxy :: Proxy (A.Array A.Word16))
3434
-- checks (Proxy :: Proxy (A.Array A.Word32))
35-
lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Double))
35+
-- lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Double))
3636
-- lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Float))
37-
-- hspec spec
37+
hspec spec
3838

3939
checks proxy = do
4040
lawsCheck (numLaws proxy)

0 commit comments

Comments
 (0)