-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use pytest to skip torch tests (#2307)
* use pytest to skip torch tests * fix some mistakes in tsmixer notebook
- Loading branch information
1 parent
0d5c722
commit cdff09a
Showing
21 changed files
with
5,993 additions
and
6,104 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
import pytest | ||
|
||
from darts.logging import get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
try: | ||
import torch | ||
|
||
TORCH_AVAILABLE = True | ||
except ImportError: | ||
logger.warning("Torch not available. Loss tests will be skipped.") | ||
TORCH_AVAILABLE = False | ||
|
||
|
||
if TORCH_AVAILABLE: | ||
from darts.models.components import glu_variants | ||
from darts.models.components.glu_variants import GLU_FFN | ||
except ImportError: | ||
pytest.skip( | ||
f"Torch not available. {__name__} tests will be skipped.", | ||
allow_module_level=True, | ||
) | ||
|
||
|
||
class TestFFN: | ||
def test_ffn(self): | ||
for FeedForward_network in GLU_FFN: | ||
self.feed_forward_block = getattr(glu_variants, FeedForward_network)( | ||
d_model=4, d_ff=16, dropout=0.1 | ||
) | ||
class TestFFN: | ||
def test_ffn(self): | ||
for FeedForward_network in GLU_FFN: | ||
self.feed_forward_block = getattr(glu_variants, FeedForward_network)( | ||
d_model=4, d_ff=16, dropout=0.1 | ||
) | ||
|
||
inputs = torch.zeros(1, 4, 4) | ||
self.feed_forward_block(x=inputs) | ||
inputs = torch.zeros(1, 4, 4) | ||
self.feed_forward_block(x=inputs) |
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
Oops, something went wrong.