File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff line change @@ -77,17 +77,19 @@ shuffle pureGen df =
7777 df{columns = V. map (atIndicesStable indexes) (columns df)}
7878
7979shuffledIndices :: (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
You can’t perform that action at this time.
0 commit comments