opensafely-core / interactive-templates

Code to generate the reports generated by OpenSAFELY Interactive
Other
0 stars 0 forks source link

Fix quirks in pandas test behaviour #370

Closed StevenMaude closed 3 months ago

StevenMaude commented 3 months ago

For the current state of the code, this change is not required. It will, however, save someone fixing this in future, when actually wanting to use a newer OpenSAFELY Python image.

However, the tests currently rely on a quirky behaviour of .all() in pandas that has been fixed.

In the version of pandas inside the python:latest image (v1.0.1), the behaviour is that .all() can return an dtype=object instead of a Boolean, and our tests as written pass.

In later versions of pandas, .all() returns a Boolean instead, and our tests fail.

We can rewrite the tests to work both prior to and post this pandas fix.

This was checked by running the tests with the Dockerfile as provided, and editing the Dockerfile to use the v2 OpenSAFELY Python image.

See pandas-dev/pandas#12863.