From 260eafd0f052563657a02b545af7684300159c45 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 27 Jun 2023 17:57:52 -0400 Subject: [PATCH 01/16] fix: add corrected aliases for observations and conditions --- src/autora/workflow/state/param.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 42c739b6..48486f4e 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -47,6 +47,16 @@ def _get_state_dependent_properties(state: SupportsControllerState): [np.empty([0, n_ivs + n_dvs])] + list(state.observations) )[:, 0:n_ivs], "%observations.dvs%": lambda: np.row_stack(state.observations)[:, n_ivs:], + "%data.conditions[-1]%": lambda: np.array(state.observations[-1])[ + :, 0:n_ivs + ], + "%observations.observations[-1]%": lambda: np.array(state.observations[-1])[ + :, n_ivs: + ], + "%observations.conditions%": lambda: np.row_stack( + [np.empty([0, n_ivs + n_dvs])] + list(state.observations) + )[:, 0:n_ivs], + "%data.observations%": lambda: np.row_stack(state.observations)[:, n_ivs:], "%models[-1]%": lambda: state.models[-1], "%models%": lambda: state.models, } From bdf650cd5e2edaccc312d1f190a01bbddfa5982e Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Wed, 28 Jun 2023 14:56:28 -0400 Subject: [PATCH 02/16] deps: upgrade autora-core (to allow for new deprecate decorator) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e9c8a8c7..77f6135b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "docs/index.md" license = { text = "MIT License" } dependencies = [ - "autora-core", + "autora-core>=3.2.0a1", "scikit-learn", "matplotlib", "pandas", From 300b8b79f11b9280fd5b41a30e042d02b59f152d Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Wed, 28 Jun 2023 14:59:49 -0400 Subject: [PATCH 03/16] deprecate: add deprecation warnings to old parameter calls --- src/autora/workflow/state/param.py | 36 ++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 48486f4e..9e80e056 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -3,15 +3,19 @@ import copy import logging +from functools import partial from typing import Dict, Mapping import numpy as np +from autora.utils.deprecation import deprecate as deprecate_ from autora.utils.dictionary import LazyDict from ..protocol import SupportsControllerState _logger = logging.getLogger(__name__) +deprecate = partial(deprecate_, callback=_logger.warning) + def _get_state_dependent_properties(state: SupportsControllerState): """ @@ -37,23 +41,31 @@ def _get_state_dependent_properties(state: SupportsControllerState): n_dvs = len(state.variables.dependent_variables) state_dependent_property_dict = LazyDict( { - "%observations.ivs[-1]%": lambda: np.array(state.observations[-1])[ - :, 0:n_ivs - ], - "%observations.dvs[-1]%": lambda: np.array(state.observations[-1])[ - :, n_ivs: - ], - "%observations.ivs%": lambda: np.row_stack( - [np.empty([0, n_ivs + n_dvs])] + list(state.observations) - )[:, 0:n_ivs], - "%observations.dvs%": lambda: np.row_stack(state.observations)[:, n_ivs:], + "%observations.ivs[-1]%": deprecate( + lambda: np.array(state.observations[-1])[:, 0:n_ivs], + "%observations.ivs[-1]% is deprecated, use %data.conditions[-1]% instead.", + ), + "%observations.dvs[-1]%": deprecate( + lambda: np.array(state.observations[-1])[:, n_ivs:], + "%observations.dvs[-1]% is deprecated, use %data.observations[-1]% instead.", + ), + "%observations.ivs%": deprecate( + lambda: np.row_stack( + [np.empty([0, n_ivs + n_dvs])] + list(state.observations) + )[:, 0:n_ivs], + "%observations.ivs% is deprecated, use %data.conditions% instead.", + ), + "%observations.dvs%": deprecate( + lambda: np.row_stack(state.observations)[:, n_ivs:], + "%observations.dvs% is deprecated, " "use %data.observations% instead", + ), "%data.conditions[-1]%": lambda: np.array(state.observations[-1])[ :, 0:n_ivs ], - "%observations.observations[-1]%": lambda: np.array(state.observations[-1])[ + "%data.observations[-1]%": lambda: np.array(state.observations[-1])[ :, n_ivs: ], - "%observations.conditions%": lambda: np.row_stack( + "%data.conditions%": lambda: np.row_stack( [np.empty([0, n_ivs + n_dvs])] + list(state.observations) )[:, 0:n_ivs], "%data.observations%": lambda: np.row_stack(state.observations)[:, n_ivs:], From 4788178037a16e886f33c6f3fb9ed24daac5b3dc Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 3 Jul 2023 10:22:08 -0400 Subject: [PATCH 04/16] refactor: use new version of autora core with updated deprecation function --- pyproject.toml | 2 +- src/autora/workflow/state/param.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 77f6135b..5bf3498b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "docs/index.md" license = { text = "MIT License" } dependencies = [ - "autora-core>=3.2.0a1", + "autora-core>=3.2.0", "scikit-learn", "matplotlib", "pandas", diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 9e80e056..286de698 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -3,19 +3,16 @@ import copy import logging -from functools import partial from typing import Dict, Mapping import numpy as np -from autora.utils.deprecation import deprecate as deprecate_ +from autora.utils.deprecation import deprecate as deprecate from autora.utils.dictionary import LazyDict from ..protocol import SupportsControllerState _logger = logging.getLogger(__name__) -deprecate = partial(deprecate_, callback=_logger.warning) - def _get_state_dependent_properties(state: SupportsControllerState): """ From 6cb861fab8bf25f387ec8651b49871a1562dece4 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 3 Jul 2023 10:26:39 -0400 Subject: [PATCH 05/16] test: update tests --- src/autora/workflow/state/param.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 286de698..fa8a82a7 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -30,7 +30,8 @@ def _get_state_dependent_properties(state: SupportsControllerState): Nevertheless, we can iterate through its keys no problem: >>> [key for key in state_dependent_properties.keys()] # doctest: +NORMALIZE_WHITESPACE ['%observations.ivs[-1]%', '%observations.dvs[-1]%', '%observations.ivs%', - '%observations.dvs%', '%models[-1]%', '%models%'] + '%observations.dvs%', '%data.conditions[-1]%', '%data.observations[-1]%', + '%data.conditions%', '%data.observations%', '%models[-1]%', '%models%'] """ From 6838df87bcd08da6911c94755fa267c7f0698707 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Wed, 5 Jul 2023 10:18:15 -0400 Subject: [PATCH 06/16] refactor: rename data -> experiment_data --- src/autora/workflow/state/param.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index fa8a82a7..81fdf759 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -57,16 +57,18 @@ def _get_state_dependent_properties(state: SupportsControllerState): lambda: np.row_stack(state.observations)[:, n_ivs:], "%observations.dvs% is deprecated, " "use %data.observations% instead", ), - "%data.conditions[-1]%": lambda: np.array(state.observations[-1])[ - :, 0:n_ivs - ], - "%data.observations[-1]%": lambda: np.array(state.observations[-1])[ - :, n_ivs: - ], - "%data.conditions%": lambda: np.row_stack( + "%experiment_data.conditions[-1]%": lambda: np.array( + state.observations[-1] + )[:, 0:n_ivs], + "%experiment_data.observations[-1]%": lambda: np.array( + state.observations[-1] + )[:, n_ivs:], + "%experiment_data.conditions%": lambda: np.row_stack( [np.empty([0, n_ivs + n_dvs])] + list(state.observations) )[:, 0:n_ivs], - "%data.observations%": lambda: np.row_stack(state.observations)[:, n_ivs:], + "%experiment_data.observations%": lambda: np.row_stack(state.observations)[ + :, n_ivs: + ], "%models[-1]%": lambda: state.models[-1], "%models%": lambda: state.models, } From 8419dd4250bf0d3bf645b7ad3a482326d4e007c9 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Wed, 5 Jul 2023 10:24:15 -0400 Subject: [PATCH 07/16] test: update test results --- src/autora/workflow/state/param.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 81fdf759..08b8750c 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -30,8 +30,9 @@ def _get_state_dependent_properties(state: SupportsControllerState): Nevertheless, we can iterate through its keys no problem: >>> [key for key in state_dependent_properties.keys()] # doctest: +NORMALIZE_WHITESPACE ['%observations.ivs[-1]%', '%observations.dvs[-1]%', '%observations.ivs%', - '%observations.dvs%', '%data.conditions[-1]%', '%data.observations[-1]%', - '%data.conditions%', '%data.observations%', '%models[-1]%', '%models%'] + '%observations.dvs%', '%experiment_data.conditions[-1]%', + '%experiment_data.observations[-1]%', '%experiment_data.conditions%', + '%experiment_data.observations%', '%models[-1]%', '%models%'] """ From 2b5ed10643b591f8eaf6b6f2baef674a720846ac Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Wed, 5 Jul 2023 10:48:21 -0400 Subject: [PATCH 08/16] refactor: rename data -> experiment_data --- ...Accessing State Dependent Properties.ipynb | 104 ++++++++++++++++-- 1 file changed, 96 insertions(+), 8 deletions(-) diff --git a/docs/interactive/Accessing State Dependent Properties.ipynb b/docs/interactive/Accessing State Dependent Properties.ipynb index 8e8f0210..f56f9c8a 100644 --- a/docs/interactive/Accessing State Dependent Properties.ipynb +++ b/docs/interactive/Accessing State Dependent Properties.ipynb @@ -15,11 +15,11 @@ "dictionary. These are the following strings, which will be replaced during execution by\n", "their respective current values:\n", "\n", - "- `\"%observations.ivs[-1]%\"`: the last observed independent variables\n", - "- `\"%observations.dvs[-1]%\"`: the last observed dependent variables\n", - "- `\"%observations.ivs%\"`: all the observed independent variables,\n", + "- `\"%experiment_data.conditions[-1]%\"`: the last observed independent variables\n", + "- `\"%experiment_data.observations[-1]%\"`: the last observed dependent variables\n", + "- `\"%experiment_data.conditions%\"`: all the observed independent variables,\n", "concatenated into a single array\n", - "- `\"%observations.dvs%\"`: all the observed dependent variables,\n", + "- `\"%experiment_data.observations%\"`: all the observed dependent variables,\n", "concatenated into a single array\n", "- `\"%models[-1]%\"`: the last fitted theorist\n", "- `\"%models%\"`: all the fitted theorists\n", @@ -251,9 +251,9 @@ "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/cycle.py:82\u001B[0m, in \u001B[0;36mCycle.run\u001B[0;34m(self, num_cycles)\u001B[0m\n\u001B[1;32m 80\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mrun\u001B[39m(\u001B[38;5;28mself\u001B[39m, num_cycles: \u001B[38;5;28mint\u001B[39m \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m1\u001B[39m):\n\u001B[1;32m 81\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Execute the next step in the cycle.\"\"\"\u001B[39;00m\n\u001B[0;32m---> 82\u001B[0m \u001B[38;5;28;43msuper\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun\u001B[49m\u001B[43m(\u001B[49m\u001B[43mnum_steps\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnum_cycles\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 83\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\n", "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:85\u001B[0m, in \u001B[0;36mBaseController.run\u001B[0;34m(self, num_steps)\u001B[0m\n\u001B[1;32m 83\u001B[0m \u001B[38;5;250m\u001B[39m\u001B[38;5;124;03m\"\"\"Run the next num_steps planned steps in the workflow.\"\"\"\u001B[39;00m\n\u001B[1;32m 84\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m i \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mrange\u001B[39m(num_steps):\n\u001B[0;32m---> 85\u001B[0m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun_once\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 86\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\n", "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:71\u001B[0m, in \u001B[0;36mBaseController.run_once\u001B[0;34m(self, step_name)\u001B[0m\n\u001B[1;32m 68\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mnext_params\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 70\u001B[0m \u001B[38;5;66;03m# Execute\u001B[39;00m\n\u001B[0;32m---> 71\u001B[0m result \u001B[38;5;241m=\u001B[39m \u001B[43mnext_function\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mparams\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnext_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 72\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mresult\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 74\u001B[0m \u001B[38;5;66;03m# Update\u001B[39;00m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:174\u001B[0m, in \u001B[0;36mfull_cycle_wrapper.._executor_full_cycle\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 169\u001B[0m experimentalist_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperimentalist\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 171\u001B[0m experimentalist_executor \u001B[38;5;241m=\u001B[39m from_experimentalist_pipeline(\n\u001B[1;32m 172\u001B[0m experimentalist_pipeline\n\u001B[1;32m 173\u001B[0m )\n\u001B[0;32m--> 174\u001B[0m experimentalist_result \u001B[38;5;241m=\u001B[39m \u001B[43mexperimentalist_executor\u001B[49m\u001B[43m(\u001B[49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexperimentalist_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 176\u001B[0m experiment_runner_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperiment_runner\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 177\u001B[0m experiment_runner_executor \u001B[38;5;241m=\u001B[39m from_experiment_runner_callable(\n\u001B[1;32m 178\u001B[0m experiment_runner_callable\n\u001B[1;32m 179\u001B[0m )\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:64\u001B[0m, in \u001B[0;36mfrom_experimentalist_pipeline.._executor_experimentalist\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 62\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_executor_experimentalist\u001B[39m(state: SupportsControllerState, params: Dict):\n\u001B[1;32m 63\u001B[0m params_ \u001B[38;5;241m=\u001B[39m resolve_state_params(params, state)\n\u001B[0;32m---> 64\u001B[0m new_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mpipeline\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mparams_\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 66\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(new_conditions, pd\u001B[38;5;241m.\u001B[39mDataFrame):\n\u001B[1;32m 67\u001B[0m new_conditions_array \u001B[38;5;241m=\u001B[39m new_conditions\n", - "File \u001B[0;32m~/Developer/autora-workflow/venv/lib/python3.10/site-packages/autora/experimentalist/pipeline.py:171\u001B[0m, in \u001B[0;36mPipeline.__call__\u001B[0;34m(self, ex, **params)\u001B[0m\n\u001B[1;32m 169\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(pipe, Pipe)\n\u001B[1;32m 170\u001B[0m all_params_for_pipe \u001B[38;5;241m=\u001B[39m merged_params\u001B[38;5;241m.\u001B[39mget(name, \u001B[38;5;28mdict\u001B[39m())\n\u001B[0;32m--> 171\u001B[0m results\u001B[38;5;241m.\u001B[39mappend(\u001B[43mpipe\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresults\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;241;43m-\u001B[39;49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mall_params_for_pipe\u001B[49m\u001B[43m)\u001B[49m)\n\u001B[1;32m 173\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m results[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m]\n", + "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:176\u001B[0m, in \u001B[0;36mfull_cycle_wrapper.._executor_full_cycle\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 171\u001B[0m experimentalist_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperimentalist\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 173\u001B[0m experimentalist_executor \u001B[38;5;241m=\u001B[39m from_experimentalist_pipeline(\n\u001B[1;32m 174\u001B[0m experimentalist_pipeline\n\u001B[1;32m 175\u001B[0m )\n\u001B[0;32m--> 176\u001B[0m experimentalist_result \u001B[38;5;241m=\u001B[39m \u001B[43mexperimentalist_executor\u001B[49m\u001B[43m(\u001B[49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexperimentalist_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 178\u001B[0m experiment_runner_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperiment_runner\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 179\u001B[0m experiment_runner_executor \u001B[38;5;241m=\u001B[39m from_experiment_runner_callable(\n\u001B[1;32m 180\u001B[0m experiment_runner_callable\n\u001B[1;32m 181\u001B[0m )\n", + "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:66\u001B[0m, in \u001B[0;36mfrom_experimentalist_pipeline.._executor_experimentalist\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 64\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_executor_experimentalist\u001B[39m(state: SupportsControllerState, params: Dict):\n\u001B[1;32m 65\u001B[0m params_ \u001B[38;5;241m=\u001B[39m resolve_state_params(params, state)\n\u001B[0;32m---> 66\u001B[0m new_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mpipeline\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mparams_\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 68\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(new_conditions, pd\u001B[38;5;241m.\u001B[39mDataFrame):\n\u001B[1;32m 69\u001B[0m new_conditions_array \u001B[38;5;241m=\u001B[39m new_conditions\n", + "File \u001B[0;32m~/Developer/autora-workflow/.venv/lib/python3.8/site-packages/autora/experimentalist/pipeline.py:171\u001B[0m, in \u001B[0;36mPipeline.__call__\u001B[0;34m(self, ex, **params)\u001B[0m\n\u001B[1;32m 169\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(pipe, Pipe)\n\u001B[1;32m 170\u001B[0m all_params_for_pipe \u001B[38;5;241m=\u001B[39m merged_params\u001B[38;5;241m.\u001B[39mget(name, \u001B[38;5;28mdict\u001B[39m())\n\u001B[0;32m--> 171\u001B[0m results\u001B[38;5;241m.\u001B[39mappend(\u001B[43mpipe\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresults\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;241;43m-\u001B[39;49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mall_params_for_pipe\u001B[49m\u001B[43m)\u001B[49m)\n\u001B[1;32m 173\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m results[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m]\n", "Cell \u001B[0;32mIn[2], line 9\u001B[0m, in \u001B[0;36mcustom_random_sampler\u001B[0;34m(conditions, n)\u001B[0m\n\u001B[1;32m 8\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mcustom_random_sampler\u001B[39m(conditions, n):\n\u001B[0;32m----> 9\u001B[0m sampled_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mrandom_sampler_rng\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mchoice\u001B[49m\u001B[43m(\u001B[49m\u001B[43mconditions\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msize\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mn\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mreplace\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mFalse\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[1;32m 10\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m sampled_conditions\n", "File \u001B[0;32m_generator.pyx:729\u001B[0m, in \u001B[0;36mnumpy.random._generator.Generator.choice\u001B[0;34m()\u001B[0m\n", "\u001B[0;31mValueError\u001B[0m: a cannot be empty unless no samples are taken" @@ -268,7 +268,95 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
x
02
16
25
37
43
54
69
70
88
91
\n", + "
" + ], + "text/plain": [ + " x\n", + "0 2\n", + "1 6\n", + "2 5\n", + "3 7\n", + "4 3\n", + "5 4\n", + "6 9\n", + "7 0\n", + "8 8\n", + "9 1" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pd.concat(cycle_with_state_dep_properties.data.conditions, ignore_index=True)\n" ] From d0f723612bce4310273fe95686c16eaf5c08af0c Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 08:42:17 -0400 Subject: [PATCH 09/16] chore: clear outputs --- ...Accessing State Dependent Properties.ipynb | 238 +++--------------- 1 file changed, 32 insertions(+), 206 deletions(-) diff --git a/docs/interactive/Accessing State Dependent Properties.ipynb b/docs/interactive/Accessing State Dependent Properties.ipynb index f56f9c8a..a2cdb7a3 100644 --- a/docs/interactive/Accessing State Dependent Properties.ipynb +++ b/docs/interactive/Accessing State Dependent Properties.ipynb @@ -31,8 +31,13 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, + "execution_count": 1, + "metadata": { + "ExecuteTime": { + "end_time": "2023-07-06T12:42:15.612743Z", + "start_time": "2023-07-06T12:42:15.592917Z" + } + }, "outputs": [], "source": [ "# Uncomment the following line when running on Google Colab\n", @@ -42,7 +47,12 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "is_executing": true, + "ExecuteTime": { + "start_time": "2023-07-06T12:42:15.597105Z" + } + }, "outputs": [], "source": [ "import numpy as np\n", @@ -58,7 +68,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "is_executing": true + }, "outputs": [], "source": [ "def ground_truth(x):\n", @@ -119,51 +131,10 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
x
02
\n", - "
" - ], - "text/plain": [ - " x\n", - "0 2" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "metadata": { + "is_executing": true + }, + "outputs": [], "source": [ "cycle_with_state_dep_properties.run().data.conditions[-1]" ] @@ -178,51 +149,10 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
x
01
\n", - "
" - ], - "text/plain": [ - " x\n", - "0 1" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "metadata": { + "is_executing": true + }, + "outputs": [], "source": [ "cycle_with_state_dep_properties.run(num_cycles=9).data.conditions[-1]" ] @@ -238,28 +168,10 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [ - { - "ename": "ValueError", - "evalue": "a cannot be empty unless no samples are taken", - "output_type": "error", - "traceback": [ - "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", - "\u001B[0;31mValueError\u001B[0m Traceback (most recent call last)", - "Cell \u001B[0;32mIn[5], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mcycle_with_state_dep_properties\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m \u001B[38;5;66;03m# doctest: +ELLIPSIS\u001B[39;00m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/cycle.py:82\u001B[0m, in \u001B[0;36mCycle.run\u001B[0;34m(self, num_cycles)\u001B[0m\n\u001B[1;32m 80\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mrun\u001B[39m(\u001B[38;5;28mself\u001B[39m, num_cycles: \u001B[38;5;28mint\u001B[39m \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m1\u001B[39m):\n\u001B[1;32m 81\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Execute the next step in the cycle.\"\"\"\u001B[39;00m\n\u001B[0;32m---> 82\u001B[0m \u001B[38;5;28;43msuper\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun\u001B[49m\u001B[43m(\u001B[49m\u001B[43mnum_steps\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnum_cycles\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 83\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:85\u001B[0m, in \u001B[0;36mBaseController.run\u001B[0;34m(self, num_steps)\u001B[0m\n\u001B[1;32m 83\u001B[0m \u001B[38;5;250m\u001B[39m\u001B[38;5;124;03m\"\"\"Run the next num_steps planned steps in the workflow.\"\"\"\u001B[39;00m\n\u001B[1;32m 84\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m i \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28mrange\u001B[39m(num_steps):\n\u001B[0;32m---> 85\u001B[0m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun_once\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 86\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:71\u001B[0m, in \u001B[0;36mBaseController.run_once\u001B[0;34m(self, step_name)\u001B[0m\n\u001B[1;32m 68\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mnext_params\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 70\u001B[0m \u001B[38;5;66;03m# Execute\u001B[39;00m\n\u001B[0;32m---> 71\u001B[0m result \u001B[38;5;241m=\u001B[39m \u001B[43mnext_function\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mparams\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnext_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 72\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mresult\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 74\u001B[0m \u001B[38;5;66;03m# Update\u001B[39;00m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:176\u001B[0m, in \u001B[0;36mfull_cycle_wrapper.._executor_full_cycle\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 171\u001B[0m experimentalist_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperimentalist\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 173\u001B[0m experimentalist_executor \u001B[38;5;241m=\u001B[39m from_experimentalist_pipeline(\n\u001B[1;32m 174\u001B[0m experimentalist_pipeline\n\u001B[1;32m 175\u001B[0m )\n\u001B[0;32m--> 176\u001B[0m experimentalist_result \u001B[38;5;241m=\u001B[39m \u001B[43mexperimentalist_executor\u001B[49m\u001B[43m(\u001B[49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexperimentalist_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 178\u001B[0m experiment_runner_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperiment_runner\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 179\u001B[0m experiment_runner_executor \u001B[38;5;241m=\u001B[39m from_experiment_runner_callable(\n\u001B[1;32m 180\u001B[0m experiment_runner_callable\n\u001B[1;32m 181\u001B[0m )\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:66\u001B[0m, in \u001B[0;36mfrom_experimentalist_pipeline.._executor_experimentalist\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 64\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_executor_experimentalist\u001B[39m(state: SupportsControllerState, params: Dict):\n\u001B[1;32m 65\u001B[0m params_ \u001B[38;5;241m=\u001B[39m resolve_state_params(params, state)\n\u001B[0;32m---> 66\u001B[0m new_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mpipeline\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mparams_\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 68\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(new_conditions, pd\u001B[38;5;241m.\u001B[39mDataFrame):\n\u001B[1;32m 69\u001B[0m new_conditions_array \u001B[38;5;241m=\u001B[39m new_conditions\n", - "File \u001B[0;32m~/Developer/autora-workflow/.venv/lib/python3.8/site-packages/autora/experimentalist/pipeline.py:171\u001B[0m, in \u001B[0;36mPipeline.__call__\u001B[0;34m(self, ex, **params)\u001B[0m\n\u001B[1;32m 169\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(pipe, Pipe)\n\u001B[1;32m 170\u001B[0m all_params_for_pipe \u001B[38;5;241m=\u001B[39m merged_params\u001B[38;5;241m.\u001B[39mget(name, \u001B[38;5;28mdict\u001B[39m())\n\u001B[0;32m--> 171\u001B[0m results\u001B[38;5;241m.\u001B[39mappend(\u001B[43mpipe\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresults\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;241;43m-\u001B[39;49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mall_params_for_pipe\u001B[49m\u001B[43m)\u001B[49m)\n\u001B[1;32m 173\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m results[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m]\n", - "Cell \u001B[0;32mIn[2], line 9\u001B[0m, in \u001B[0;36mcustom_random_sampler\u001B[0;34m(conditions, n)\u001B[0m\n\u001B[1;32m 8\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mcustom_random_sampler\u001B[39m(conditions, n):\n\u001B[0;32m----> 9\u001B[0m sampled_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mrandom_sampler_rng\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mchoice\u001B[49m\u001B[43m(\u001B[49m\u001B[43mconditions\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msize\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mn\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mreplace\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mFalse\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[1;32m 10\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m sampled_conditions\n", - "File \u001B[0;32m_generator.pyx:729\u001B[0m, in \u001B[0;36mnumpy.random._generator.Generator.choice\u001B[0;34m()\u001B[0m\n", - "\u001B[0;31mValueError\u001B[0m: a cannot be empty unless no samples are taken" - ] - } - ], + "metadata": { + "is_executing": true + }, + "outputs": [], "source": [ "cycle_with_state_dep_properties.run() # doctest: +ELLIPSIS" ] @@ -267,96 +179,10 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
x
02
16
25
37
43
54
69
70
88
91
\n", - "
" - ], - "text/plain": [ - " x\n", - "0 2\n", - "1 6\n", - "2 5\n", - "3 7\n", - "4 3\n", - "5 4\n", - "6 9\n", - "7 0\n", - "8 8\n", - "9 1" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "metadata": { + "is_executing": true + }, + "outputs": [], "source": [ "pd.concat(cycle_with_state_dep_properties.data.conditions, ignore_index=True)\n" ] From 40c9eb8700969e5dfd30e285da5852ac69f79b08 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 08:42:32 -0400 Subject: [PATCH 10/16] chore: clear outputs --- ...Accessing State Dependent Properties.ipynb | 187 +++++++++++++++--- 1 file changed, 156 insertions(+), 31 deletions(-) diff --git a/docs/interactive/Accessing State Dependent Properties.ipynb b/docs/interactive/Accessing State Dependent Properties.ipynb index a2cdb7a3..e3b0d3d4 100644 --- a/docs/interactive/Accessing State Dependent Properties.ipynb +++ b/docs/interactive/Accessing State Dependent Properties.ipynb @@ -31,13 +31,8 @@ }, { "cell_type": "code", - "execution_count": 1, - "metadata": { - "ExecuteTime": { - "end_time": "2023-07-06T12:42:15.612743Z", - "start_time": "2023-07-06T12:42:15.592917Z" - } - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "# Uncomment the following line when running on Google Colab\n", @@ -47,12 +42,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "is_executing": true, - "ExecuteTime": { - "start_time": "2023-07-06T12:42:15.597105Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", @@ -68,9 +58,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "is_executing": true - }, + "metadata": {}, "outputs": [], "source": [ "def ground_truth(x):\n", @@ -131,10 +119,59 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "is_executing": true - }, - "outputs": [], + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
x
02
\n", + "
" + ], + "text/plain": [ + " x\n", + "0 2" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "cycle_with_state_dep_properties.run().data.conditions[-1]" ] @@ -149,10 +186,75 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "is_executing": true - }, - "outputs": [], + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
x
01
\n", + "
" + ], + "text/plain": [ + " x\n", + "0 1" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "cycle_with_state_dep_properties.run(num_cycles=9).data.conditions[-1]" ] @@ -168,10 +270,35 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "is_executing": true - }, - "outputs": [], + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "%observations.ivs% is deprecated, use %data.conditions% instead.\n", + "%observations.ivs% is deprecated, use %data.conditions% instead.\n" + ] + }, + { + "ename": "ValueError", + "evalue": "a cannot be empty unless no samples are taken", + "output_type": "error", + "traceback": [ + "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[0;31mValueError\u001B[0m Traceback (most recent call last)", + "Cell \u001B[0;32mIn[6], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;43mnext\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43mcycle_with_state_dep_properties\u001B[49m\u001B[43m)\u001B[49m\n", + "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:90\u001B[0m, in \u001B[0;36mBaseController.__next__\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m 88\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m__next__\u001B[39m(\u001B[38;5;28mself\u001B[39m):\n\u001B[1;32m 89\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Run the next planned step in the workflow.\"\"\"\u001B[39;00m\n\u001B[0;32m---> 90\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun_once\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n", + "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:71\u001B[0m, in \u001B[0;36mBaseController.run_once\u001B[0;34m(self, step_name)\u001B[0m\n\u001B[1;32m 68\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mnext_params\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 70\u001B[0m \u001B[38;5;66;03m# Execute\u001B[39;00m\n\u001B[0;32m---> 71\u001B[0m result \u001B[38;5;241m=\u001B[39m \u001B[43mnext_function\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mparams\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnext_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 72\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mresult\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 74\u001B[0m \u001B[38;5;66;03m# Update\u001B[39;00m\n", + "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:174\u001B[0m, in \u001B[0;36mfull_cycle_wrapper.._executor_full_cycle\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 169\u001B[0m experimentalist_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperimentalist\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 171\u001B[0m experimentalist_executor \u001B[38;5;241m=\u001B[39m from_experimentalist_pipeline(\n\u001B[1;32m 172\u001B[0m experimentalist_pipeline\n\u001B[1;32m 173\u001B[0m )\n\u001B[0;32m--> 174\u001B[0m experimentalist_result \u001B[38;5;241m=\u001B[39m \u001B[43mexperimentalist_executor\u001B[49m\u001B[43m(\u001B[49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexperimentalist_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 176\u001B[0m experiment_runner_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperiment_runner\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 177\u001B[0m experiment_runner_executor \u001B[38;5;241m=\u001B[39m from_experiment_runner_callable(\n\u001B[1;32m 178\u001B[0m experiment_runner_callable\n\u001B[1;32m 179\u001B[0m )\n", + "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:64\u001B[0m, in \u001B[0;36mfrom_experimentalist_pipeline.._executor_experimentalist\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 62\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_executor_experimentalist\u001B[39m(state: SupportsControllerState, params: Dict):\n\u001B[1;32m 63\u001B[0m params_ \u001B[38;5;241m=\u001B[39m resolve_state_params(params, state)\n\u001B[0;32m---> 64\u001B[0m new_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mpipeline\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mparams_\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 66\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(new_conditions, pd\u001B[38;5;241m.\u001B[39mDataFrame):\n\u001B[1;32m 67\u001B[0m new_conditions_array \u001B[38;5;241m=\u001B[39m new_conditions\n", + "File \u001B[0;32m~/Developer/autora-workflow/.venv/lib/python3.8/site-packages/autora/experimentalist/pipeline.py:171\u001B[0m, in \u001B[0;36mPipeline.__call__\u001B[0;34m(self, ex, **params)\u001B[0m\n\u001B[1;32m 169\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(pipe, Pipe)\n\u001B[1;32m 170\u001B[0m all_params_for_pipe \u001B[38;5;241m=\u001B[39m merged_params\u001B[38;5;241m.\u001B[39mget(name, \u001B[38;5;28mdict\u001B[39m())\n\u001B[0;32m--> 171\u001B[0m results\u001B[38;5;241m.\u001B[39mappend(\u001B[43mpipe\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresults\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;241;43m-\u001B[39;49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mall_params_for_pipe\u001B[49m\u001B[43m)\u001B[49m)\n\u001B[1;32m 173\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m results[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m]\n", + "Cell \u001B[0;32mIn[3], line 9\u001B[0m, in \u001B[0;36mcustom_random_sampler\u001B[0;34m(conditions, n)\u001B[0m\n\u001B[1;32m 8\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mcustom_random_sampler\u001B[39m(conditions, n):\n\u001B[0;32m----> 9\u001B[0m sampled_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mrandom_sampler_rng\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mchoice\u001B[49m\u001B[43m(\u001B[49m\u001B[43mconditions\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msize\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mn\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mreplace\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mFalse\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[1;32m 10\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m sampled_conditions\n", + "File \u001B[0;32m_generator.pyx:729\u001B[0m, in \u001B[0;36mnumpy.random._generator.Generator.choice\u001B[0;34m()\u001B[0m\n", + "\u001B[0;31mValueError\u001B[0m: a cannot be empty unless no samples are taken" + ] + } + ], "source": [ "cycle_with_state_dep_properties.run() # doctest: +ELLIPSIS" ] @@ -179,9 +306,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "is_executing": true - }, + "metadata": {}, "outputs": [], "source": [ "pd.concat(cycle_with_state_dep_properties.data.conditions, ignore_index=True)\n" From 06bf62059c12b1d0a7d4340b61e880646a0e9784 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 09:32:45 -0400 Subject: [PATCH 11/16] docs: update examples of using state dependent properties --- ...Accessing State Dependent Properties.ipynb | 169 +----------------- 1 file changed, 4 insertions(+), 165 deletions(-) diff --git a/docs/interactive/Accessing State Dependent Properties.ipynb b/docs/interactive/Accessing State Dependent Properties.ipynb index e3b0d3d4..24f4c612 100644 --- a/docs/interactive/Accessing State Dependent Properties.ipynb +++ b/docs/interactive/Accessing State Dependent Properties.ipynb @@ -101,7 +101,7 @@ " experiment_runner=example_synthetic_experiment_runner,\n", " params={\n", " \"experimentalist\": {\n", - " \"exclude_conditions\": {\"excluded_conditions\": \"%observations.ivs%\"},\n", + " \"exclude_conditions\": {\"excluded_conditions\": \"%experiment_data.conditions%\"},\n", " \"custom_random_sampler\": {\"n\": 1}\n", " }\n", " }\n", @@ -120,58 +120,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
x
02
\n", - "
" - ], - "text/plain": [ - " x\n", - "0 2" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "cycle_with_state_dep_properties.run().data.conditions[-1]" ] @@ -187,74 +136,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
x
01
\n", - "
" - ], - "text/plain": [ - " x\n", - "0 1" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "cycle_with_state_dep_properties.run(num_cycles=9).data.conditions[-1]" ] @@ -267,57 +149,14 @@ "conditions which are available:" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "%observations.ivs% is deprecated, use %data.conditions% instead.\n", - "%observations.ivs% is deprecated, use %data.conditions% instead.\n" - ] - }, - { - "ename": "ValueError", - "evalue": "a cannot be empty unless no samples are taken", - "output_type": "error", - "traceback": [ - "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", - "\u001B[0;31mValueError\u001B[0m Traceback (most recent call last)", - "Cell \u001B[0;32mIn[6], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;43mnext\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43mcycle_with_state_dep_properties\u001B[49m\u001B[43m)\u001B[49m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:90\u001B[0m, in \u001B[0;36mBaseController.__next__\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m 88\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m__next__\u001B[39m(\u001B[38;5;28mself\u001B[39m):\n\u001B[1;32m 89\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Run the next planned step in the workflow.\"\"\"\u001B[39;00m\n\u001B[0;32m---> 90\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mrun_once\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:71\u001B[0m, in \u001B[0;36mBaseController.run_once\u001B[0;34m(self, step_name)\u001B[0m\n\u001B[1;32m 68\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mnext_params\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 70\u001B[0m \u001B[38;5;66;03m# Execute\u001B[39;00m\n\u001B[0;32m---> 71\u001B[0m result \u001B[38;5;241m=\u001B[39m \u001B[43mnext_function\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mparams\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnext_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 72\u001B[0m _logger\u001B[38;5;241m.\u001B[39mdebug(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mresult\u001B[38;5;132;01m=}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 74\u001B[0m \u001B[38;5;66;03m# Update\u001B[39;00m\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:174\u001B[0m, in \u001B[0;36mfull_cycle_wrapper.._executor_full_cycle\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 169\u001B[0m experimentalist_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperimentalist\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 171\u001B[0m experimentalist_executor \u001B[38;5;241m=\u001B[39m from_experimentalist_pipeline(\n\u001B[1;32m 172\u001B[0m experimentalist_pipeline\n\u001B[1;32m 173\u001B[0m )\n\u001B[0;32m--> 174\u001B[0m experimentalist_result \u001B[38;5;241m=\u001B[39m \u001B[43mexperimentalist_executor\u001B[49m\u001B[43m(\u001B[49m\u001B[43mstate\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexperimentalist_params\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 176\u001B[0m experiment_runner_params \u001B[38;5;241m=\u001B[39m params\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mexperiment_runner\u001B[39m\u001B[38;5;124m\"\u001B[39m, {})\n\u001B[1;32m 177\u001B[0m experiment_runner_executor \u001B[38;5;241m=\u001B[39m from_experiment_runner_callable(\n\u001B[1;32m 178\u001B[0m experiment_runner_callable\n\u001B[1;32m 179\u001B[0m )\n", - "File \u001B[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:64\u001B[0m, in \u001B[0;36mfrom_experimentalist_pipeline.._executor_experimentalist\u001B[0;34m(state, params)\u001B[0m\n\u001B[1;32m 62\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_executor_experimentalist\u001B[39m(state: SupportsControllerState, params: Dict):\n\u001B[1;32m 63\u001B[0m params_ \u001B[38;5;241m=\u001B[39m resolve_state_params(params, state)\n\u001B[0;32m---> 64\u001B[0m new_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mpipeline\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mparams_\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 66\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(new_conditions, pd\u001B[38;5;241m.\u001B[39mDataFrame):\n\u001B[1;32m 67\u001B[0m new_conditions_array \u001B[38;5;241m=\u001B[39m new_conditions\n", - "File \u001B[0;32m~/Developer/autora-workflow/.venv/lib/python3.8/site-packages/autora/experimentalist/pipeline.py:171\u001B[0m, in \u001B[0;36mPipeline.__call__\u001B[0;34m(self, ex, **params)\u001B[0m\n\u001B[1;32m 169\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(pipe, Pipe)\n\u001B[1;32m 170\u001B[0m all_params_for_pipe \u001B[38;5;241m=\u001B[39m merged_params\u001B[38;5;241m.\u001B[39mget(name, \u001B[38;5;28mdict\u001B[39m())\n\u001B[0;32m--> 171\u001B[0m results\u001B[38;5;241m.\u001B[39mappend(\u001B[43mpipe\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresults\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;241;43m-\u001B[39;49m\u001B[38;5;241;43m1\u001B[39;49m\u001B[43m]\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mall_params_for_pipe\u001B[49m\u001B[43m)\u001B[49m)\n\u001B[1;32m 173\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m results[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m]\n", - "Cell \u001B[0;32mIn[3], line 9\u001B[0m, in \u001B[0;36mcustom_random_sampler\u001B[0;34m(conditions, n)\u001B[0m\n\u001B[1;32m 8\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mcustom_random_sampler\u001B[39m(conditions, n):\n\u001B[0;32m----> 9\u001B[0m sampled_conditions \u001B[38;5;241m=\u001B[39m \u001B[43mrandom_sampler_rng\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mchoice\u001B[49m\u001B[43m(\u001B[49m\u001B[43mconditions\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43msize\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mn\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mreplace\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mFalse\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[1;32m 10\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m sampled_conditions\n", - "File \u001B[0;32m_generator.pyx:729\u001B[0m, in \u001B[0;36mnumpy.random._generator.Generator.choice\u001B[0;34m()\u001B[0m\n", - "\u001B[0;31mValueError\u001B[0m: a cannot be empty unless no samples are taken" - ] - } - ], - "source": [ - "cycle_with_state_dep_properties.run() # doctest: +ELLIPSIS" - ] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "pd.concat(cycle_with_state_dep_properties.data.conditions, ignore_index=True)\n" + "cycle_with_state_dep_properties.run()\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 6ca0d81c2b9cd6742511b419bf7f9ba2b5022c21 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 10:41:51 -0400 Subject: [PATCH 12/16] Update src/autora/workflow/state/param.py Co-authored-by: benwandrew --- src/autora/workflow/state/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 08b8750c..1317b069 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -46,7 +46,7 @@ def _get_state_dependent_properties(state: SupportsControllerState): ), "%observations.dvs[-1]%": deprecate( lambda: np.array(state.observations[-1])[:, n_ivs:], - "%observations.dvs[-1]% is deprecated, use %data.observations[-1]% instead.", + "%observations.dvs[-1]% is deprecated, use %experiment_data.observations[-1]% instead.", ), "%observations.ivs%": deprecate( lambda: np.row_stack( From 3fee0faf306b70c2ab4d68224b665aec21a86080 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 10:41:58 -0400 Subject: [PATCH 13/16] Update src/autora/workflow/state/param.py Co-authored-by: benwandrew --- src/autora/workflow/state/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 1317b069..de9b6f51 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -42,7 +42,7 @@ def _get_state_dependent_properties(state: SupportsControllerState): { "%observations.ivs[-1]%": deprecate( lambda: np.array(state.observations[-1])[:, 0:n_ivs], - "%observations.ivs[-1]% is deprecated, use %data.conditions[-1]% instead.", + "%observations.ivs[-1]% is deprecated, use %experiment_data.conditions[-1]% instead.", ), "%observations.dvs[-1]%": deprecate( lambda: np.array(state.observations[-1])[:, n_ivs:], From b537ec3f0b90d3fd7a46efed06174fd36761a69c Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 10:42:05 -0400 Subject: [PATCH 14/16] Update src/autora/workflow/state/param.py Co-authored-by: benwandrew --- src/autora/workflow/state/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index de9b6f51..43344748 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -52,7 +52,7 @@ def _get_state_dependent_properties(state: SupportsControllerState): lambda: np.row_stack( [np.empty([0, n_ivs + n_dvs])] + list(state.observations) )[:, 0:n_ivs], - "%observations.ivs% is deprecated, use %data.conditions% instead.", + "%observations.ivs% is deprecated, use %experiment_data.conditions% instead.", ), "%observations.dvs%": deprecate( lambda: np.row_stack(state.observations)[:, n_ivs:], From 36b4ed78414d49eb06a7364d840f4e4f339959b3 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 10:42:13 -0400 Subject: [PATCH 15/16] Update src/autora/workflow/state/param.py Co-authored-by: benwandrew --- src/autora/workflow/state/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 43344748..5637b52f 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -56,7 +56,7 @@ def _get_state_dependent_properties(state: SupportsControllerState): ), "%observations.dvs%": deprecate( lambda: np.row_stack(state.observations)[:, n_ivs:], - "%observations.dvs% is deprecated, " "use %data.observations% instead", + "%observations.dvs% is deprecated, " "use %experiment_data.observations% instead", ), "%experiment_data.conditions[-1]%": lambda: np.array( state.observations[-1] From b4e3c9aeab8f1cc9fca026cead76d631323ffb5b Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 6 Jul 2023 10:45:29 -0400 Subject: [PATCH 16/16] docs: update examples of using state dependent properties --- ...Accessing State Dependent Properties.ipynb | 119 +++++++++++++++++- 1 file changed, 116 insertions(+), 3 deletions(-) diff --git a/docs/interactive/Accessing State Dependent Properties.ipynb b/docs/interactive/Accessing State Dependent Properties.ipynb index 24f4c612..c5f715c1 100644 --- a/docs/interactive/Accessing State Dependent Properties.ipynb +++ b/docs/interactive/Accessing State Dependent Properties.ipynb @@ -120,7 +120,50 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
x
02
\n", + "
" + ], + "text/plain": [ + " x\n", + "0 2" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "cycle_with_state_dep_properties.run().data.conditions[-1]" ] @@ -136,7 +179,50 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
x
01
\n", + "
" + ], + "text/plain": [ + " x\n", + "0 1" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "cycle_with_state_dep_properties.run(num_cycles=9).data.conditions[-1]" ] @@ -153,10 +239,37 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "a cannot be empty unless no samples are taken", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[6], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mcycle_with_state_dep_properties\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/Developer/autora-workflow/src/autora/workflow/cycle.py:82\u001b[0m, in \u001b[0;36mCycle.run\u001b[0;34m(self, num_cycles)\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mrun\u001b[39m(\u001b[38;5;28mself\u001b[39m, num_cycles: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m):\n\u001b[1;32m 81\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Execute the next step in the cycle.\"\"\"\u001b[39;00m\n\u001b[0;32m---> 82\u001b[0m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnum_steps\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnum_cycles\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 83\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\n", + "File \u001b[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:85\u001b[0m, in \u001b[0;36mBaseController.run\u001b[0;34m(self, num_steps)\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Run the next num_steps planned steps in the workflow.\"\"\"\u001b[39;00m\n\u001b[1;32m 84\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(num_steps):\n\u001b[0;32m---> 85\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_once\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 86\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\n", + "File \u001b[0;32m~/Developer/autora-workflow/src/autora/workflow/base.py:71\u001b[0m, in \u001b[0;36mBaseController.run_once\u001b[0;34m(self, step_name)\u001b[0m\n\u001b[1;32m 68\u001b[0m _logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mnext_params\u001b[38;5;132;01m=}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 70\u001b[0m \u001b[38;5;66;03m# Execute\u001b[39;00m\n\u001b[0;32m---> 71\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mnext_function\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnext_params\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 72\u001b[0m _logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresult\u001b[38;5;132;01m=}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 74\u001b[0m \u001b[38;5;66;03m# Update\u001b[39;00m\n", + "File \u001b[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:174\u001b[0m, in \u001b[0;36mfull_cycle_wrapper.._executor_full_cycle\u001b[0;34m(state, params)\u001b[0m\n\u001b[1;32m 169\u001b[0m experimentalist_params \u001b[38;5;241m=\u001b[39m params\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexperimentalist\u001b[39m\u001b[38;5;124m\"\u001b[39m, {})\n\u001b[1;32m 171\u001b[0m experimentalist_executor \u001b[38;5;241m=\u001b[39m from_experimentalist_pipeline(\n\u001b[1;32m 172\u001b[0m experimentalist_pipeline\n\u001b[1;32m 173\u001b[0m )\n\u001b[0;32m--> 174\u001b[0m experimentalist_result \u001b[38;5;241m=\u001b[39m \u001b[43mexperimentalist_executor\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexperimentalist_params\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 176\u001b[0m experiment_runner_params \u001b[38;5;241m=\u001b[39m params\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mexperiment_runner\u001b[39m\u001b[38;5;124m\"\u001b[39m, {})\n\u001b[1;32m 177\u001b[0m experiment_runner_executor \u001b[38;5;241m=\u001b[39m from_experiment_runner_callable(\n\u001b[1;32m 178\u001b[0m experiment_runner_callable\n\u001b[1;32m 179\u001b[0m )\n", + "File \u001b[0;32m~/Developer/autora-workflow/src/autora/workflow/executor.py:64\u001b[0m, in \u001b[0;36mfrom_experimentalist_pipeline.._executor_experimentalist\u001b[0;34m(state, params)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_executor_experimentalist\u001b[39m(state: SupportsControllerState, params: Dict):\n\u001b[1;32m 63\u001b[0m params_ \u001b[38;5;241m=\u001b[39m resolve_state_params(params, state)\n\u001b[0;32m---> 64\u001b[0m new_conditions \u001b[38;5;241m=\u001b[39m \u001b[43mpipeline\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mparams_\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(new_conditions, pd\u001b[38;5;241m.\u001b[39mDataFrame):\n\u001b[1;32m 67\u001b[0m new_conditions_array \u001b[38;5;241m=\u001b[39m new_conditions\n", + "File \u001b[0;32m~/Developer/autora-workflow/.venv/lib/python3.8/site-packages/autora/experimentalist/pipeline.py:171\u001b[0m, in \u001b[0;36mPipeline.__call__\u001b[0;34m(self, ex, **params)\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(pipe, Pipe)\n\u001b[1;32m 170\u001b[0m all_params_for_pipe \u001b[38;5;241m=\u001b[39m merged_params\u001b[38;5;241m.\u001b[39mget(name, \u001b[38;5;28mdict\u001b[39m())\n\u001b[0;32m--> 171\u001b[0m results\u001b[38;5;241m.\u001b[39mappend(\u001b[43mpipe\u001b[49m\u001b[43m(\u001b[49m\u001b[43mresults\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mall_params_for_pipe\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m results[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n", + "Cell \u001b[0;32mIn[3], line 9\u001b[0m, in \u001b[0;36mcustom_random_sampler\u001b[0;34m(conditions, n)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcustom_random_sampler\u001b[39m(conditions, n):\n\u001b[0;32m----> 9\u001b[0m sampled_conditions \u001b[38;5;241m=\u001b[39m \u001b[43mrandom_sampler_rng\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mchoice\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconditions\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msize\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreplace\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m sampled_conditions\n", + "File \u001b[0;32m_generator.pyx:729\u001b[0m, in \u001b[0;36mnumpy.random._generator.Generator.choice\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mValueError\u001b[0m: a cannot be empty unless no samples are taken" + ] + } + ], "source": [ "cycle_with_state_dep_properties.run()\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {