Skip to content

Commit a8c1235

Browse files
authored
Add pre-commit that strips out cells (#226)
1 parent c768b10 commit a8c1235

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

.github/workflows/pre-commit.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Linting
2+
3+
on:
4+
push:
5+
branches: main
6+
pull_request:
7+
branches: main
8+
9+
jobs:
10+
checks:
11+
name: "pre-commit hooks"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-python@v2
16+
with:
17+
python-version: "3.9"
18+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v2.31.0
4+
hooks:
5+
- id: pyupgrade
6+
args:
7+
- --py38-plus
8+
- repo: https://github.com/kynan/nbstripout
9+
rev: 0.6.0
10+
hooks:
11+
- id: nbstripout
12+

conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Configuration file for the Sphinx documentation builder.
43
#

machine-learning/tutorial_helper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def train_model(model, criterion, optimizer, scheduler, num_epochs=25):
6464
best_acc = 0.0
6565

6666
for epoch in range(num_epochs):
67-
print('Epoch {}/{}'.format(epoch, num_epochs - 1))
67+
print(f'Epoch {epoch}/{num_epochs - 1}')
6868
print('-' * 10)
6969

7070
# Each epoch has a training and validation phase
@@ -119,7 +119,7 @@ def train_model(model, criterion, optimizer, scheduler, num_epochs=25):
119119
time_elapsed = time.time() - since
120120
print('Training complete in {:.0f}m {:.0f}s'.format(
121121
time_elapsed // 60, time_elapsed % 60))
122-
print('Best val Acc: {:4f}'.format(best_acc))
122+
print(f'Best val Acc: {best_acc:4f}')
123123

124124
# load best model weights
125125
model.load_state_dict(best_model_wts)
@@ -154,7 +154,7 @@ def visualize_model(model, num_images=6):
154154
fig, axes = plt.subplots(ncols=2, nrows=images_so_far // 2,
155155
figsize=(12, 12))
156156
for img, pred, ax in zip(images, predictions, axes.ravel()):
157-
imshow(img, title="Predicted: {}".format(pred), ax=ax)
157+
imshow(img, title=f"Predicted: {pred}", ax=ax)
158158

159159
plt.tight_layout()
160160
return axes

sql.ipynb

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
{
1313
"cell_type": "code",
1414
"execution_count": null,
15-
"metadata": {
16-
"scrolled": true
17-
},
15+
"metadata": {},
1816
"outputs": [],
1917
"source": [
2018
"! pip install dask-sql"

0 commit comments

Comments
 (0)