From 41c1a4d17e80e55ad06c10d485ad30a44c806c19 Mon Sep 17 00:00:00 2001 From: am-tropin <94761432+am-tropin@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:50:34 +0400 Subject: [PATCH] added tests for parameter_product --- .../test_function_store-checkpoint.ipynb | 42 ++++++++++++++++++- app/tests/test_function_store.ipynb | 42 ++++++++++++++++++- app/tests/test_function_store.py | 28 +++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) diff --git a/app/tests/.ipynb_checkpoints/test_function_store-checkpoint.ipynb b/app/tests/.ipynb_checkpoints/test_function_store-checkpoint.ipynb index a3250b9..016c823 100644 --- a/app/tests/.ipynb_checkpoints/test_function_store-checkpoint.ipynb +++ b/app/tests/.ipynb_checkpoints/test_function_store-checkpoint.ipynb @@ -157,16 +157,54 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "dc7808a1", "metadata": {}, "outputs": [], + "source": [ + "# import itertools\n", + "\n", + "# def parameter_product(parameters):\n", + "# params_values = [parameters[key] if isinstance(parameters[key], list) else [parameters[key]] for key in parameters.keys()]\n", + "# return [dict(zip(parameters.keys(), combination)) for combination in itertools.product(*params_values)]\n", + "\n", + "# parameter_product({'1': ['a', 'd'], '2': 'b', '3': 'c'})" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "77e36d5f", + "metadata": {}, + "outputs": [], + "source": [ + "def test_1_parameter_product():\n", + " assert parameter_product({'1': 'a', '2': 'c'}) == [{'1': 'a', '2': 'c'}]\n", + "\n", + "def test_2_parameter_product():\n", + " assert parameter_product({'1': ['a', 'b'], '2': 'c'}) == [{'1': 'a', '2': 'c'}, {'1': 'b', '2': 'c'}]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "783783ff", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "37e10010", + "metadata": {}, + "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, - "id": "2faf0484", + "id": "6b86eb33", "metadata": {}, "outputs": [], "source": [] diff --git a/app/tests/test_function_store.ipynb b/app/tests/test_function_store.ipynb index a3250b9..016c823 100644 --- a/app/tests/test_function_store.ipynb +++ b/app/tests/test_function_store.ipynb @@ -157,16 +157,54 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "dc7808a1", "metadata": {}, "outputs": [], + "source": [ + "# import itertools\n", + "\n", + "# def parameter_product(parameters):\n", + "# params_values = [parameters[key] if isinstance(parameters[key], list) else [parameters[key]] for key in parameters.keys()]\n", + "# return [dict(zip(parameters.keys(), combination)) for combination in itertools.product(*params_values)]\n", + "\n", + "# parameter_product({'1': ['a', 'd'], '2': 'b', '3': 'c'})" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "77e36d5f", + "metadata": {}, + "outputs": [], + "source": [ + "def test_1_parameter_product():\n", + " assert parameter_product({'1': 'a', '2': 'c'}) == [{'1': 'a', '2': 'c'}]\n", + "\n", + "def test_2_parameter_product():\n", + " assert parameter_product({'1': ['a', 'b'], '2': 'c'}) == [{'1': 'a', '2': 'c'}, {'1': 'b', '2': 'c'}]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "783783ff", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "37e10010", + "metadata": {}, + "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, - "id": "2faf0484", + "id": "6b86eb33", "metadata": {}, "outputs": [], "source": [] diff --git a/app/tests/test_function_store.py b/app/tests/test_function_store.py index 7f21e2d..ba1650a 100644 --- a/app/tests/test_function_store.py +++ b/app/tests/test_function_store.py @@ -124,6 +124,34 @@ def test_for_33_check_year(): +# In[4]: + + +# import itertools + +# def parameter_product(parameters): +# params_values = [parameters[key] if isinstance(parameters[key], list) else [parameters[key]] for key in parameters.keys()] +# return [dict(zip(parameters.keys(), combination)) for combination in itertools.product(*params_values)] + +# parameter_product({'1': ['a', 'd'], '2': 'b', '3': 'c'}) + + +# In[ ]: + + +def test_1_parameter_product(): + assert parameter_product({'1': 'a', '2': 'c'}) == [{'1': 'a', '2': 'c'}] + +def test_2_parameter_product(): + assert parameter_product({'1': ['a', 'b'], '2': 'c'}) == [{'1': 'a', '2': 'c'}, {'1': 'b', '2': 'c'}] + + +# In[ ]: + + + + + # In[ ]: