Skip to content

Commit 1987a1a

Browse files
MNT print narx to markdown table (#133)
1 parent d29ce47 commit 1987a1a

File tree

6 files changed

+4157
-272
lines changed

6 files changed

+4157
-272
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ jobs:
4949
uses: codecov/codecov-action@v5
5050
with:
5151
token: ${{ secrets.CODECOV_TOKEN }}
52+
verbose: true

fastcan/narx/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class NARX(MultiOutputMixin, RegressorMixin, BaseEstimator):
132132
... delay_ids=delay_ids).fit(X, y, coef_init="one_step_ahead")
133133
>>> print_narx(narx)
134134
| yid | Term | Coef |
135-
=======================================
135+
|-----|--------------------|----------|
136136
| 0 | Intercept | 1.008 |
137137
| 0 | y_hat[k-1,0] | 0.498 |
138138
| 0 | X[k-2,0] | 0.701 |

fastcan/narx/_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def print_narx(
6969
>>> X, y = load_diabetes(return_X_y=True)
7070
>>> print_narx(NARX().fit(X, y), term_space=10, coef_space=5, float_precision=0)
7171
| yid | Term |Coef |
72-
========================
72+
|-----|----------|-----|
7373
| 0 |Intercept | 152 |
7474
| 0 | X[k,0] | -10 |
7575
| 0 | X[k,1] |-240 |
@@ -102,7 +102,7 @@ def _get_term_str(term_feat_ids, term_delay_ids):
102102
+ f"|{'Term':^{term_space}}"
103103
+ f"|{'Coef':^{coef_space}}|"
104104
)
105-
print("=" * (yid_space + term_space + coef_space + 4))
105+
print(f"|{'-'*yid_space}|{'-'*term_space}|{'-'*coef_space}|")
106106
for i in range(narx.n_outputs_):
107107
print(
108108
f"|{i:^{yid_space}}|"
@@ -246,7 +246,7 @@ def make_narx(
246246
0.0289
247247
>>> print_narx(narx)
248248
| yid | Term | Coef |
249-
=======================================
249+
|-----|--------------------|----------|
250250
| 0 | Intercept | 1.050 |
251251
| 0 | y_hat[k-1,0] | 0.484 |
252252
| 0 | X[k,0]*X[k,0] | 0.306 |

fastcan/narx/tests/test_narx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ def test_print_narx(capsys):
517517
captured = capsys.readouterr()
518518
# Check if the header is present in the output
519519
assert "| yid | Term | Coef |" in captured.out
520+
# Check if the separator line is present
521+
assert "|-----|--------------------|----------|" in captured.out
520522
# Check if the intercept line for yid 0 is present
521523
assert "| 0 | Intercept |" in captured.out
522524
# Check if the intercept line for yid 1 is present

0 commit comments

Comments
 (0)