diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e789bbf09..59549cb70 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: args: ["--verbose"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.11 + rev: v0.11.13 hooks: - id: ruff args: ["--fix", "--output-format=full"] @@ -34,7 +34,7 @@ repos: files: ^docs/.*\.ipynb$ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.16.0 hooks: - id: mypy args: [--ignore-missing-imports] diff --git a/pixi.lock b/pixi.lock index e4bdafec9..7b321ce9f 100644 --- a/pixi.lock +++ b/pixi.lock @@ -10595,7 +10595,7 @@ packages: - pypi: . name: pyfixest version: 0.29.0 - sha256: 31543d41ff2468cfd50b45714058aff8a99ee2a92986ce71f79b03942bc50f33 + sha256: 0bb19c6b3039ba36d1b8976ed88a3baefaa037dcbf6a31dc3ed5c067ead41e4d requires_dist: - scipy>=1.6 - formulaic>=1.1.0 diff --git a/pyfixest/did/saturated_twfe.py b/pyfixest/did/saturated_twfe.py index a5b9194a9..018631d93 100644 --- a/pyfixest/did/saturated_twfe.py +++ b/pyfixest/did/saturated_twfe.py @@ -454,7 +454,7 @@ def compute_period_weights( if include_grid: all_periods = sorted(df[period].unique()) grid = pd.MultiIndex.from_product( - [ever_treated, all_periods], names=[cohort, period] + [list(ever_treated), all_periods], names=[cohort, period] ).to_frame(index=False) out = grid.merge(out, on=[cohort, period], how="left") out["weight"] = out["weight"].fillna(0.0) diff --git a/pyfixest/estimation/feols_.py b/pyfixest/estimation/feols_.py index 6ba90fbc7..f9ea19a44 100644 --- a/pyfixest/estimation/feols_.py +++ b/pyfixest/estimation/feols_.py @@ -222,6 +222,18 @@ class Feols: the _model_name_plot attribute will be modified. _quantile: Optional[float] The quantile used for quantile regression. None if not a quantile regression. + + # special for did + _res_cohort_eventtime_dict: Optional[dict[str, Any]] + _yname: Optional[str] + _gname: Optional[str] + _tname: Optional[str] + _idname: Optional[str] + _att: Optional[Any] + test_treatment_heterogeneity: Callable[..., Any] + aggregate: Callable[..., Any] + iplot_aggregate: Callable[..., Any] + """ def __init__( @@ -356,6 +368,14 @@ def __init__( # special for poisson self.deviance = None + # special for did + self._res_cohort_eventtime_dict: Optional[dict[str, Any]] = None + self._yname: Optional[str] = None + self._gname: Optional[str] = None + self._tname: Optional[str] = None + self._idname: Optional[str] = None + self._att: Optional[bool] = None + # set functions inherited from other modules _module = import_module("pyfixest.report") _tmp = _module.coefplot @@ -368,6 +388,16 @@ def __init__( self.summary = functools.partial(_tmp, models=[self]) self.summary.__doc__ = _tmp.__doc__ + # DiD methods - assign placeholder functions + def _not_implemented_did(*args, **kwargs): + raise NotImplementedError( + "This method is only available for DiD models, not for vanilla 'feols'." + ) + + self.test_treatment_heterogeneity = _not_implemented_did + self.aggregate = _not_implemented_did + self.iplot_aggregate = _not_implemented_did + def prepare_model_matrix(self): "Prepare model matrices for estimation." mm_dict = model_matrix_fixest( diff --git a/pyfixest/estimation/fepois_.py b/pyfixest/estimation/fepois_.py index 03ed6f214..84383d2a7 100644 --- a/pyfixest/estimation/fepois_.py +++ b/pyfixest/estimation/fepois_.py @@ -572,7 +572,7 @@ def _check_for_separation_fe( """ separation_na: set[int] = set() if fe is not None and not (Y > 0).all(axis=0).all(): - Y_help = (Y > 0).astype(int).squeeze() + Y_help = (Y.iloc[:, 0] > 0).astype(int) # loop over all elements of fe for x in fe.columns: diff --git a/pyproject.toml b/pyproject.toml index ceb05ea2e..42e1b6634 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -225,7 +225,6 @@ docstring-code-format = true docstring-code-line-length = 88 [tool.mypy] -plugins = "numpy.typing.mypy_plugin" [[tool.mypy.overrides]] module = [