diff --git a/docs/interactive/Accessing State Dependent Properties.ipynb b/docs/interactive/Accessing State Dependent Properties.ipynb index 8e8f0210..c5f715c1 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", @@ -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", @@ -245,32 +245,23 @@ "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: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", - "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" + "\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() # 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" ] }, { diff --git a/pyproject.toml b/pyproject.toml index e9c8a8c7..5bf3498b 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.0", "scikit-learn", "matplotlib", "pandas", diff --git a/src/autora/workflow/state/param.py b/src/autora/workflow/state/param.py index 42c739b6..5637b52f 100644 --- a/src/autora/workflow/state/param.py +++ b/src/autora/workflow/state/param.py @@ -6,6 +6,7 @@ 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 @@ -29,7 +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%', '%models[-1]%', '%models%'] + '%observations.dvs%', '%experiment_data.conditions[-1]%', + '%experiment_data.observations[-1]%', '%experiment_data.conditions%', + '%experiment_data.observations%', '%models[-1]%', '%models%'] """ @@ -37,16 +40,36 @@ 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( + "%observations.ivs[-1]%": deprecate( + lambda: np.array(state.observations[-1])[:, 0:n_ivs], + "%observations.ivs[-1]% is deprecated, use %experiment_data.conditions[-1]% instead.", + ), + "%observations.dvs[-1]%": deprecate( + lambda: np.array(state.observations[-1])[:, n_ivs:], + "%observations.dvs[-1]% is deprecated, use %experiment_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 %experiment_data.conditions% instead.", + ), + "%observations.dvs%": deprecate( + lambda: np.row_stack(state.observations)[:, n_ivs:], + "%observations.dvs% is deprecated, " "use %experiment_data.observations% instead", + ), + "%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], - "%observations.dvs%": 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, }