-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split tests for deprecated api (#5071)
* imports * imports * flake8 Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
- Loading branch information
Showing
3 changed files
with
78 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Test deprecated functionality which will be removed in vX.Y.Z""" | ||
import sys | ||
|
||
|
||
def _soft_unimport_module(str_module): | ||
# once the module is imported e.g with parsing with pytest it lives in memory | ||
if str_module in sys.modules: | ||
del sys.modules[str_module] |
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,45 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Test deprecated functionality which will be removed in vX.Y.Z""" | ||
|
||
import pytest | ||
import torch | ||
|
||
from pytorch_lightning.callbacks import ModelCheckpoint | ||
from pytorch_lightning.utilities.exceptions import MisconfigurationException | ||
|
||
|
||
def test_tbd_remove_in_v1_2_0(): | ||
with pytest.deprecated_call(match='will be removed in v1.2'): | ||
ModelCheckpoint(filepath='..') | ||
|
||
with pytest.deprecated_call(match='will be removed in v1.2'): | ||
ModelCheckpoint('..') | ||
|
||
with pytest.raises(MisconfigurationException, match='inputs which are not feasible'): | ||
ModelCheckpoint(filepath='..', dirpath='.') | ||
|
||
|
||
def test_tbd_remove_in_v1_2_0_metrics(): | ||
from pytorch_lightning.metrics.classification import Fbeta | ||
from pytorch_lightning.metrics.functional.classification import f1_score, fbeta_score | ||
|
||
with pytest.deprecated_call(match='will be removed in v1.2'): | ||
Fbeta(2) | ||
|
||
with pytest.deprecated_call(match='will be removed in v1.2'): | ||
fbeta_score(torch.tensor([0, 1, 2, 3]), torch.tensor([0, 1, 2, 1]), 0.2) | ||
|
||
with pytest.deprecated_call(match='will be removed in v1.2'): | ||
f1_score(torch.tensor([0, 1, 0, 1]), torch.tensor([0, 1, 0, 0])) |
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