Skip to content

Comments

Feature/monadic api tests 2#155

Open
amiri wants to merge 4 commits intoDataHaskell:mainfrom
amiri:feature/monadic-api-tests-2
Open

Feature/monadic api tests 2#155
amiri wants to merge 4 commits intoDataHaskell:mainfrom
amiri:feature/monadic-api-tests-2

Conversation

@amiri
Copy link
Contributor

@amiri amiri commented Feb 20, 2026

I am having some strangeness with this test. I am testing the sampleM function, seeing whether the expected sample rate is the real sample rate, but there are 2 problems.

  1. Sometimes I get a non-number from D.nRows:
Rows in initialDf: 705)

It looks like I may be getting generated arbitrary data in there, but GenDataFrame:genDataFrame says that numRows should always be an Int.

  1. And sometimes I get no rows sampled, which doesn't make sense to me:
Rows in initialDf: 204d)
Rows in finalDf: 0; expectedRate is 0.0 where 0.22 was expected
Diff is 0.22

This is always the last test, which always fails. I am doing something wrong, but I don't know what.

@mchav
Copy link
Member

mchav commented Feb 20, 2026

Investigating trace.

There's this message:

-- | The 'traceIO' function outputs the trace message from the IO monad.
-- This sequences the output with respect to other IO actions.
--
-- @since base-4.5.0.0

Maybe the right approach is getting out the I/O monad.

@mchav
Copy link
Member

mchav commented Feb 20, 2026

Seems like a weird interaction from generating zero columns dataframes:

Change GenDataFrame to:

genDataFrame :: Gen DataFrame
genDataFrame = do
    numRows <- choose (100, 1000)
    numCols <- choose (1, 10)
    colNames <- V.fromList <$> vectorOf numCols genUniqueColName
    cols <- V.fromList <$> vectorOf numCols (genColumn numRows)
    let indices = M.fromList $ zip (V.toList colNames) [0 ..]
    pure $
        DataFrame
            { columns = cols
            , columnIndices = indices
            , dataframeDimensions = (numRows, numCols)
            , derivingExpressions = M.empty
            }

@amiri
Copy link
Contributor Author

amiri commented Feb 20, 2026

Doh! I suppose my pre condition didn't work right... Still working on this.

@mchav
Copy link
Member

mchav commented Feb 20, 2026

The precondition checks rows not columns. So might be worth checking both. Even with a passing test the trace output is still weird.

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