Skip to content

Conversation

@amiri
Copy link
Contributor

@amiri amiri commented Jan 23, 2026

…tions.Subset.sample in DataFrame.Monad.modifyM, like filterWhereM

I think I did this correctly. I feel uncomfortable with the lack of tests, though, and I don't know how to test this code. I would appreciate any guidance on how to do that here. I could then write tests for the other monadic functions, too.

@mchav
Copy link
Member

mchav commented Jan 23, 2026

Thanks so much @amiri! Agreed we should have tests. I'm trying to figure out how to get good property tests working but this feels like it's a fine change to visually inspect.

You can run the following commands to eyeball the results:

$ ./scripts/repl.sh
ghci> :script dataframe.ghci
dataframe> df <- D.readCsv "./data/housing.csv"
dataframe> D.nRows df
-- some number
dataframe> import DataFrame.Monad
dataframe> import System.Random
dataframe> D.nRows (execFrame df (sampleM (mkStdGen 431) 0.1))
-- Should be 10% of previous number.

@amiri
Copy link
Contributor Author

amiri commented Jan 23, 2026

OK, that worked, but I used execFrameM instead of just execFrame, and I got 2,079 rows out of 20,640. A tiny bit more than 10 percent.

@mchav mchav merged commit 790fa81 into DataHaskell:main Jan 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants