Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ You can install the release version from `PyPI` by running
# inside an active virtual environment
python -m pip install pyfixest
```
To install a version with only core functionality and a reduced dependency set, you can run

or the development version from github by running
```py
python -m pip install pyfixest[minimal]
```

You can install the development version from github by running

```py
python -m pip install git+https://github.com/py-econometrics/pyfixest
Expand Down
718 changes: 351 additions & 367 deletions pixi.lock

Large diffs are not rendered by default.

27 changes: 22 additions & 5 deletions pyfixest/estimation/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@

import numpy as np
import pandas as pd
from joblib import Parallel, delayed
from scipy.sparse import csc_matrix
from scipy.sparse.linalg import lsqr
from tqdm import tqdm

try:
from tqdm import tqdm
except ImportError:

def tqdm(iterable, *args, **kwargs):
"Define a dummy tqdm function."
return iterable

Check warning on line 15 in pyfixest/estimation/decomposition.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/estimation/decomposition.py#L15

Added line #L15 was not covered by tests


try:
from joblib import Parallel, delayed

joblib_available = True
except ImportError:
joblib_available = False

Check warning on line 23 in pyfixest/estimation/decomposition.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/estimation/decomposition.py#L22-L23

Added lines #L22 - L23 were not covered by tests


@dataclass
Expand Down Expand Up @@ -154,9 +168,12 @@
self.alpha = alpha
self.B = B

_bootstrapped = Parallel(n_jobs=self.nthreads)(
delayed(self._bootstrap)(rng=rng) for _ in tqdm(range(B))
)
if joblib_available:
_bootstrapped = Parallel(n_jobs=self.nthreads)(

Check warning on line 172 in pyfixest/estimation/decomposition.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/estimation/decomposition.py#L171-L172

Added lines #L171 - L172 were not covered by tests
delayed(self._bootstrap)(rng=rng) for _ in tqdm(range(B))
)
else:
_bootstrapped = [self._bootstrap(rng=rng) for _ in tqdm(range(B))]

Check warning on line 176 in pyfixest/estimation/decomposition.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/estimation/decomposition.py#L176

Added line #L176 was not covered by tests

self._bootstrapped = {
key: np.concatenate([d[key] for d in _bootstrapped])
Expand Down
10 changes: 9 additions & 1 deletion pyfixest/estimation/feols_compressed_.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
import narwhals as nw
import numpy as np
import pandas as pd
from tqdm import tqdm

try:
from tqdm import tqdm
except ImportError:

def tqdm(iterable, *args, **kwargs):
"Define a dummy tqdm function."
return iterable

Check warning on line 16 in pyfixest/estimation/feols_compressed_.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/estimation/feols_compressed_.py#L16

Added line #L16 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being repeated a lot ... why don't we let tqdm be a core dep? It seems very lightweight

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with joblib, actually - it has no other dependencies except for python . More or less the motivation of this PR is to make the package so lightweight that it can easily be installed in closed environments (with no access to pypi / conda). My prior would be that both joblib and tqdm should actually be installed on every system that runs Python, though I'm not 100% sure.

I am more or less gravitating towards having a default / core env that includes joblib, tqdm, GT etc that users install with pip install pyfixest and then a minimal but still functional env for those who can really only work with numpy, scipy, etc. Would be your suggestion to keep tqdm in the "minimal" dependency set @juanitorduz?



from pyfixest.estimation.feols_ import Feols, PredictionErrorOptions, PredictionType
from pyfixest.estimation.FormulaParser import FixestFormula
Expand Down
10 changes: 9 additions & 1 deletion pyfixest/estimation/ritest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@
_HAS_LETS_PLOT = False

from scipy.stats import norm
from tqdm import tqdm

try:
from tqdm import tqdm
except ImportError:

def tqdm(iterable, *args, **kwargs):
"""Define a dummy tqdm function."""
return iterable

Check warning on line 36 in pyfixest/estimation/ritest.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/estimation/ritest.py#L36

Added line #L36 was not covered by tests


from pyfixest.estimation.demean_ import demean

Expand Down
16 changes: 14 additions & 2 deletions pyfixest/report/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import numpy as np
import pandas as pd
from great_tables import GT
from tabulate import tabulate

from pyfixest.estimation.feiv_ import Feiv
from pyfixest.estimation.feols_ import Feols
Expand Down Expand Up @@ -156,6 +154,8 @@
pf.etable([fit1, fit2])
```
"""
# check if etable installed else error

if signif_code is None:
signif_code = [0.001, 0.01, 0.05]
assert isinstance(signif_code, list) and len(signif_code) == 3, (
Expand Down Expand Up @@ -683,6 +683,11 @@
-------
- formatted_table (str): The formatted table as a string.
"""
try:
from tabulate import tabulate
except ImportError:
raise ImportError("The tabulate package is required but it is not installed.")

Check warning on line 689 in pyfixest/report/summarize.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/report/summarize.py#L686-L689

Added lines #L686 - L689 were not covered by tests

# Format the DataFrame for tabulate
table = tabulate(
df,
Expand Down Expand Up @@ -1064,6 +1069,13 @@
rowname_col = dfs.columns[0]
groupname_col = None

try:
from great_tables import GT
except ImportError:
raise ImportError(

Check warning on line 1075 in pyfixest/report/summarize.py

View check run for this annotation

Codecov / codecov/patch

pyfixest/report/summarize.py#L1072-L1075

Added lines #L1072 - L1075 were not covered by tests
"The great_tables package is for running pf.etable() in 'gt' mode."
)

# Generate the table with GT
gt = GT(dfs, auto_align=False)

Expand Down
17 changes: 11 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ dependencies = [
"formulaic>=1.1.0",
"pandas>=1.1.0",
"numba>=0.58.0",
"seaborn>=0.13.2",
"tabulate>=0.9.0",
"tqdm>=4.0.0",
"great-tables>=0.10.0",
"numpy>=1.19.0",
"narwhals>=1.13.3",
"joblib>=1.4.2,<2",
"seaborn>=0.13.2",
]

[tool.pixi.feature.dev.dependencies]
rpy2 = ">=3.5.11,<4"

[project.optional-dependencies]

core = [
"joblib>=1.4.2,<2",
"tabulate>=0.9.0",
"tqdm>=4.0.0",
"great-tables>=0.10.0",
]

dev = [
"pytest>=7.2.0",
"pytest-cov>=4.1.0",
Expand Down Expand Up @@ -83,7 +87,8 @@ platforms = ["linux-64", "win-64", "osx-arm64", "osx-64"]
pyfixest = { path = ".", editable = true }

[tool.pixi.environments]
default = { solve-group = "default" }
minimal = { solve-group = "default" }
default = {features = ["core"], solve-group = "default"}
dev = { features = ["dev"], solve-group = "default" }
docs = { features = ["docs"], solve-group = "default" }
build = { features = ["build"], solve-group = "default" }
Expand Down
9 changes: 8 additions & 1 deletion scripts/run_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@

import papermill
from joblib import Parallel, delayed
from tqdm import tqdm

try:
from tqdm import tqdm
except ImportError:

def tqdm(iterable, *args, **kwargs):
return iterable


KERNEL_NAME: str = "python3"
DOCS = Path("docs")
Expand Down
Loading