Skip to content

Fix formula eval depth in select models - #9471

Merged
bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:port-rob-sil-eval-depth-from-formula
Jan 7, 2025
Merged

bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:port-rob-sil-eval-depth-from-formula

Conversation

@bashtage

@bashtage bashtage commented Jan 7, 2025 •

Copy link
Copy Markdown
Member
Details

Notes:

  • It is essential that you add a test when making code changes. Tests are not
    needed for doc changes.
  • When adding a new function, test values should usually be verified in another package (e.g., R/SAS/Stata).
  • When fixing a bug, you must add a test that would produce the bug in main and
    then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass flake8. If on Linux or OSX, you can
    verify you changes are well formatted by running
    git diff upstream/main -u -- "*.py" | flake8 --diff --isolated
    
    assuming flake8 is installed. This command is also available on Windows
    using the Windows System for Linux once flake8 is installed in the
    local Linux environment. While passing this test is not required, it is good practice and it help
    improve code quality in statsmodels.
  • Docstring additions must render correctly, including escapes and LaTeX.

)

def test_formula_eval_env(self):
def times_two(x):

Check notice

Code scanning / CodeQL

Unused local variable

Variable times_two is not used.
model = "I(food/income) ~ income + persons"
cls.income_fit = BetaModel.from_formula(model, income).fit()

def times_two(x):

Check notice

Code scanning / CodeQL

Unused local variable

Variable times_two is not used.
data=df)
result1 = model1.fit()

def times_two(x):

Check notice

Code scanning / CodeQL

Unused local variable

Variable times_two is not used.
Ensure eval env depth is increased when using super to
build model formulas

closes statsmodels#9047
closes statsmodels#9037
@bashtage
bashtage force-pushed the port-rob-sil-eval-depth-from-formula branch from d5494ff to 4e64b96 Compare January 7, 2025 12:10
@bashtage
bashtage merged commit 4af97fb into statsmodels:main Jan 7, 2025
@bashtage
bashtage deleted the port-rob-sil-eval-depth-from-formula branch January 7, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Cox Model from formula doesn't grab the correct environment

2 participants