{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [ "remove-cell" ] }, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "from myst_nb import glue" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# The basics" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Before anything else, let's import the classes we need:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "try:\n", " from respace import ResultSet\n", "except ImportError:\n", " !pip install respace\n", " from respace import ResultSet" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## The ResultSet class" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Now let's build the simplest possible {class}`~respace.ResultSet`: it contains only one\n", "result `\"result\"` that depends on a single parameter `\"parameter\"`. And let's make it\n", "verbose, so we see more of what's going on:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.Dataset>\n",
       "Dimensions:    (parameter: 1)\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1\n",
       "Data variables:\n",
       "    result     (parameter) int64 -1
" ], "text/plain": [ "\n", "Dimensions: (parameter: 1)\n", "Coordinates:\n", " * parameter (parameter) int64 1\n", "Data variables:\n", " result (parameter) int64 -1" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def add_one(parameter): return parameter + 1\n", "rs = ResultSet({\"result\": add_one}, {\"parameter\": 1}, verbose=True)\n", "rs" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Here you can see what's displayed is an {class}`xarray.Dataset` instance, which is a\n", "representation of your parameter space (the {attr}`~respace.ResultSet.param_space`\n", "attribute of `rs`). You can see all the data you've entered in there, except `add_one`,\n", "the computing function[^actually-in-res-attr]. So where is it? Let's select the result\n", "and see what we got:\n", "\n", "[^actually-in-res-attr]: Users familiar with `xarray` may know it can already be seen by\n", " expanding \"result\"'s attributes, but here we don't assume any prior knowledge of\n", " `xarray`, and anyway that's a nice way to introduce the `__getitem__` behaviour." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 1)>\n",
       "array([-1])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       []\n",
       "    compute_times:         []\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([-1])\n", "Coordinates:\n", " * parameter (parameter) int64 1\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: []\n", " compute_times: []\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rs[\"result\"]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "There it is, under `Attributes`! And there's some other stuff there too. But we'll get\n", "back to that. First let's look at the \"values\" of the result displayed there: an array\n", "with just a `-1`. But what is this doing there? Nothing was computed. Well, to find out,\n", "let's {meth}`~respace.ResultSet.compute` a value of `\"result\"`:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Computing result for the following parameter values:\n", "{'parameter': 1}\n", "2\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 1)>\n",
       "array([0])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2]\n",
       "    compute_times:         [3.5762786865234375e-06]\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([0])\n", "Coordinates:\n", " * parameter (parameter) int64 1\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2]\n", " compute_times: [3.5762786865234375e-06]\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res = rs.compute(\"result\", {})\n", "print(res)\n", "rs[\"result\"]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Many things have changed in here, but let's start with the value in the array: it became\n", "`0`. So what does it mean? It means that the result for `parameter = 1` is located at\n", "index `0` of the `computed_values` attribute: there is the `2` resulting from the\n", "addition. But how did it know to add `1 + 1`? Well since `parameter` was not provided in\n", "the dictionary passed as second argument to `rs.compute()`, its default value was taken.\n", "Here since the parameter has only one possible value, that's the default. Otherwise, the\n", "first value along the `parameter` axis will be the default. Let's now add more parameter\n", "values to see how that goes." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Changing the parameters" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 4)>\n",
       "array([ 0, -1, -1, -1])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1 2 3 4\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2]\n",
       "    compute_times:         [3.5762786865234375e-06]\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([ 0, -1, -1, -1])\n", "Coordinates:\n", " * parameter (parameter) int64 1 2 3 4\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2]\n", " compute_times: [3.5762786865234375e-06]\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rs.add_param_values({'parameter': [2, 3, 4]})\n", "rs[\"result\"]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "As you can see, the new parameter values are there in the `Coordinates`, and the array's\n", "size increased along the exising axis, with the `0` still at the coordinate\n", "corresponding to `parameter = 1`, and `-1` elsewhere. Let's see what happens if we now\n", "try to {meth}`~respace.ResultSet.get` the result as we did for `compute` above:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 4)>\n",
       "array([ 0, -1, -1, -1])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1 2 3 4\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2]\n",
       "    compute_times:         [3.5762786865234375e-06]\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([ 0, -1, -1, -1])\n", "Coordinates:\n", " * parameter (parameter) int64 1 2 3 4\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2]\n", " compute_times: [3.5762786865234375e-06]\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res = rs.get(\"result\", {})\n", "print(res)\n", "rs[\"result\"]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Here's the `2` again, and we didn't get any message saying a new value was computed.\n", "That's because it wasn't, since the value was already computed it was just retrieved\n", "from the right position in `computed_values`. Now if we `get` for a different\n", "`\"parameter\"` value:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Computing result for the following parameter values:\n", "{'parameter': 3}\n", "4\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 4)>\n",
       "array([ 0, -1,  1, -1])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1 2 3 4\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2, 4]\n",
       "    compute_times:         [3.5762786865234375e-06, 2.384185791015625e-06]\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([ 0, -1, 1, -1])\n", "Coordinates:\n", " * parameter (parameter) int64 1 2 3 4\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2, 4]\n", " compute_times: [3.5762786865234375e-06, 2.384185791015625e-06]\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res = rs.get(\"result\", {\"parameter\": 3})\n", "print(res)\n", "rs[\"result\"]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "tags": [ "remove-cell" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 2)>\n",
       "array([0, 1])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1 3\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2, 4]\n",
       "    compute_times:         [3.5762786865234375e-06, 2.384185791015625e-06]\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([0, 1])\n", "Coordinates:\n", " * parameter (parameter) int64 1 3\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2, 4]\n", " compute_times: [3.5762786865234375e-06, 2.384185791015625e-06]\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "metadata": { "scrapbook": { "mime_prefix": "", "name": "populated_space" } }, "output_type": "display_data" } ], "source": [ "glue(\"populated_space\", rs.populated_space[\"result\"])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "As expected, here it computed the result for the new value.\n", "\n", "`````{note}\n", "Now if we want to\n", "see only the part of the parameter space where values have been computed, we can use the\n", "{attr}`~respace.ResultSet.populated_space` property:\n", "\n", "```{code} python\n", "rs.populated_space[\"result\"]\n", "```\n", "\n", "````{toggle}\n", "\n", "```{glue} populated_space\n", "```\n", "\n", "````\n", "\n", "`````" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "And what happens if we try to make a computation for a parameter value that's not in the\n", "parameter space?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "tags": [ "hide-output" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Computing result for the following parameter values:\n", "{'parameter': 5}\n", "6\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (parameter: 5)>\n",
       "array([ 0, -1,  1, -1,  2])\n",
       "Coordinates:\n",
       "  * parameter  (parameter) int64 1 2 3 4 5\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2, 4, 6]\n",
       "    compute_times:         [3.5762786865234375e-06, 2.384185791015625e-06, 2....\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([ 0, -1, 1, -1, 2])\n", "Coordinates:\n", " * parameter (parameter) int64 1 2 3 4 5\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2, 4, 6]\n", " compute_times: [3.5762786865234375e-06, 2.384185791015625e-06, 2....\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res = rs.get(\"result\", {\"parameter\": 5})\n", "print(res)\n", "rs[\"result\"]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Well it's simply added to the set and the computation goes through." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Adding parameters" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "What if we need to add some new parameters at some point? That's what the\n", "{meth}`~respace.ResultSet.add_params` method is for. Here are different ways to use it\n", "that show some of the types of parameters that can be added:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.DataArray 'result' (constant: 1, date: 2, letter: 3, parameter: 5)>\n",
       "array([[[[ 0, -1,  1, -1,  2],\n",
       "         [ 0, -1,  1, -1,  2],\n",
       "         [ 0, -1,  1, -1,  2]],\n",
       "\n",
       "        [[ 0, -1,  1, -1,  2],\n",
       "         [ 0, -1,  1, -1,  2],\n",
       "         [ 0, -1,  1, -1,  2]]]])\n",
       "Coordinates:\n",
       "  * letter     (letter) object 'c' 'a' 'b'\n",
       "  * constant   (constant) int64 4\n",
       "  * date       (date) object 2000-01-01 2023-02-20\n",
       "  * parameter  (parameter) int64 1 2 3 4 5\n",
       "Attributes:\n",
       "    tracking_compute_fun:  <function add_one at 0x7f49fdfa3370>\n",
       "    computed_values:       [2, 4, 6]\n",
       "    compute_times:         [3.5762786865234375e-06, 2.384185791015625e-06, 2....\n",
       "    name:                  result\n",
       "    compute_fun:           <function add_one at 0x7f4a39cb13f0>\n",
       "    save_fun:              <function save_pickle at 0x7f49fdfa1510>\n",
       "    load_fun:              <function load_pickle at 0x7f49fdfa1630>\n",
       "    save_suffix:           .pickle\n",
       "    save_path_fmt:         None
" ], "text/plain": [ "\n", "array([[[[ 0, -1, 1, -1, 2],\n", " [ 0, -1, 1, -1, 2],\n", " [ 0, -1, 1, -1, 2]],\n", "\n", " [[ 0, -1, 1, -1, 2],\n", " [ 0, -1, 1, -1, 2],\n", " [ 0, -1, 1, -1, 2]]]])\n", "Coordinates:\n", " * letter (letter) object 'c' 'a' 'b'\n", " * constant (constant) int64 4\n", " * date (date) object 2000-01-01 2023-02-20\n", " * parameter (parameter) int64 1 2 3 4 5\n", "Attributes:\n", " tracking_compute_fun: \n", " computed_values: [2, 4, 6]\n", " compute_times: [3.5762786865234375e-06, 2.384185791015625e-06, 2....\n", " name: result\n", " compute_fun: \n", " save_fun: \n", " load_fun: \n", " save_suffix: .pickle\n", " save_path_fmt: None" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from datetime import date\n", "from respace import Parameter\n", "rs.add_params({\"date\": [date(2000, 1, 1), date.today()], \"constant\": 4})\n", "rs.add_params(Parameter(\"letter\", default=\"c\", values=[\"a\", \"b\", \"c\"]))\n", "rs[\"result\"]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "```{note}\n", "Note how dimensions have been added to the array, and how the default value for\n", "`\"letter\"` was shifted to the first position: that is so we always know which value is\n", "the default.\n", "```\n", "\n", "```{warning}\n", "Beware that the existing result values are then assumed to have been computed for the\n", "default value of the added parameters. So you should always make sure (and that's\n", "usually a good programming practice!) that for the new parameters set at their default\n", "value, the behaviour of the computing function is unchanged. Also, if needed, don't\n", "forget to update it accordingly. If parameters are absent from the signature of the\n", "function, the default behaviour implemented in ReSpace is to silently ignore these\n", "parameters[^why-ignore].\n", "```\n", "\n", "[^why-ignore]: Why silently ignore irrelevant parameters? That's because a ResultSet is\n", " meant to hold multiple results depending potentially on different parameters. It\n", " would then be extremely annoying to have to update the computing function of every\n", " result every time a new parameter needs to be added to one result." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Adding results" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Equivalently, you have the {meth}`~respace.ResultSet.add_results` method to introduce\n", "new results in the set. Here's how you use it:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.Dataset>\n",
       "Dimensions:       (letter: 3, constant: 1, date: 2, parameter: 5)\n",
       "Coordinates:\n",
       "  * letter        (letter) object 'c' 'a' 'b'\n",
       "  * constant      (constant) int64 4\n",
       "  * date          (date) object 2000-01-01 2023-02-20\n",
       "  * parameter     (parameter) int64 1 2 3 4 5\n",
       "Data variables:\n",
       "    result        (constant, date, letter, parameter) int64 0 -1 1 -1 ... 1 -1 2\n",
       "    other_result  (letter, constant, date, parameter) int64 -1 -1 -1 ... -1 -1\n",
       "    c             (letter, constant, date, parameter) int64 -1 -1 -1 ... -1 -1
" ], "text/plain": [ "\n", "Dimensions: (letter: 3, constant: 1, date: 2, parameter: 5)\n", "Coordinates:\n", " * letter (letter) object 'c' 'a' 'b'\n", " * constant (constant) int64 4\n", " * date (date) object 2000-01-01 2023-02-20\n", " * parameter (parameter) int64 1 2 3 4 5\n", "Data variables:\n", " result (constant, date, letter, parameter) int64 0 -1 1 -1 ... 1 -1 2\n", " other_result (letter, constant, date, parameter) int64 -1 -1 -1 ... -1 -1\n", " c (letter, constant, date, parameter) int64 -1 -1 -1 ... -1 -1" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from respace import ResultMetadata\n", "\n", "rs.add_results({\"other_result\": lambda parameter, constant: parameter - constant})\n", "rs.add_results([ResultMetadata(\"c\", lambda: 1, save_path_fmt=\"c\")])\n", "rs" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Saving results" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "ReSpace also makes it super easy for you to save your results, let's have a look:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Saving result at result_letter=c_constant=4_date=2000-01-01_parameter=5.pickle.\n", "Computing c for the following parameter values:\n", "{'letter': 'c', 'constant': 4, 'date': datetime.date(2000, 1, 1), 'parameter': 1}\n", "Saving c at c.pickle.\n" ] } ], "source": [ "_ = rs.save(\"result\", {\"parameter\": 5})\n", "_ = rs.save(\"c\", {})" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The result `\"c\"` was saved according to the save path format we passed it. More\n", "interestingly, `\"result\"` was saved at a path indicating first its name, and then a\n", "string giving the name of the parameters and their values." ] }, { "cell_type": "markdown", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "respace-9tX2jDyd-py3.10", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "8330400c0c308954e1e6721b2f81b5d118f9759b385f86441e24203e32745363" } } }, "nbformat": 4, "nbformat_minor": 2 }