dataframe 0.2.0.0 → 0.2.0.1
raw patch · 8 files changed
+48/−62 lines, 8 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- DataFrame: [Cons] :: forall x (xs1 :: [Type]). Typeable x => TypeRep x -> TypeRepList xs1 -> TypeRepList (x ': xs1)
- DataFrame: [Nil] :: TypeRepList ('[] :: [Type])
- DataFrame: data TypeRepList (xs :: [Type])
- DataFrame: matchesAnyType :: forall a (xs :: [Type]). Typeable a => TypeRepList xs -> TypeRep a -> Bool
- DataFrame: numericTypes :: TypeRepList '[Int, Int8, Int16, Int32, Int64, Double, Float]
- DataFrame: testNumeric :: Typeable a => TypeRep a -> Bool
- DataFrame: testUnboxable :: Typeable a => TypeRep a -> Bool
- DataFrame: unboxableTypes :: TypeRepList '[Int, Int8, Int16, Int32, Int64, Word, Word8, Word16, Word32, Word64, Char, Double, Float, Bool]
Files
- CHANGELOG.md +4/−0
- dataframe.cabal +6/−6
- src/DataFrame/Internal/DataFrame.hs +3/−0
- src/DataFrame/Internal/Expression.hs +2/−2
- src/DataFrame/Internal/Row.hs +31/−0
- src/DataFrame/Internal/Types.hs +0/−50
- src/DataFrame/Operations/Subset.hs +1/−2
- src/DataFrame/Operations/Transformations.hs +1/−2
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for dataframe +## 0.2.0.1+* Fix bug with new comparison expressions. gt and geq were actually implemented as lt and leq.+* Changes to make library work with ghc 9.10.1 and 9.12.2+ ## 0.2.0.0 ### Replace `Function` adt with a column expression syntax.
dataframe.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: dataframe-version: 0.2.0.0+version: 0.2.0.1 synopsis: An intuitive, dynamically-typed DataFrame library. @@ -14,7 +14,7 @@ copyright: (c) 2024-2024 Michael Chavinda category: Data-tested-with: GHC ==9.8.3 || ==9.6.6 || == 9.4.8+tested-with: GHC ==9.8.3 || ==9.6.6 || == 9.4.8 || ==9.10.1 || ==9.12.1 || ==9.12.2 extra-doc-files: CHANGELOG.md README.md source-repository head@@ -41,7 +41,7 @@ DataFrame.Operations.Aggregation, DataFrame.Display.Terminal.Plot, DataFrame.IO.CSV- build-depends: base >= 4.17.2.0 && < 4.21,+ build-depends: base >= 4.17.2.0 && < 4.22, array ^>= 0.5, attoparsec >= 0.12 && <= 0.14.4, bytestring >= 0.11 && <= 0.12.2.0,@@ -77,7 +77,7 @@ DataFrame.Operations.Aggregation, DataFrame.Display.Terminal.Plot, DataFrame.IO.CSV- build-depends: base >= 4.17.2.0 && < 4.21,+ build-depends: base >= 4.17.2.0 && < 4.22, array ^>= 0.5, attoparsec >= 0.12 && <= 0.14.4, bytestring >= 0.11 && <= 0.12.2.0,@@ -97,7 +97,7 @@ type: exitcode-stdio-1.0 main-is: Main.hs hs-source-dirs: benchmark- build-depends: base >= 4.17.2.0 && < 4.21,+ build-depends: base >= 4.17.2.0 && < 4.22, criterion >= 1 && <= 1.6.4.0, text >= 2.0 && <= 2.1.2, random >= 1 && <= 1.3.1,@@ -116,7 +116,7 @@ Operations.InsertColumn, Operations.Sort, Operations.Take- build-depends: base >= 4.17.2.0 && < 4.21,+ build-depends: base >= 4.17.2.0 && < 4.22, HUnit ^>= 1.6, random >= 1, random-shuffle >= 0.0.4,
src/DataFrame/Internal/DataFrame.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE StrictData #-}+{-# LANGUAGE FlexibleContexts #-} module DataFrame.Internal.DataFrame where import qualified Data.Map as M@@ -45,6 +46,7 @@ asText d properMarkdown = let header = "index" : map fst (sortBy (compare `on` snd) $ M.toList (columnIndices d)) types = V.toList $ V.filter (/= "") $ V.map getType (columns d)+ getType :: Maybe Column -> T.Text getType Nothing = "" getType (Just (BoxedColumn (column :: V.Vector a))) = T.pack $ show (typeRep @a) getType (Just (UnboxedColumn (column :: VU.Vector a))) = T.pack $ show (typeRep @a)@@ -53,6 +55,7 @@ getType (Just (GroupedUnboxedColumn (column :: V.Vector a))) = T.pack $ show (typeRep @a) -- Separate out cases dynamically so we don't end up making round trip string -- copies.+ get :: Maybe Column -> V.Vector T.Text get (Just (BoxedColumn (column :: V.Vector a))) = case testEquality (typeRep @a) (typeRep @T.Text) of Just Refl -> column Nothing -> case testEquality (typeRep @a) (typeRep @String) of
src/DataFrame/Internal/Expression.hs view
@@ -126,10 +126,10 @@ lt = BinOp "lt" (<) gt :: (Columnable a, Ord a) => Expr a -> Expr a -> Expr Bool-gt = BinOp "gt" (<)+gt = BinOp "gt" (>) leq :: (Columnable a, Ord a, Eq a) => Expr a -> Expr a -> Expr Bool leq = BinOp "leq" (<=) geq :: (Columnable a, Ord a, Eq a) => Expr a -> Expr a -> Expr Bool-geq = BinOp "geq" (<=)+geq = BinOp "geq" (>=)
src/DataFrame/Internal/Row.hs view
@@ -1,4 +1,8 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE ExplicitNamespaces #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE InstanceSigs #-} module DataFrame.Internal.Row where import qualified Data.List as L@@ -17,6 +21,33 @@ import DataFrame.Internal.DataFrame import DataFrame.Internal.Types import Data.Function (on)+import Data.Maybe (fromMaybe)+import Data.Typeable (Typeable, type (:~:) (..))+import Data.Word ( Word8, Word16, Word32, Word64 )+import Type.Reflection (TypeRep, typeOf, typeRep)+import Data.Type.Equality (TestEquality(..))++data RowValue where+ Value :: (Columnable' a) => a -> RowValue++instance Eq RowValue where+ (==) :: RowValue -> RowValue -> Bool+ (Value a) == (Value b) = fromMaybe False $ do+ Refl <- testEquality (typeOf a) (typeOf b)+ return $ a == b++instance Ord RowValue where+ (<=) :: RowValue -> RowValue -> Bool+ (Value a) <= (Value b) = fromMaybe False $ do+ Refl <- testEquality (typeOf a) (typeOf b)+ return $ a <= b++instance Show RowValue where+ show :: RowValue -> String+ show (Value a) = show a++toRowValue :: forall a . (Columnable' a) => a -> RowValue+toRowValue = Value type Row = V.Vector RowValue
src/DataFrame/Internal/Types.hs view
@@ -19,54 +19,4 @@ import Type.Reflection (TypeRep, typeOf, typeRep) import Data.Type.Equality (TestEquality(..)) --- We need an "Object" type as an intermediate representation--- for rows. Useful for things like sorting and function application. type Columnable' a = (Typeable a, Show a, Ord a, Eq a)--data RowValue where- Value :: (Columnable' a) => a -> RowValue--instance Eq RowValue where- (==) :: RowValue -> RowValue -> Bool- (Value a) == (Value b) = fromMaybe False $ do- Refl <- testEquality (typeOf a) (typeOf b)- return $ a == b--instance Ord RowValue where- (<=) :: RowValue -> RowValue -> Bool- (Value a) <= (Value b) = fromMaybe False $ do- Refl <- testEquality (typeOf a) (typeOf b)- return $ a <= b--instance Show RowValue where- show :: RowValue -> String- show (Value a) = show a--toRowValue :: forall a . (Columnable' a) => a -> RowValue-toRowValue = Value---- Convenience functions for types.-unboxableTypes :: TypeRepList '[Int, Int8, Int16, Int32, Int64,- Word, Word8, Word16, Word32, Word64,- Char, Double, Float, Bool]-unboxableTypes = Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep Nil)))))))))))))--numericTypes :: TypeRepList '[Int, Int8, Int16, Int32, Int64, Double, Float]-numericTypes = Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep (Cons typeRep Nil))))))--data TypeRepList (xs :: [Type]) where- Nil :: TypeRepList '[]- Cons :: Typeable x => TypeRep x -> TypeRepList xs -> TypeRepList (x ': xs)--matchesAnyType :: forall a xs. (Typeable a) => TypeRepList xs -> TypeRep a -> Bool-matchesAnyType Nil _ = False-matchesAnyType (Cons ty tys) rep =- case testEquality ty rep of- Just Refl -> True- Nothing -> matchesAnyType tys rep--testUnboxable :: forall a . Typeable a => TypeRep a -> Bool-testUnboxable x = matchesAnyType unboxableTypes (typeRep @a)--testNumeric :: forall a . Typeable a => TypeRep a -> Bool-testNumeric x = matchesAnyType numericTypes (typeRep @a)
src/DataFrame/Operations/Subset.hs view
@@ -21,8 +21,7 @@ import DataFrame.Internal.Column import DataFrame.Internal.DataFrame (DataFrame(..), getColumn, empty) import DataFrame.Internal.Expression-import DataFrame.Internal.Row (mkRowFromArgs)-import DataFrame.Internal.Types (RowValue, toRowValue)+import DataFrame.Internal.Row (mkRowFromArgs, RowValue, toRowValue) import DataFrame.Operations.Core import DataFrame.Operations.Transformations (apply) import Data.Function ((&))
src/DataFrame/Operations/Transformations.hs view
@@ -17,8 +17,7 @@ import DataFrame.Internal.Column (Column(..), columnTypeString, itransform, ifoldrColumn, TypedColumn (TColumn), Columnable, transform, unwrapTypedColumn) import DataFrame.Internal.DataFrame (DataFrame(..), getColumn) import DataFrame.Internal.Expression-import DataFrame.Internal.Row (mkRowFromArgs)-import DataFrame.Internal.Types (RowValue, toRowValue)+import DataFrame.Internal.Row (mkRowFromArgs, RowValue, toRowValue) import DataFrame.Operations.Core import Data.Maybe import Type.Reflection (typeRep, typeOf)