Skip to content

Commit

Permalink
Tweaks to python
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Nov 7, 2024
1 parent 73c8030 commit ab09ff4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions gui/src/app/Scripting/Runtime/load_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def rename_sampling_options(k):
return "iter_sampling"
if k == "num_chains":
return "chains"
if k == "seed":
return "seed"

raise ValueError(f"Unknown sampling option: {k}")

Expand Down
2 changes: 1 addition & 1 deletion gui/src/app/Scripting/Runtime/makePyRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const makePyRuntimeScript = (project: ProjectDataModel) => {
script += `if args.ignore_saved_data:\n`;
script += indent(spRunData);
script += `\nelse:\n`;
script += ` print("Loading data from data.json, pass --ignore--saved-data to run data.py instead")\n`;
script += ` print("Loading data from data.json, pass --ignore-saved-data to run data.py instead")\n`;
script += ` data = os.path.join(HERE, 'data.json')\n\n`;
} else if (hasDataJson) {
script += `data = os.path.join(HERE, 'data.json')\n\n`;
Expand Down
2 changes: 1 addition & 1 deletion gui/src/app/Scripting/Runtime/run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
print("executing analysis.py")

sp_data = {
"draws": fit.draws(concat_chains=True),
"draws": fit.draws(concat_chains=True).transpose(),
"paramNames": fit.metadata.cmdstan_config["raw_header"].split(","),
"numChains": fit.chains,
}
Expand Down
8 changes: 5 additions & 3 deletions gui/test/app/Scripting/makePyRuntime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if args.ignore_saved_data:
if "data" not in locals():
raise ValueError("data variable not defined in data.py")
else:
print("Loading data from data.json, pass --ignore--saved-data to run data.py instead")
print("Loading data from data.json, pass --ignore-saved-data to run data.py instead")
data = os.path.join(HERE, 'data.json')
def rename_sampling_options(k):
Expand All @@ -50,6 +50,8 @@ def rename_sampling_options(k):
return "iter_sampling"
if k == "num_chains":
return "chains"
if k == "seed":
return "seed"
raise ValueError(f"Unknown sampling option: {k}")
Expand Down Expand Up @@ -170,7 +172,7 @@ import matplotlib.pyplot as plt
print("executing analysis.py")
sp_data = {
"draws": fit.draws(concat_chains=True),
"draws": fit.draws(concat_chains=True).transpose(),
"paramNames": fit.metadata.cmdstan_config["raw_header"].split(","),
"numChains": fit.chains,
}
Expand Down Expand Up @@ -217,7 +219,7 @@ describe("Python runtime", () => {
const runPy = makePyRuntimeScript(noAnalysis);

// we expect the same output, truncated after the sampling part
const analysisless = full.split("\n").slice(0, 65).join("\n") + "\n";
const analysisless = full.split("\n").slice(0, 67).join("\n") + "\n";

expect(runPy).toEqual(analysisless);
});
Expand Down

0 comments on commit ab09ff4

Please sign in to comment.