-
Notifications
You must be signed in to change notification settings - Fork 0
[tests] tests for the parser #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4f235d7
pytest workflow
deven367 9dc6148
tests for `coreforecast`
deven367 02619ab
append path correctly
deven367 27ef88e
pytest.ini
deven367 93ba70e
pyyaml dep
deven367 c1abeb2
install coreforecast
deven367 2eff2ce
migrate common logic to conftest
deven367 1ebdcef
tests for utilsforecast
deven367 adfca7f
Merge pull request #2 from Nixtla/test-utilsforecast
deven367 523b8e2
install utilsforecast
deven367 24ddd6b
revise logic for default options
deven367 7c257e9
tests for `datasetsforecast`
deven367 08d3705
make pytest output verbose
deven367 672b415
clean-up
deven367 217b416
mark tests as `datasets`
deven367 7245a94
fix ini file and add marker
deven367 29ed0c5
skip tests for datasetsforecast for now (unknown issue for now, runs …
deven367 e07a864
update README with the Notion link
deven367 2624a94
tests for `hierarchicalforecast`
deven367 de98655
tests for `statsforecast`
deven367 eb9ea3e
tests for `mlforecast`
deven367 7f0c431
tests for `neuralforecast`
deven367 05bf3e7
install missing deps
deven367 690eaa3
fix syntax
deven367 3374c8a
migrate to a clean requirements.txt
deven367 6ddb2cb
fix tests for hierarchical
deven367 943773c
fix tests for statsforecast
deven367 45843cc
add logic to parse additional types of docstrings
deven367 34b8544
fix tests for datasets
deven367 153a838
add more tests for hierarchical
deven367 c7e3898
fix test for `mlforecast`
deven367 f250e4d
test `datasets` as well
deven367 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,29 @@ | ||
| name: pytest | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
|
|
||
| jobs: | ||
| run-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: 3.11 | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install -r requirements.txt | ||
|
|
||
| - name: Run tests | ||
| run: pytest |
This file contains hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
| [pytest] | ||
| testpaths = tests | ||
| addopts = -vv | ||
| markers = | ||
| datasets: tests for datasetsforecast | ||
This file contains hidden or 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,12 @@ | ||
| griffe2md | ||
| rich | ||
| pyyaml | ||
| neuralforecast | ||
| mlforecast[dask] | ||
| statsforecast | ||
| hierarchicalforecast | ||
| nixtla | ||
| coreforecast | ||
| utilsforecast | ||
| datasetsforecast | ||
| pytest |
This file contains hidden or 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,13 @@ | ||
| import os | ||
| import sys | ||
|
|
||
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) | ||
| from parser import MkDocstringsParser | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def setup_parser(): | ||
| parser = MkDocstringsParser() | ||
| yield parser |
This file contains hidden or 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,51 @@ | ||
| def test_regular_fn(setup_parser): | ||
| parser = setup_parser | ||
| regular_fn = """::: coreforecast.differences.num_diffs""" | ||
| output = parser.process_markdown(regular_fn) | ||
|
|
||
| assert output == """### `num_diffs` | ||
|
|
||
| ```python | ||
| num_diffs(x, max_d=1) | ||
| ``` | ||
|
|
||
| Find the optimal number of differences | ||
|
|
||
| **Parameters:** | ||
|
|
||
| Name | Type | Description | Default | ||
| ---- | ---- | ----------- | ------- | ||
| `x` | <code>[ndarray](#numpy.ndarray)</code> | Array with the time series. | *required* | ||
| `max_d` | <code>[int](#int)</code> | Maximum number of differences to consider. Defaults to 1. | <code>1</code> | ||
|
|
||
| **Returns:** | ||
|
|
||
| Name | Type | Description | ||
| ---- | ---- | ----------- | ||
| `int` | <code>[int](#int)</code> | Optimal number of differences. | ||
| """ | ||
|
|
||
| def test_fn_w_decorator(setup_parser): | ||
| parser = setup_parser | ||
| fn_w_decorator = """::: coreforecast.expanding.expanding_mean""" | ||
| output = parser.process_markdown(fn_w_decorator) | ||
| assert output == """### `expanding_mean` | ||
|
|
||
| ```python | ||
| expanding_mean(x) | ||
| ``` | ||
|
|
||
| Compute the expanding_mean of the input array. | ||
|
|
||
| **Parameters:** | ||
|
|
||
| Name | Type | Description | Default | ||
| ---- | ---- | ----------- | ------- | ||
| `x` | <code>np.ndarray</code> | Input array. | *required* | ||
|
|
||
| **Returns:** | ||
|
|
||
| Type | Description | ||
| ---- | ----------- | ||
| | np.ndarray: Array with the expanding statistic | ||
| """ |
This file contains hidden or 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,78 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.mark.datasets | ||
deven367 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def test_yearly_dataclass(setup_parser): | ||
| fn = "::: datasetsforecast.m3.Yearly" | ||
| rendered = setup_parser.process_markdown(fn) | ||
|
|
||
| assert rendered == """### `Yearly` | ||
|
|
||
| ```python | ||
| Yearly(seasonality=1, horizon=6, freq='Y', sheet_name='M3Year', name='Yearly', n_ts=645) | ||
| ``` | ||
|
|
||
| #### `Yearly.freq` | ||
|
|
||
| ```python | ||
| freq: str = 'Y' | ||
| ``` | ||
|
|
||
| #### `Yearly.horizon` | ||
|
|
||
| ```python | ||
| horizon: int = 6 | ||
| ``` | ||
|
|
||
| #### `Yearly.n_ts` | ||
|
|
||
| ```python | ||
| n_ts: int = 645 | ||
| ``` | ||
|
|
||
| #### `Yearly.name` | ||
|
|
||
| ```python | ||
| name: str = 'Yearly' | ||
| ``` | ||
|
|
||
| #### `Yearly.seasonality` | ||
|
|
||
| ```python | ||
| seasonality: int = 1 | ||
| ``` | ||
|
|
||
| #### `Yearly.sheet_name` | ||
|
|
||
| ```python | ||
| sheet_name: str = 'M3Year' | ||
| ``` | ||
| """ | ||
|
|
||
| @pytest.mark.datasets | ||
| def test_download_file(setup_parser): | ||
| fn = """::: datasetsforecast.utils.download_file | ||
| handler: python | ||
| options: | ||
| docstring_style: numpy | ||
| heading_level: 3 | ||
| show_root_heading: true | ||
| show_source: true""" | ||
| rendered = setup_parser.process_markdown(fn) | ||
|
|
||
| assert rendered == """### `download_file` | ||
|
|
||
| ```python | ||
| download_file(directory, source_url, decompress=False) | ||
| ``` | ||
|
|
||
| Download data from source_ulr inside directory. | ||
|
|
||
| **Parameters:** | ||
|
|
||
| Name | Type | Description | Default | ||
| ---- | ---- | ----------- | ------- | ||
| `directory` | <code>[str](#str)</code> | Custom directory where data will be downloaded. | *required* | ||
| `source_url` | <code>[str](#str)</code> | URL where data is hosted. | *required* | ||
| `decompress` | <code>[bool](#bool)</code> | Wheter decompress downloaded file. Default False. | <code>False</code> | ||
| """ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.