Skip to content

Commit

Permalink
doctests fixed (dimension-first bugz)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyday567 committed Aug 20, 2024
1 parent ac87e93 commit a7ea148
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/NumHask/Array/Dynamic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,6 @@ drops ts a = backpermute dsNew (List.zipWith (\d' s' -> bool (d' + s') s' (d' <

-- | Select by (dimension,index) pairs.
--
-- >>> 1
-- Dynamic
-- >>> let s = indexes [(0,1),(1,1)] a
-- >>> pretty s
-- [16,17,18,19]
Expand All @@ -905,7 +903,7 @@ indexes ::
Array a
indexes ps a = backpermute (S.deleteDims ds) (S.insertDims ps) a
where
ds = fmap snd ps
ds = fmap fst ps

-- | Select the first element along the supplied dimensions
--
Expand Down
4 changes: 0 additions & 4 deletions src/NumHask/Array/Fixed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,6 @@ indexes _ xs a = unsafeBackpermute (S.insertDims (List.zip (shapeOf @ds) xs)) a

-- | Select an index /except/ along specified dimensions.
--
-- >>> 1
-- Fixed indexesExcept
-- >>> let s = indexesExcept (Proxy :: Proxy '[2]) [1,1] a
-- >>> :t s
-- s :: Array '[4] Int
Expand Down Expand Up @@ -1046,8 +1044,6 @@ traverses ds f a = joins ds <$> traverse (traverse f) (extracts ds a)

-- | Join inner and outer dimension layers by supplied dimensions. No checks on shape.
--
-- >>> 1
-- fixed joins
-- >>> let e = extracts (Proxy :: Proxy [1,0]) a
-- >>> let j = joins (Proxy :: Proxy [1,0]) e
-- >>> a == j
Expand Down
4 changes: 3 additions & 1 deletion src/NumHask/Array/Shape.hs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ type instance Eval (Foldl' f y (x ': xs)) = Eval (Foldl' f (Eval (f y x)) xs)
-- >>> insertDims [(1,3), (0,2)] [4]
-- [2,3,4]
insertDims :: [(Int,Int)] -> [Int] -> [Int]
insertDims ps ds = foldr (uncurry insertDim) ds ps
insertDims ps ds = foldl' (flip (uncurry insertDim)) ds ps'
where
ps' = zip (preInsertPositions $ fmap fst ps) (fmap snd ps)

type family InsertDims (xs :: [Nat]) (ys :: [Nat]) (as :: [Nat]) where
InsertDims xs ys as = InsertDimsGo (Eval (Reverse (Eval (PreDeletePositions (Eval (Reverse xs)))))) ys as
Expand Down

0 comments on commit a7ea148

Please sign in to comment.