Skip to content

Commit

Permalink
docs: update basic-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hollandjg committed Dec 1, 2023
1 parent e32b4f1 commit b02bbc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
35 changes: 2 additions & 33 deletions docs/cli/basic-usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The command line interface allows us to load and save `States` and run arbitrary
To use the command line, we first define a file containing the functions we want to run on the State.

```python title="lib.py"
--8<-- "https://raw.githubusercontent.com/AutoResearch/autora-core/feat/reintegrate-workflow/docs/cli/basic-usage/lib.py"
--8<-- "https://raw.githubusercontent.com/AutoResearch/autora-core/docs/update-workflow-docs/docs/cli/basic-usage/lib.py"
```

We can run the pipeline of initialization, condition generation, experiment and theory building as follows.
Expand Down Expand Up @@ -115,38 +115,7 @@ For instance, we can plot the results:


```python title="plot.py"
# TODO: replace with snippet

#!/usr/bin/env python
import numpy as np
from matplotlib import pyplot as plt
import typer

from autora.workflow.__main__ import load_state

from lib import ground_truth, noise_std


def plot_results(state):
x = np.linspace(-10, 10, 100).reshape((-1, 1))
plt.plot(x, ground_truth(x), label="ground_truth", c="orange")
plt.fill_between(x.flatten(), ground_truth(x).flatten() + noise_std, ground_truth(x).flatten() - noise_std,
alpha=0.3, color="orange")

xi, yi = state.experiment_data["x"], state.experiment_data["y"]
plt.scatter(xi, yi, label=f"observations")

plt.plot(x, state.models[-1].predict(x), label="model")

plt.legend()
plt.show()

def main(filename: str):
state = load_state(filename) # load from the first
plot_results(state)

if __name__ == "__main__":
typer.run(main)
--8<-- "https://raw.githubusercontent.com/AutoResearch/autora-core/docs/update-workflow-docs/docs/cli/basic-usage/plot.py"
```

```shell
Expand Down
1 change: 0 additions & 1 deletion docs/cli/basic-usage/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def plot_results(state: StandardState):
)

assert isinstance(state.experiment_data, pd.DataFrame)

xi, yi = state.experiment_data["x"], state.experiment_data["y"]
plt.scatter(xi, yi, label="observations")

Expand Down

0 comments on commit b02bbc5

Please sign in to comment.