Skip to content

Commit 2be4d6c

Browse files
khoda81caleb531
authored andcommitted
Replaced " with '
1 parent f6fc111 commit 2be4d6c

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

automata/fa/fa.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def get_state_name(state_data):
2525
uses `str` for any unsupported python data types.
2626
"""
2727
if isinstance(state_data, str):
28-
if state_data == "":
29-
return "λ"
28+
if state_data == '':
29+
return 'λ'
3030

3131
return state_data
3232

3333
if isinstance(state_data, (set, frozenset, list, tuple)):
34-
inner = ", ".join(FA.get_state_name(sub_data) for sub_data in state_data)
34+
inner = ', '.join(FA.get_state_name(sub_data) for sub_data in state_data)
3535
if isinstance(state_data, (set, frozenset)):
3636
return '{' + inner + '}'
3737

@@ -62,7 +62,7 @@ def is_accepting(self, state):
6262
def is_initial(self, state):
6363
"""Check if a state is an initial state."""
6464

65-
def show(
65+
def show_diagram(
6666
self,
6767
input_str: str | None = None,
6868
save_path: str | os.PathLike | None = None,
@@ -95,7 +95,7 @@ def show(
9595
Digraph: The graph in dot format.
9696
"""
9797
# Converting to graphviz preferred input type,
98-
# keeping the conventional input styles; i.e fig_size(8,8)
98+
# keeping the conventional input styles; i.e fig_size(8, 8)
9999
# TODO why is (8, 8) the "conventional" size?
100100
fig_size = ", ".join(map(str, fig_size))
101101
font_size = str(font_size)
@@ -109,12 +109,12 @@ def show(
109109
ranksep=state_separation,
110110
)
111111
if horizontal:
112-
graph.attr(rankdir="LR")
112+
graph.attr(rankdir='LR')
113113
if reverse_orientation:
114114
if horizontal:
115-
graph.attr(rankdir="RL")
115+
graph.attr(rankdir='RL')
116116
else:
117-
graph.attr(rankdir="BT")
117+
graph.attr(rankdir='BT')
118118

119119
for state in self.iter_states():
120120
# every edge needs an origin node, so we add a null node for every
@@ -125,12 +125,12 @@ def show(
125125
null_node = str(uuid.uuid4())
126126
graph.node(
127127
null_node,
128-
label="",
128+
label='',
129129
shape='point',
130130
fontsize=font_size,
131131
)
132132
node = self.get_state_name(state)
133-
edge_label = "->" + node
133+
edge_label = '->' + node
134134
graph.edge(
135135
null_node,
136136
node,
@@ -147,13 +147,13 @@ def show(
147147
edge_labels = defaultdict(list)
148148
for from_state, to_state, symbol in self.iter_transitions():
149149
# TODO only do this for NFA
150-
label = "ε" if symbol == "" else str(symbol)
150+
label = 'ε' if symbol == '' else str(symbol)
151151
from_node = self.get_state_name(from_state)
152152
to_node = self.get_state_name(to_state)
153153
edge_labels[from_node, to_node].append(label)
154154

155155
for (from_node, to_node), labels in edge_labels.items():
156-
label = ",".join(sorted(labels))
156+
label = ','.join(sorted(labels))
157157
graph.edge(
158158
from_node,
159159
to_node,
@@ -164,7 +164,7 @@ def show(
164164
else:
165165
# TODO
166166
raise NotImplementedError(
167-
"input_str is not yet supported yet"
167+
'input_str is not yet supported yet'
168168
)
169169

170170
status, taken_transitions_pairs, taken_steps = self.input_check(
@@ -177,8 +177,8 @@ def show(
177177
if x not in taken_transitions_pairs
178178
]
179179

180-
start_color = Color("#FFFF00")
181-
end_color = Color("#00FF00") if status else Color("#FF0000")
180+
start_color = Color('#FFFF00')
181+
end_color = Color('#00FF00') if status else Color('#FF0000')
182182

183183
number_of_colors = len(input_str)
184184
interpolation = Color.interpolate([start_color, end_color], space='lch')
@@ -196,18 +196,18 @@ def show(
196196
graph.edge(
197197
pair[0],
198198
pair[1],
199-
label=" [{}]\n{} ".format(counter, pair[2]),
199+
label=' [{}]\n{} '.format(counter, pair[2]),
200200
arrowsize=arrow_size,
201201
fontsize=font_size,
202202
color=edge_color.to_string(hex=True),
203-
penwidth="2.5",
203+
penwidth='2.5',
204204
)
205205

206206
for pair in remaining_transitions_pairs:
207207
graph.edge(
208208
pair[0],
209209
pair[1],
210-
label=" {} ".format(pair[2]),
210+
label=' {} '.format(pair[2]),
211211
arrowsize=arrow_size,
212212
fontsize=font_size,
213213
)
@@ -243,4 +243,4 @@ def _ipython_display_(self):
243243
# IPython. So if IPython is not installed, this function will not be
244244
# called, therefore no need to add ipython as dependency.
245245
from IPython.display import display
246-
display(self.show())
246+
display(self.show_diagram())

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from setuptools import setup
22

3-
if __name__ == "__main__":
3+
if __name__ == '__main__':
44
setup()

0 commit comments

Comments
 (0)