Skip to content

Commit ec14500

Browse files
committed
MAINT: Avoid dtype changing insert
Convert to series to avoid change dtypes Add pyarrow for testing
1 parent 55b9083 commit ec14500

File tree

8 files changed

+20
-6
lines changed

8 files changed

+20
-6
lines changed

ci/install-posix.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ eval "$CMD"
1616

1717
if [ "${PIP_PRE}" = true ]; then
1818
python -m pip uninstall -y numpy pandas scipy matplotlib statsmodels
19+
python -m pip install pyarrow
1920
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy pandas scipy matplotlib --upgrade --use-deprecated=legacy-resolver
2021
python -m pip install git+https://github.com/statsmodels/statsmodels.git --upgrade --no-build-isolation -v
21-
fi
22+
fi

linearmodels/tests/panel/test_between_ols.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ def test_fitted_effects_residuals(both_data_types):
349349
assert_frame_similar(res.estimated_effects, expected)
350350

351351
fitted_effects = res.fitted_values.values + res.estimated_effects.values
352-
expected.iloc[:, 0] = mod.dependent.values2d - fitted_effects
352+
idiosyncratic = pd.DataFrame(
353+
mod.dependent.values2d - fitted_effects, index=expected.index
354+
)
355+
expected.iloc[:, 0] = idiosyncratic.iloc[:, 0]
353356
expected.columns = ["idiosyncratic"]
354357
assert_allclose(expected, res.idiosyncratic, atol=1e-8)
355358
assert_frame_similar(res.idiosyncratic, expected)

linearmodels/tests/panel/test_fama_macbeth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ def test_fitted_effects_residuals(data):
9595
assert_allclose(res.fitted_values, expected)
9696
assert_frame_similar(res.fitted_values, expected)
9797

98-
expected.iloc[:, 0] = mod.dependent.values2d - expected.values
98+
idiosyncratic = pd.DataFrame(
99+
mod.dependent.values2d - expected.values, index=expected.index
100+
)
101+
expected.iloc[:, 0] = idiosyncratic.iloc[:, 0]
99102
expected.columns = ["idiosyncratic"]
100103
assert_allclose(res.idiosyncratic, expected)
101104
assert_frame_similar(res.idiosyncratic, expected)

linearmodels/tests/panel/test_firstdifference_ols.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ def test_fitted_effects_residuals(data):
207207
assert_allclose(res.fitted_values, expected)
208208
assert_frame_similar(res.fitted_values, expected)
209209

210-
expected.iloc[:, 0] = mod.dependent.values2d - expected.values
210+
idiosyncratic = pd.DataFrame(
211+
mod.dependent.values2d - expected.values, index=expected.index
212+
)
213+
expected.iloc[:, 0] = idiosyncratic.iloc[:, 0]
211214
expected.columns = ["idiosyncratic"]
212215
assert_allclose(res.idiosyncratic, expected)
213216
assert_frame_similar(res.idiosyncratic, expected)

linearmodels/tests/panel/test_panel_ols.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,8 @@ def test_fitted_effects_residuals(data, entity_eff, time_eff):
12571257
assert_frame_similar(res.idiosyncratic, expected)
12581258

12591259
fitted_error = res.fitted_values + res.idiosyncratic.values
1260-
expected.iloc[:, 0] = mod.dependent.values2d - fitted_error
1260+
estimated_effects = mod.dependent.values2d - fitted_error
1261+
expected.iloc[:, 0] = estimated_effects.iloc[:, 0]
12611262
expected.columns = ["estimated_effects"]
12621263
assert_allclose(res.estimated_effects, expected, atol=1e-8)
12631264
assert_frame_similar(res.estimated_effects, expected)

linearmodels/tests/panel/test_random_effects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def test_fitted_effects_residuals(data):
7070
assert_frame_similar(res.idiosyncratic, expected)
7171

7272
fitted_error = res.fitted_values + res.idiosyncratic.values
73-
expected.iloc[:, 0] = mod.dependent.values2d - fitted_error
73+
estimated_effects = mod.dependent.values2d - fitted_error
74+
expected.iloc[:, 0] = estimated_effects.iloc[:, 0]
7475
expected.columns = ["estimated_effects"]
7576
assert_allclose(res.estimated_effects, expected)
7677
assert_frame_similar(res.estimated_effects, expected)

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ pytest-cov
1010
seaborn
1111
xarray>=0.13
1212
wheel
13+
pyarrow

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ filterwarnings =
2626
ignore:`np.bool` is a deprecated alias:DeprecationWarning:pyhdfe
2727
ignore:defusedxml.cElementTree:DeprecationWarning:nbconvert
2828
ignore:the imp module is deprecated in favour of importlib:DeprecationWarning:pywintypes
29+
error:Setting an item of incompatible dtype:FutureWarning:
2930

3031
markers =
3132
slow: mark a test as slow

0 commit comments

Comments
 (0)