Skip to content

Commit cb77524

Browse files
committed
flake8, isort
1 parent 29f1ce5 commit cb77524

File tree

8 files changed

+24
-23
lines changed

8 files changed

+24
-23
lines changed

src/microstructpy/examples/docs_banner.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import os
44

55
import matplotlib.pyplot as plt
6-
import microstructpy as msp
76
import numpy as np
87
import scipy.stats
98

9+
import microstructpy as msp
10+
1011

1112
def main():
1213
# Colors
@@ -61,7 +62,7 @@ def main():
6162
len_y = domain.width + 2 * off
6263
plt.figure(figsize=(k * len_x, k * len_y))
6364

64-
# Plot Seeds
65+
# Plot Seeds
6566
seed_colors = [phases[s.phase]['color'] for s in seeds]
6667
seeds.plot(color=seed_colors, alpha=0.8, edgecolor='k', linewidth=0.3)
6768
domain.plot(facecolor='none', edgecolor='k', linewidth=0.3)
@@ -111,7 +112,7 @@ def main():
111112
plt.gca().set_axis_off()
112113
plt.gca().get_xaxis().set_visible(False)
113114
plt.gca().get_yaxis().set_visible(False)
114-
115+
115116
xlim, ylim = domain.limits
116117
xlim[0] -= off
117118
xlim[1] += 3 * off + 2 * domain.length

src/microstructpy/examples/foam.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import os
22

33
import matplotlib.pyplot as plt
4-
import microstructpy as msp
54
import numpy as np
65
import scipy.stats
76

7+
import microstructpy as msp
8+
89

910
def main():
1011
# Create Directory
@@ -49,7 +50,7 @@ def main():
4950
while not good_pt:
5051
trial_pt = trial_position(void_tess)
5152
good_pt = check_pt(trial_pt, r, check_bkdwns)
52-
53+
5354
seed.position = trial_pt
5455
bkdwns[i] = seed.breakdown
5556
seed.phase = 1
@@ -97,6 +98,7 @@ def pick_edge(void_tess):
9798
kp2 = facet[j - 1]
9899
return kp1, kp2
99100

101+
100102
def trial_position(void_tess):
101103
kp1, kp2 = pick_edge(void_tess)
102104
pt1 = void_tess.points[kp1]

src/microstructpy/examples/from_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import matplotlib.image as mpim
55
import matplotlib.pyplot as plt
6-
import microstructpy as msp
76
import numpy as np
87

8+
import microstructpy as msp
99

1010
# Read in image
1111
image_basename = 'aluminum_micro.png'

src/microstructpy/examples/grain_neighborhoods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import os
44

55
import matplotlib.pyplot as plt
6-
import microstructpy as msp
76
import numpy as np
87
import scipy.integrate
98
import scipy.stats
109

10+
import microstructpy as msp
1111

1212
# Define the domain
1313
domain = msp.geometry.Square(corner=(0, 0), side_length=10)
@@ -83,7 +83,7 @@
8383
max_volume=0.1)
8484

8585
# Plot triangle mesh
86-
colors = ['C' + str(repl_seeds[a].phase) for a in tmesh.element_attributes]
86+
colors = ['C' + str(repl_seeds[att].phase) for att in tmesh.element_attributes]
8787
tmesh.plot(facecolors=colors, edgecolors='k', linewidth=0.2)
8888

8989
plt.axis('square')

src/microstructpy/examples/logo.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import os
44

55
import matplotlib.pyplot as plt
6-
import microstructpy as msp
76
import numpy as np
87
from matplotlib import collections
9-
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
8+
from matplotlib.offsetbox import AnnotationBbox
9+
from matplotlib.offsetbox import OffsetImage
1010

11-
__author__ = 'Kenneth (Kip) Hart'
11+
import microstructpy as msp
1212

1313

1414
def main(n_seeds, size_rng, pos_rng, k_lw):
@@ -106,14 +106,13 @@ def main(n_seeds, size_rng, pos_rng, k_lw):
106106
# Create the Logo
107107
logo_im = np.copy(plt_im)
108108

109-
xx, yy = np.meshgrid(np.arange(logo_im.shape[0]), np.arange(logo_im.shape[1]))
110-
zz = - 0.2 * xx + 0.9 * yy
109+
xx, yy = np.meshgrid(*[np.arange(n) for n in logo_im.shape])
110+
zz = - 0.2 * xx + 0.9 * yy
111111
ss = (zz - zz.min()) / (zz.max() - zz.min())
112112

113113
c1 = [67, 206, 162]
114114
c2 = [24, 90, 157]
115115

116-
117116
logo_im[mask, -1] = 0 # transparent background
118117

119118
# gradient
@@ -124,9 +123,9 @@ def main(n_seeds, size_rng, pos_rng, k_lw):
124123
logo_im = logo_im[inds]
125124
logo_im = logo_im[:, inds]
126125

127-
pad_width = logo_im.shape[0]
128-
pad_height = 0.5 * logo_im.shape[1]
129-
pad_shape = np.array([pad_width, pad_height, logo_im.shape[2]]).astype('int')
126+
pad_w = logo_im.shape[0]
127+
pad_h = 0.5 * logo_im.shape[1]
128+
pad_shape = np.array([pad_w, pad_h, logo_im.shape[2]]).astype('int')
130129
logo_pad = np.zeros(pad_shape, dtype=logo_im.dtype)
131130
pad_im = np.concatenate((logo_pad, logo_im, logo_pad), axis=1)
132131
doc_im = np.concatenate((logo_pad, pad_im, logo_pad), axis=1)
@@ -141,7 +140,7 @@ def main(n_seeds, size_rng, pos_rng, k_lw):
141140
inds = np.linspace(0, fav_im.shape[0] - 1, favicon_size).astype('int')
142141
fav_im = fav_im[inds]
143142
fav_im = fav_im[:, inds]
144-
143+
145144
plt.imsave(favicon_filename, fav_im, dpi=dpi, format='png')
146145

147146
# Create the Social Banner
@@ -172,7 +171,6 @@ def main(n_seeds, size_rng, pos_rng, k_lw):
172171
plt.close('all')
173172

174173

175-
176174
if __name__ == '__main__':
177175
n_seeds = 14
178176
size_rng = 4

src/microstructpy/examples/standard_voronoi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22

33
import matplotlib.pyplot as plt
4-
import microstructpy as msp
54

5+
import microstructpy as msp
66

77
# Create domain
88
domain = msp.geometry.Square()

src/microstructpy/examples/uniform_seeding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
import matplotlib as mpl
66
import matplotlib.pyplot as plt
7-
import microstructpy as msp
87
import numpy as np
98
from scipy.spatial import distance
109

10+
import microstructpy as msp
1111

1212
# Create domain
13-
domain = msp.geometry.Square(corner=(0,0))
13+
domain = msp.geometry.Square(corner=(0, 0))
1414

1515
# Create list of seed points
1616
factory = msp.seeding.Seed.factory

src/microstructpy/verification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def seeds_of_best_fit(seeds, phases, pmesh, tmesh):
309309
seed_facets = [f for f, m in zip(pmesh.facets, mask) if m]
310310
kps = np.unique([kp for f in seed_facets for kp in f])
311311
seed_pts = poly_pts[kps.astype('int')]
312-
312+
313313
try:
314314
fit_geom = seed.geometry.best_fit(seed_pts)
315315
except ValueError:

0 commit comments

Comments
 (0)