-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show non-fatal stanc warning messages to user. Exposes information available since httpstan 2.2.0. Closes #144
- Loading branch information
1 parent
c62994a
commit 0de28cb
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Test that stanc warnings are visible.""" | ||
import contextlib | ||
import io | ||
|
||
import stan | ||
|
||
|
||
def test_stanc_no_warning() -> None: | ||
"""No warnings.""" | ||
program_code = "parameters {real y;} model {y ~ normal(0,1);}" | ||
buffer = io.StringIO() | ||
with contextlib.redirect_stderr(buffer): | ||
stan.build(program_code=program_code) | ||
assert "warning" not in buffer.getvalue().lower() | ||
|
||
|
||
def test_stanc_warning() -> None: | ||
"""Test that stanc warning is shown to user.""" | ||
# stanc prints warning: | ||
# assignment operator <- is deprecated in the Stan language; use = instead. | ||
program_code = """ | ||
parameters { | ||
real y; | ||
} | ||
model { | ||
real x; | ||
x <- 5; | ||
} | ||
""" | ||
buffer = io.StringIO() | ||
with contextlib.redirect_stderr(buffer): | ||
stan.build(program_code=program_code) | ||
assert "assignment operator <- is deprecated in the Stan language" in buffer.getvalue() |