Skip to content

Commit 0aa2977

Browse files
committed
test: Check pandas/PaddedInt interaction
1 parent b204f9e commit 0aa2977

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bids/layout/tests/test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import numpy as np
66
import pytest
7+
import pandas as pd
78
import bids
89
from bids.exceptions import ConfigError
910

@@ -91,3 +92,14 @@ def test_PaddedInt_array_comparisons():
9192

9293
# Verify that we do get some False results
9394
assert np.array_equal(np.array([4, 5, 6]) == PaddedInt(5), [False, True, False])
95+
96+
97+
def test_PaddedInt_dataframe_behavior():
98+
# Verify that pandas dataframes are not more special than numpy arrays,
99+
# as far as PaddedInt is concerned
100+
df = pd.DataFrame({'a': [5, 5, 5]})
101+
pidf = pd.DataFrame({'a': [PaddedInt(5)] * 3})
102+
assert np.all(df['a'] == PaddedInt(5))
103+
assert np.all(df == pidf)
104+
105+
assert pidf['a'].dtype is np.dtype('int64')

0 commit comments

Comments
 (0)