From ad5b96404ea09b93b1d183e6eeebaccb76ba7e19 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 11 Dec 2024 09:22:18 +0000 Subject: [PATCH] DOC: Change "cluster" to "clustered" in the docs Update docs Simplify formulaic by removing patch --- ci/azure_template_posix.yml | 1 + linearmodels/compat/formulaic.py | 12 ------------ linearmodels/iv/_utility.py | 5 ----- linearmodels/iv/absorbing.py | 2 +- linearmodels/iv/gmm.py | 2 +- linearmodels/iv/model.py | 10 +++++----- linearmodels/panel/model.py | 5 ----- linearmodels/shared/hypotheses.py | 5 ----- linearmodels/system/model.py | 5 ----- requirements.txt | 2 +- 10 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 linearmodels/compat/formulaic.py diff --git a/ci/azure_template_posix.yml b/ci/azure_template_posix.yml index 49db563b8b..be0286c18a 100644 --- a/ci/azure_template_posix.yml +++ b/ci/azure_template_posix.yml @@ -100,6 +100,7 @@ jobs: flake8 linearmodels black --check linearmodels isort --check linearmodels + ruff check linearmodels displayName: 'Check style and formatting' - script: | diff --git a/linearmodels/compat/formulaic.py b/linearmodels/compat/formulaic.py deleted file mode 100644 index 23020279ca..0000000000 --- a/linearmodels/compat/formulaic.py +++ /dev/null @@ -1,12 +0,0 @@ -def monkey_patch_materializers(): - from formulaic.materializers.base import FormulaMaterializer - from formulaic.materializers.pandas import PandasMaterializer - - if "pandas.DataFrame" not in FormulaMaterializer.REGISTERED_INPUTS: - FormulaMaterializer.REGISTERED_INPUTS["pandas.DataFrame"] = ( - FormulaMaterializer.REGISTERED_INPUTS["pandas.core.frame.DataFrame"] - ) - if "pandas.DataFrame" not in PandasMaterializer.REGISTERED_INPUTS: - PandasMaterializer.REGISTERED_INPUTS["pandas.DataFrame"] = ( - PandasMaterializer.REGISTERED_INPUTS["pandas.core.frame.DataFrame"] - ) diff --git a/linearmodels/iv/_utility.py b/linearmodels/iv/_utility.py index 164a8d0523..57c0882425 100644 --- a/linearmodels/iv/_utility.py +++ b/linearmodels/iv/_utility.py @@ -13,11 +13,6 @@ import linearmodels.typing.data -from ..compat.formulaic import monkey_patch_materializers - -# Monkey patch parsers if needed, remove once formulaic updated -monkey_patch_materializers() - PARSING_ERROR = """ Conversion of formula blocks to DataFrames failed. The formula blocks used for conversion were: diff --git a/linearmodels/iv/absorbing.py b/linearmodels/iv/absorbing.py index d8069228d4..72ff24e69c 100644 --- a/linearmodels/iv/absorbing.py +++ b/linearmodels/iv/absorbing.py @@ -1020,7 +1020,7 @@ def fit( * "robust", "heteroskedastic" - Heteroskedasticity robust inference * "kernel" - Heteroskedasticity and autocorrelation robust inference - * "cluster" - One-way cluster dependent inference. + * "clustered" - One-way cluster dependent inference. Heteroskedasticity robust debiased : bool diff --git a/linearmodels/iv/gmm.py b/linearmodels/iv/gmm.py index b5b398e7f8..16a4cac418 100644 --- a/linearmodels/iv/gmm.py +++ b/linearmodels/iv/gmm.py @@ -380,7 +380,7 @@ class IVGMMCovariance(HomoskedasticCovariance): * "robust", "heteroskedastic" - Allows for heteroskedasticity by not autocorrelation * "kernel" - Allows for heteroskedasticity and autocorrelation - * "cluster" - Allows for one-way cluster dependence + * "clustered" - Allows for one-way cluster dependence debiased : bool Flag indicating whether to debias the covariance estimator diff --git a/linearmodels/iv/model.py b/linearmodels/iv/model.py index bf937fe7b4..cbc5bbfd67 100644 --- a/linearmodels/iv/model.py +++ b/linearmodels/iv/model.py @@ -632,7 +632,7 @@ def fit( * "robust", "heteroskedastic" - Heteroskedasticity robust inference * "kernel" - Heteroskedasticity and autocorrelation robust inference - * "cluster" - One-way cluster dependent inference. + * "clustered" - One-way cluster dependent inference. Heteroskedasticity robust debiased : bool @@ -976,7 +976,7 @@ class _IVGMMBase(_IVModelBase): * "robust", "heteroskedastic" - Allows for heteroskedasticity by not autocorrelation * "kernel" - Allows for heteroskedasticity and autocorrelation - * "cluster" - Allows for one-way cluster dependence + * "clustered" - Allows for one-way cluster dependence The estimator is defined as @@ -1079,7 +1079,7 @@ class IVGMM(_IVGMMBase): * "robust", "heteroskedastic" - Allows for heteroskedasticity by not autocorrelation * "kernel" - Allows for heteroskedasticity and autocorrelation - * "cluster" - Allows for one-way cluster dependence + * "clustered" - Allows for one-way cluster dependence The estimator is defined as @@ -1245,7 +1245,7 @@ def fit( * "robust", "heteroskedastic" - Allows for heteroskedasticity but not autocorrelation * "kernel" - Allows for heteroskedasticity and autocorrelation - * "cluster" - Allows for one-way cluster dependence + * "clustered" - Allows for one-way cluster dependence debiased : bool Flag indicating whether to debiased the covariance estimator using @@ -1355,7 +1355,7 @@ class IVGMMCUE(_IVGMMBase): * "robust", "heteroskedastic" - Allows for heteroskedasticity by not autocorrelation * "kernel" - Allows for heteroskedasticity and autocorrelation - * "cluster" - Allows for one-way cluster dependence + * "clustered" - Allows for one-way cluster dependence In most circumstances, the ``center`` weight option should be ``True`` to avoid starting value dependence. diff --git a/linearmodels/panel/model.py b/linearmodels/panel/model.py index 73313a343a..1071e13d01 100644 --- a/linearmodels/panel/model.py +++ b/linearmodels/panel/model.py @@ -1,7 +1,5 @@ from __future__ import annotations -from linearmodels.compat.formulaic import monkey_patch_materializers - from collections.abc import Mapping from typing import Any, NamedTuple, Union, cast @@ -58,9 +56,6 @@ from linearmodels.shared.utility import AttrDict, ensure_unique_column, panel_to_frame import linearmodels.typing.data -# Monkey patch parsers if needed, remove once formulaic updated -monkey_patch_materializers() - CovarianceEstimator = Union[ ACCovariance, ClusteredCovariance, diff --git a/linearmodels/shared/hypotheses.py b/linearmodels/shared/hypotheses.py index 8570492c09..96aa544cc0 100644 --- a/linearmodels/shared/hypotheses.py +++ b/linearmodels/shared/hypotheses.py @@ -1,7 +1,5 @@ from __future__ import annotations -from linearmodels.compat.formulaic import monkey_patch_materializers - from collections.abc import Mapping from formulaic.utils.constraints import LinearConstraints @@ -11,9 +9,6 @@ import linearmodels.typing.data -# Monkey patch parsers if needed, remove once formulaic updated -monkey_patch_materializers() - class WaldTestStatistic: """ diff --git a/linearmodels/system/model.py b/linearmodels/system/model.py index 254caffef2..7c854e2f1a 100644 --- a/linearmodels/system/model.py +++ b/linearmodels/system/model.py @@ -14,8 +14,6 @@ from __future__ import annotations -from linearmodels.compat.formulaic import monkey_patch_materializers - from collections.abc import Mapping, Sequence from functools import reduce import textwrap @@ -61,9 +59,6 @@ __all__ = ["SUR", "IV3SLS", "IVSystemGMM", "LinearConstraint"] -# Monkey patch parsers if needed, remove once formulaic updated -monkey_patch_materializers() - UNKNOWN_EQ_TYPE = """ Contents of each equation must be either a dictionary with keys "dependent" and "exog" or a 2-element tuple of he form (dependent, exog). diff --git a/requirements.txt b/requirements.txt index 2050406585..aa98893b0b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,6 @@ statsmodels>=0.13.0 mypy_extensions>=0.4 Cython>=3.0.10 pyhdfe>=0.1 -formulaic>=1.0.0 +formulaic>=1.0.2 # versioning setuptools_scm[toml]>=8.0.0,<9.0.0