Repository navigation
Fix test_create_table_numpy to run without pandas in the numpy: 1 CI leg - #875
Open
aayushgupta7725 wants to merge 1 commit into
Open
aayushgupta7725 wants to merge 1 commit into
aayushgupta7725 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #872
The
numpy: 1leg of the test matrix in.github/workflows/test.ymlinstalls numpy but deliberately not pandas, to check numpy-only
scenarios. However, the only test meant to run there,
test_create_table_numpy, was decorated with@pytest.mark.skipif(pd is None, ...)and built its test data viapd.DataFrame(...).to_dict(orient="records")— so it required pandasand was silently skipped in every
numpy: 1job, every time, since2020.
This PR rewrites the test to build its rows directly with numpy's own
constructors (
np.int8,np.uint64,np.float16, etc.), using.item()to convert each value to a plain Python type the same waypandas'
to_dict()already does internally. This removes the pandasdependency from the test while preserving exactly what it verifies —
that sqlite-utils can build a table and insert data originating from
various numpy dtypes.
Changes:
test_create_table_numpyintests/test_create.pyto usenumpy directly instead of
pd.DataFrameskipifcondition frompd is Nonetonp is Noneimport pandas as pdblock fromtests/test_create.py, since nothing else in the file referencespdVerified locally: with pandas uninstalled and numpy installed
(matching the
numpy: 1CI leg), the test now runs and passes ratherthan being skipped.
📚 Documentation preview 📚: https://sqlite-utils--875.org.readthedocs.build/en/875/