Skip to content

Commit 3e69bd5

Browse files
committed
Clean up build warnings
Issue 170, implement PR comments and clean up build warnings
1 parent 7eaf4e7 commit 3e69bd5

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

dataframe.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ library
106106
process ^>= 1.6,
107107
snappy-hs ^>= 0.1,
108108
random >= 1.2 && < 1.3,
109-
random-shuffle >= 0.0.4 && < 1,
110109
regex-tdfa >= 1.3.0 && < 2,
111110
scientific >=0.3.1 && <0.4,
112111
template-haskell >= 2.0 && < 3,

src/DataFrame/Operations/Permutation.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ shuffle pureGen df =
7777
df{columns = V.map (atIndicesStable indexes) (columns df)}
7878

7979
shuffledIndices :: (RandomGen g) => g -> Int -> VU.Vector Int
80-
shuffledIndices pureGen k = shuffleVec pureGen (VU.fromList [0 .. (k - 1)])
80+
shuffledIndices pureGen k
81+
| k <= 0 = VU.empty
82+
| otherwise = shuffleVec pureGen
8183
where
82-
shuffleVec :: (RandomGen g) => g -> VU.Vector Int -> VU.Vector Int
83-
shuffleVec g v = runST $ do
84-
vm <- VU.thaw v
85-
let (n, nGen) = randomR (0, (k - 1)) g
84+
shuffleVec :: (RandomGen g) => g -> VU.Vector Int
85+
shuffleVec g = runST $ do
86+
vm <- VUM.generate k id
87+
let (n, nGen) = randomR (1, (k - 1)) g
8688
go vm n nGen
8789
VU.unsafeFreeze vm
8890

8991
go v (-1) _ = pure ()
9092
go v 0 _ = pure ()
9193
go v maxInd gen =
92-
let (n, nextGen) = randomR (0, maxInd) gen
94+
let (n, nextGen) = randomR (1, maxInd) gen
9395
in VUM.swap v 0 n *> go (VUM.tail v) (maxInd - 1) nextGen

0 commit comments

Comments
 (0)