Skip to content

Commit cb92d00

Browse files
committed
chore: fix warnings
1 parent f950499 commit cb92d00

50 files changed

Lines changed: 544 additions & 498 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Synthesis.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ clean tdf =
118118

119119
-- | Extract title (e.g. "Mr", "Mrs") from a full Titanic passenger name.
120120
extractTitle :: T.Text -> T.Text
121-
extractTitle name =
122-
case filter (T.isSuffixOf ".") (T.words name) of
121+
extractTitle fullName =
122+
case filter (T.isSuffixOf ".") (T.words fullName) of
123123
(w : _) -> T.dropEnd 1 w
124124
[] -> ""
125125

@@ -133,10 +133,10 @@ computeAccuracy df =
133133
DT.unsafeFreeze @RawPredSchema $
134134
df |> D.select ["Survived", "prediction"]
135135
survived = DT.col @"Survived"
136-
pred = DT.col @"prediction"
136+
predCol = DT.col @"prediction"
137137
count expr = fromIntegral (DT.nRows (DT.filterWhere expr tdf))
138-
tp = count ((survived DT..==. DT.lit 1) DT..&&. (pred DT..==. DT.lit 1))
139-
tn = count ((survived DT..==. DT.lit 0) DT..&&. (pred DT..==. DT.lit 0))
140-
fp = count ((survived DT..==. DT.lit 0) DT..&&. (pred DT..==. DT.lit 1))
141-
fn = count ((survived DT..==. DT.lit 1) DT..&&. (pred DT..==. DT.lit 0))
138+
tp = count ((survived DT..==. DT.lit 1) DT..&&. (predCol DT..==. DT.lit 1))
139+
tn = count ((survived DT..==. DT.lit 0) DT..&&. (predCol DT..==. DT.lit 0))
140+
fp = count ((survived DT..==. DT.lit 0) DT..&&. (predCol DT..==. DT.lit 1))
141+
fn = count ((survived DT..==. DT.lit 1) DT..&&. (predCol DT..==. DT.lit 0))
142142
in (tp + tn) / (tp + tn + fp + fn)

dataframe.cabal

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@ source-repository head
4040
location: https://github.com/mchav/dataframe
4141

4242
common warnings
43-
-- TODO add more warnings, eventually -Wall
4443
ghc-options:
45-
-Wincomplete-patterns
46-
-Wincomplete-uni-patterns
47-
-Wunused-imports
48-
-Wunused-packages
49-
-Wunused-local-binds
44+
-Wall
5045

5146
library
5247
import: warnings

src/DataFrame/DecisionTree.hs

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ identifyCarePoints ::
395395
identifyCarePoints target df indices leftTree rightTree =
396396
case interpret @a df (Col target) of
397397
Left _ -> []
398-
Right (TColumn col) ->
399-
case toVector @a col of
398+
Right (TColumn column) ->
399+
case toVector @a column of
400400
Left _ -> []
401401
Right targetVals ->
402402
V.toList $ V.mapMaybe (checkPoint targetVals) indices
@@ -424,12 +424,12 @@ predictWithTree ::
424424
Int -> -- Row index
425425
Tree a ->
426426
a
427-
predictWithTree target df idx (Leaf v) = v
427+
predictWithTree _target _df _idx (Leaf v) = v
428428
predictWithTree target df idx (Branch cond left right) =
429429
case interpret @Bool df cond of
430430
Left _ -> predictWithTree @a target df idx left -- Default to left on error
431-
Right (TColumn col) ->
432-
case toVector @Bool col of
431+
Right (TColumn column) ->
432+
case toVector @Bool column of
433433
Left _ -> predictWithTree @a target df idx left
434434
Right boolVals ->
435435
if boolVals V.! idx
@@ -440,8 +440,8 @@ countCarePointErrors :: Expr Bool -> DataFrame -> [CarePoint] -> Int
440440
countCarePointErrors cond df carePoints =
441441
case interpret @Bool df cond of
442442
Left _ -> length carePoints
443-
Right (TColumn col) ->
444-
case toVector @Bool col of
443+
Right (TColumn column) ->
444+
case toVector @Bool column of
445445
Left _ -> length carePoints
446446
Right boolVals ->
447447
length $ filter (isMisclassified boolVals) carePoints
@@ -457,8 +457,8 @@ partitionIndices ::
457457
partitionIndices cond df indices =
458458
case interpret @Bool df cond of
459459
Left _ -> (indices, V.empty)
460-
Right (TColumn col) ->
461-
case toVector @Bool col of
460+
Right (TColumn column) ->
461+
case toVector @Bool column of
462462
Left _ -> (indices, V.empty)
463463
Right boolVals ->
464464
V.partition (boolVals V.!) indices
@@ -473,13 +473,13 @@ majorityValueFromIndices ::
473473
majorityValueFromIndices target df indices =
474474
case interpret @a df (Col target) of
475475
Left e -> throw e
476-
Right (TColumn col) ->
477-
case toVector @a col of
476+
Right (TColumn column) ->
477+
case toVector @a column of
478478
Left e -> throw e
479479
Right vals ->
480480
let counts =
481481
V.foldl'
482-
(\acc i -> M.insertWith (+) (vals V.! i) 1 acc)
482+
(\acc i -> M.insertWith (+) (vals V.! i) (1 :: Int) acc)
483483
M.empty
484484
indices
485485
in if M.null counts
@@ -499,8 +499,8 @@ computeTreeLoss target df indices tree
499499
| otherwise =
500500
case interpret @a df (Col target) of
501501
Left _ -> 1.0
502-
Right (TColumn col) ->
503-
case toVector @a col of
502+
Right (TColumn column) ->
503+
case toVector @a column of
504504
Left _ -> 1.0
505505
Right targetVals ->
506506
let
@@ -699,24 +699,26 @@ numericExprsWithTerms cfg df =
699699
numericCols :: DataFrame -> [NumExpr]
700700
numericCols df = concatMap extract (columnNames df)
701701
where
702-
extract col = case unsafeGetColumn col df of
702+
extract colName = case unsafeGetColumn colName df of
703703
UnboxedColumn Nothing (_ :: VU.Vector b) ->
704704
case testEquality (typeRep @b) (typeRep @Double) of
705-
Just Refl -> [NDouble (Col col)]
705+
Just Refl -> [NDouble (Col colName)]
706706
Nothing -> case sIntegral @b of
707-
STrue -> [NDouble (F.toDouble (Col @b col))]
707+
STrue -> [NDouble (F.toDouble (Col @b colName))]
708708
SFalse -> []
709709
BoxedColumn (Just _) (_ :: V.Vector b) ->
710710
case testEquality (typeRep @b) (typeRep @Double) of
711-
Just Refl -> [NMaybeDouble (Col @(Maybe b) col)]
711+
Just Refl -> [NMaybeDouble (Col @(Maybe b) colName)]
712712
Nothing -> case sIntegral @b of
713-
STrue -> [NMaybeDouble (F.whenPresent (realToFrac @b @Double) (Col @(Maybe b) col))]
713+
STrue ->
714+
[NMaybeDouble (F.whenPresent (realToFrac @b @Double) (Col @(Maybe b) colName))]
714715
SFalse -> []
715716
UnboxedColumn (Just _) (_ :: VU.Vector b) ->
716717
case testEquality (typeRep @b) (typeRep @Double) of
717-
Just Refl -> [NMaybeDouble (Col @(Maybe b) col)]
718+
Just Refl -> [NMaybeDouble (Col @(Maybe b) colName)]
718719
Nothing -> case sIntegral @b of
719-
STrue -> [NMaybeDouble (F.whenPresent (realToFrac @b @Double) (Col @(Maybe b) col))]
720+
STrue ->
721+
[NMaybeDouble (F.whenPresent (realToFrac @b @Double) (Col @(Maybe b) colName))]
720722
SFalse -> []
721723
_ -> []
722724

@@ -766,16 +768,18 @@ generateConditionsOld cfg df =
766768
ords = columnOrdering cfg
767769
genConds :: T.Text -> [Expr Bool]
768770
genConds colName = case unsafeGetColumn colName df of
769-
(BoxedColumn Nothing (col :: V.Vector a)) ->
770-
case withOrdFrom @a ords (map (Lit . (`percentileOrd'` col)) [1, 25, 75, 99]) of
771+
(BoxedColumn Nothing (column :: V.Vector a)) ->
772+
case withOrdFrom @a ords (map (Lit . (`percentileOrd'` column)) [1, 25, 75, 99]) of
771773
Just ps -> map (F.lift2 (==) (Col @a colName)) ps
772774
Nothing -> []
773-
(BoxedColumn (Just _) (col :: V.Vector a)) -> case sFloating @a of
775+
(BoxedColumn (Just _) (column :: V.Vector a)) -> case sFloating @a of
774776
STrue -> [] -- handled by numericCols / numericExprs
775777
SFalse -> case sIntegral @a of
776778
STrue -> [] -- handled by numericCols / numericExprs
777779
SFalse ->
778-
case withOrdFrom @a ords (map (Lit . Just . (`percentileOrd'` col)) [1, 25, 75, 99]) of
780+
case withOrdFrom @a
781+
ords
782+
(map (Lit . Just . (`percentileOrd'` column)) [1, 25, 75, 99]) of
779783
Just ps -> map (F.lift2 (==) (Col @(Maybe a) colName)) ps
780784
Nothing -> []
781785
(UnboxedColumn _ (_ :: VU.Vector a)) -> []
@@ -794,7 +798,7 @@ generateConditionsOld cfg df =
794798
]
795799
where
796800
colConds (!l, !r) = case (unsafeGetColumn l df, unsafeGetColumn r df) of
797-
( BoxedColumn Nothing (col1 :: V.Vector a)
801+
( BoxedColumn Nothing (_col1 :: V.Vector a)
798802
, BoxedColumn Nothing (_ :: V.Vector b)
799803
) ->
800804
case testEquality (typeRep @a) (typeRep @b) of
@@ -826,7 +830,7 @@ calculateGini target df =
826830
counts = getCounts @a target df
827831
numClasses = fromIntegral $ M.size counts
828832
probs = map (\c -> (fromIntegral c + 1) / (n + numClasses)) (M.elems counts)
829-
in if n == 0 then 0 else 1 - sum (map (^ 2) probs)
833+
in if n == 0 then 0 else 1 - sum (map (^ (2 :: Int)) probs)
830834

831835
majorityValue :: forall a. (Columnable a, Ord a) => T.Text -> DataFrame -> a
832836
majorityValue target df =
@@ -840,17 +844,17 @@ getCounts ::
840844
getCounts target df =
841845
case interpret @a df (Col target) of
842846
Left e -> throw e
843-
Right (TColumn col) ->
844-
case toVector @a col of
847+
Right (TColumn column) ->
848+
case toVector @a column of
845849
Left e -> throw e
846850
Right vals -> foldl' (\acc x -> M.insertWith (+) x 1 acc) M.empty (V.toList vals)
847851

848852
percentile :: Int -> Expr Double -> DataFrame -> Double
849853
percentile p expr df =
850854
case interpret @Double df expr of
851855
Left _ -> 0
852-
Right (TColumn col) ->
853-
case toVector @Double col of
856+
Right (TColumn column) ->
857+
case toVector @Double column of
854858
Left _ -> 0
855859
Right vals ->
856860
let sorted = V.fromList $ sort $ V.toList vals
@@ -898,13 +902,13 @@ probsFromIndices ::
898902
probsFromIndices target df indices =
899903
case interpret @a df (Col target) of
900904
Left _ -> M.empty
901-
Right (TColumn col) ->
902-
case toVector @a col of
905+
Right (TColumn column) ->
906+
case toVector @a column of
903907
Left _ -> M.empty
904908
Right vals ->
905909
let counts =
906910
V.foldl'
907-
(\acc i -> M.insertWith (+) (vals V.! i) 1 acc)
911+
(\acc i -> M.insertWith (+) (vals V.! i) (1 :: Int) acc)
908912
M.empty
909913
indices
910914
total = fromIntegral (V.length indices) :: Double

src/DataFrame/Display/Terminal/Plot.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,16 @@ plotCorrelationMatrix df = do
171171
numericCols
172172
)
173173
numericCols
174-
print (zip [0 ..] numericCols)
174+
print (zip [(0 :: Int) ..] numericCols)
175175
T.putStrLn $ heatmap correlations (defPlot{plotTitle = "Correlation Matrix"})
176176
where
177177
correlation xs ys =
178178
let n = fromIntegral $ length xs
179179
meanX = sum xs / n
180180
meanY = sum ys / n
181181
covXY = sum [(x - meanX) * (y - meanY) | (x, y) <- zip xs ys] / n
182-
stdX = sqrt $ sum [(x - meanX) ^ 2 | x <- xs] / n
183-
stdY = sqrt $ sum [(y - meanY) ^ 2 | y <- ys] / n
182+
stdX = sqrt $ sum [(x - meanX) ^ (2 :: Int) | x <- xs] / n
183+
stdY = sqrt $ sum [(y - meanY) ^ (2 :: Int) | y <- ys] / n
184184
in covXY / (stdX * stdY)
185185

186186
plotBars :: (HasCallStack) => T.Text -> DataFrame -> IO ()
@@ -254,7 +254,7 @@ plotGroupedBarsWithN n groupCol valCol config df = do
254254
M.toList $
255255
M.fromListWith
256256
(+)
257-
[(g <> " - " <> v, 1) | (g, v) <- pairs]
257+
[(g <> " - " <> v, 1 :: Int) | (g, v) <- pairs]
258258
finalCounts = groupWithOther n [(k, fromIntegral v) | (k, v) <- counts]
259259
T.putStrLn $ bars finalCounts (plotSettings config)
260260

@@ -388,7 +388,7 @@ getCategoricalCounts colName df =
388388
countByShow xs =
389389
map (Data.Bifunctor.bimap T.pack fromIntegral) $
390390
M.toList $
391-
L.foldl' (\acc x -> M.insertWith (+) (show x) 1 acc) M.empty xs
391+
L.foldl' (\acc x -> M.insertWith (+) (show x) (1 :: Int) acc) M.empty xs
392392

393393
isNumericColumnCheck :: T.Text -> DataFrame -> Bool
394394
isNumericColumnCheck colName df = isNumericColumn df colName
@@ -579,7 +579,7 @@ plotPieGroupedWith groupCol valCol config df = do
579579
let groups = extractStringColumn groupCol df
580580
vals = extractStringColumn valCol df
581581
combined = zipWith (\g v -> g <> " - " <> v) groups vals
582-
counts = M.toList $ M.fromListWith (+) [(c, 1) | c <- combined]
582+
counts = M.toList $ M.fromListWith (+) [(c, 1 :: Int) | c <- combined]
583583
finalCounts = groupWithOtherForPie 10 [(k, fromIntegral v) | (k, v) <- counts]
584584
T.putStrLn $ pie finalCounts (plotSettings config)
585585

src/DataFrame/Display/Terminal/PrettyPrint.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ showTable properMarkdown header types rows =
6262
separator = T.intercalate "-|-" [T.replicate width (T.singleton '-') | width <- widths]
6363
fillCols fill cols =
6464
T.intercalate " | " [fill c width col | (c, width, col) <- zip3 cs widths cols]
65-
lines =
65+
outputLines =
6666
if properMarkdown
6767
then
6868
T.concat ["| ", fillCols colTitleFill consolidatedHeader, " |"]
@@ -75,4 +75,4 @@ showTable properMarkdown header types rows =
7575
: fillCols colTitleFill types
7676
: separator
7777
: map (fillCols colValueFill) rows
78-
in T.unlines lines
78+
in T.unlines outputLines

src/DataFrame/Display/Web/Plot.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ plotSingleBars colName config df = do
447447
let values = extractNumericColumn colName df
448448
labels' =
449449
if length values > 20
450-
then take 20 ["Item " <> T.pack (show i) | i <- [1 ..]]
450+
then take 20 ["Item " <> T.pack (show i) | i <- [(1 :: Int) ..]]
451451
else ["Item " <> T.pack (show i) | i <- [1 .. length values]]
452452
vals = if length values > 20 then take 20 values else values
453453
labels = T.intercalate "," ["\"" <> label <> "\"" | label <- labels']
@@ -794,7 +794,7 @@ plotGroupedBarsWithN n groupCol valCol config df = do
794794
M.toList $
795795
M.fromListWith
796796
(+)
797-
[(g <> " - " <> v, 1) | (g, v) <- pairs]
797+
[(g <> " - " <> v, 1 :: Int) | (g, v) <- pairs]
798798
finalCounts = groupWithOther n [(k, fromIntegral v) | (k, v) <- counts]
799799
labels = T.intercalate "," ["\"" <> label <> "\"" | (label, _) <- finalCounts]
800800
dataPoints = T.intercalate "," [T.pack (show val) | (_, val) <- finalCounts]
@@ -946,7 +946,7 @@ getCategoricalCounts colName df =
946946
countByShow xs =
947947
map (Data.Bifunctor.bimap T.pack fromIntegral) $
948948
M.toList $
949-
L.foldl' (\acc x -> M.insertWith (+) (show x) 1 acc) M.empty xs
949+
L.foldl' (\acc x -> M.insertWith (+) (show x) (1 :: Int) acc) M.empty xs
950950

951951
groupWithOther :: Int -> [(T.Text, Double)] -> [(T.Text, Double)]
952952
groupWithOther n items =

src/DataFrame/Errors.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ columnsNotFound missingColumns callPoint availableColumns =
108108
++ "]"
109109

110110
typeMismatchError :: String -> String -> String
111-
typeMismatchError givenType expectedType =
111+
typeMismatchError givenType expType =
112112
red $
113113
red "\n\n[Error]: Type Mismatch"
114114
++ "\n\tWhile running your code I tried to "
115115
++ "get a column of type: "
116116
++ red (show givenType)
117117
++ " but the column in the dataframe was actually of type: "
118-
++ green (show expectedType)
118+
++ green (show expType)
119119

120120
emptyDataSetError :: T.Text -> String
121121
emptyDataSetError callPoint =

0 commit comments

Comments
 (0)