Skip to content

Commit 525f28d

Browse files
committedAug 18, 2012
Pep8 fixes and removal of parsetab.
1 parent 6aa2e91 commit 525f28d

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed
 

‎pydatcom/parser.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class Parser(object):
1515
tokens = ()
1616
precedence = ()
1717

18-
def __init__(self, file_name=None, debug=0):
18+
def __init__(self, file_name=None, debug=0,
19+
keep_parse_tab=False):
1920
self.debug = debug
2021
self.file_name = file_name
22+
self.keep_parse_tab = keep_parse_tab
2123
self.cases = []
2224
self.common_dicts = []
2325
try:
@@ -52,6 +54,11 @@ def __init__(self, file_name=None, debug=0):
5254
file_data = f.read()
5355
yacc.parse(file_data)
5456

57+
if not self.keep_parse_tab:
58+
parse_tab_file = "parser_DatcomParser_parsetab.py"
59+
if os.path.exists(parse_tab_file):
60+
os.remove(parse_tab_file)
61+
5562

5663
class DatcomParser(Parser):
5764
"""

‎pydatcom/plotter.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
from matplotlib.ticker import EngFormatter
1010
import numpy as np
1111

12+
1213
class DatcomPlotter(object):
1314

1415
def __init__(self, parser_dict):
1516
self.d = parser_dict
1617
if not os.path.isdir('fig'):
1718
os.mkdir('fig')
18-
self.figpath=os.path.abspath('fig')
19+
self.figpath = os.path.abspath('fig')
1920

2021
def common_plots(self):
2122
## lift plots
@@ -87,7 +88,7 @@ def common_plots(self):
8788
title='{name}: YawRate effect on Roll Moment Coefficient',
8889
x_name='alpha', x_label='Alpha, deg',
8990
y_name='dCl_YawRate', y_label='dCl')
90-
91+
9192
## pitch moment
9293
self.plot2d(
9394
title='{name}: Basic Pitch Moment Coefficient',
@@ -129,24 +130,24 @@ def common_plots(self):
129130
x_name='alpha', x_label='Alpha, deg',
130131
y_name='dCn_YawRate', y_label='dCn')
131132

132-
def plot2d(self, title,
133+
def plot2d(self, title,
133134
x_name, x_label,
134135
y_name, y_label):
135136
fig = plt.figure()
136137
ax = fig.add_subplot(111)
137138
y = self.d[y_name]
138139
x = self.d[x_name][:len(y)]
139-
ax.plot(x,y)
140+
ax.plot(x, y)
140141
ax.set_xlabel(x_label.format(**self.d))
141142
ax.set_ylabel(y_label.format(**self.d))
142143
ax.set_title(title.format(**self.d))
143144
ax.grid()
144145
plt.savefig(os.path.join(self.figpath,
145146
os.path.join(self.figpath,
146-
title.format(**self.d)+'.pdf')))
147+
title.format(**self.d) + '.pdf')))
147148
plt.close(fig)
148149

149-
def plot3d(self, title,
150+
def plot3d(self, title,
150151
x_name, x_label,
151152
y_name, y_label,
152153
z_name, z_label):
@@ -163,14 +164,14 @@ def plot3d(self, title,
163164
#print 'len Z2:', len(Z[0])
164165
#print 'len x:', len(x)
165166
#print 'len y:', len(y)
166-
X, Y = np.meshgrid(x,y)
167+
X, Y = np.meshgrid(x, y)
167168
surf = ax.plot_surface(X, Y, Z,
168169
cmap=cm.jet, rstride=1, cstride=1)
169170
fig.colorbar(surf, shrink=0.5, aspect=5)
170171
ax.grid()
171172
plt.savefig(os.path.join(self.figpath,
172173
os.path.join(self.figpath,
173-
title.format(**self.d)+'.pdf')))
174+
title.format(**self.d) + '.pdf')))
174175
plt.close(fig)
175176

176177
@staticmethod
@@ -186,6 +187,6 @@ def command_line():
186187
parser = DatcomParser(args.datcom_file)
187188
plotter = DatcomPlotter(parser.get_common())
188189
plotter.common_plots()
189-
190+
190191
if __name__ == "__main__":
191192
DatcomPlotter.command_line()

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import os
55

6-
version = '0.2.4'
6+
version = '0.2.5'
77

88
setup(name='PyDatcom',
99
version=version,

0 commit comments

Comments
 (0)
Please sign in to comment.