Skip to content

Commit 74c96d9

Browse files
committed
set %precision
formatting
1 parent cf294c5 commit 74c96d9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

roboticstoolbox/examples/rtbtool

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,7 @@ if args.showassign:
132132
""",
133133
attr(0))
134134

135-
# if args.script is not None:
136-
# path = Path(args.script)
137-
# if not path.exists():
138-
# raise ValueError(f"script does not exist: {args.script}")
139-
# exec(path.read_text())
140-
141-
142135
# drop into IPython
143-
144-
145136
class MyPrompt(Prompts):
146137
def in_prompt_tokens(self, cli=None):
147138
return [(Token.Prompt, args.prompt)]
@@ -169,16 +160,22 @@ c.InteractiveShell.prompts_class = MyPrompt
169160
if args.showassign:
170161
c.InteractiveShell.ast_node_interactivity = 'last_expr_or_assign'
171162

163+
# set precision, same as %precision
164+
c.PlainTextFormatter.float_precision = "%.3f"
165+
166+
# set up a script to be executed by IPython when we get there
172167
code = None
173168
if args.script is not None:
174169
path = Path(args.script)
175170
if not path.exists():
176171
raise ValueError(f"script does not exist: {args.script}")
177172
code = path.open('r').readlines()
178173
if code is None:
179-
code = ["plt.ion()"]
174+
code = [
175+
"plt.ion()",
176+
]
177+
180178
else:
181179
code.append("plt.ion()")
182-
183180
c.InteractiveShellApp.exec_lines = code
184181
IPython.start_ipython(config=c, user_ns=globals())

0 commit comments

Comments
 (0)