Skip to content

Commit 337c1c2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e17fd6f commit 337c1c2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tests/tests_pytorch/trainer/optimization/test_optimizers.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import pytest
1818
import torch
1919
from torch import optim
20+
from torch.utils.data import DataLoader, TensorDataset
2021

2122
from lightning.pytorch import LightningModule, Trainer
2223
from lightning.pytorch.callbacks import ModelCheckpoint
@@ -28,9 +29,6 @@
2829
from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
2930
from lightning.pytorch.utilities.exceptions import MisconfigurationException
3031
from lightning.pytorch.utilities.types import LRSchedulerConfig
31-
32-
from torch import optim
33-
from torch.utils.data import DataLoader, TensorDataset
3432
from tests_pytorch.helpers.runif import RunIf
3533

3634

@@ -674,7 +672,7 @@ def forward(self, x):
674672

675673
def training_step(self, batch, batch_idx):
676674
# Add print statement to track batch index and global step
677-
if hasattr(self, 'trainer'):
675+
if hasattr(self, "trainer"):
678676
print(f"Batch idx: {batch_idx}, Global step: {self.trainer.global_step}")
679677
return {"loss": torch.tensor(0.1, requires_grad=True)}
680678

@@ -721,6 +719,5 @@ def configure_optimizers(self):
721719
# Assert that the scheduler was called the expected number of times
722720
# Allow for a small difference due to environment or rounding discrepancies
723721
assert abs(mocked_sched.call_count - expected_steps) <= 1, (
724-
f"Scheduler was called {mocked_sched.call_count} times, "
725-
f"but expected {expected_steps} calls."
726-
)
722+
f"Scheduler was called {mocked_sched.call_count} times, but expected {expected_steps} calls."
723+
)

0 commit comments

Comments
 (0)