From 8d212a3a00cc3705c54757d37df7c6798e6bc296 Mon Sep 17 00:00:00 2001 From: Roman Manasipov <110097955+romanmanasipov@users.noreply.github.com> Date: Sat, 14 Sep 2024 11:18:58 +0200 Subject: [PATCH] blob storage tests (#17) * save DataFrame to csv and excel * added test for saving and loading files * formatting --- .../files_and_python_objects_storage.ipynb | 780 +++++++++--------- tests/test_files.py | 66 ++ tests/test_reference_tables.py | 1 - tests/test_units.py | 1 - 4 files changed, 469 insertions(+), 379 deletions(-) create mode 100644 tests/test_files.py diff --git a/examples/files_and_python_objects_storage.ipynb b/examples/files_and_python_objects_storage.ipynb index a04b017..3761f32 100755 --- a/examples/files_and_python_objects_storage.ipynb +++ b/examples/files_and_python_objects_storage.ipynb @@ -278,7 +278,7 @@ "text/plain": [ "{'FileName': 'text_file.txt',\n", " 'FileSize': 108,\n", - " 'LastModified': '2024-09-14T06:27:24+00:00'}" + " 'LastModified': '2024-09-14T08:24:36+00:00'}" ] }, "execution_count": 7, @@ -373,7 +373,7 @@ "text/plain": [ "{'FileName': 'text_file_inside_folder.txt',\n", " 'FileSize': 153,\n", - " 'LastModified': '2024-09-14T06:27:25+00:00'}" + " 'LastModified': '2024-09-14T08:24:37+00:00'}" ] }, "execution_count": 12, @@ -495,7 +495,7 @@ "text/plain": [ "{'FileName': 'json_file.txt',\n", " 'FileSize': 106,\n", - " 'LastModified': '2024-09-14T06:27:25+00:00'}" + " 'LastModified': '2024-09-14T08:24:37+00:00'}" ] }, "execution_count": 18, @@ -886,7 +886,7 @@ "text/plain": [ "{'FileName': 'in_memory_json_file.txt',\n", " 'FileSize': 81,\n", - " 'LastModified': '2024-09-14T06:27:30+00:00'}" + " 'LastModified': '2024-09-14T08:24:41+00:00'}" ] }, "execution_count": 32, @@ -924,6 +924,32 @@ "json_file" ] }, + { + "cell_type": "code", + "execution_count": 34, + "id": "ce8c0c4c-839c-4a04-9800-38db421857f8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'a': 1,\n", + " 'b': 'foo',\n", + " 'c': [1, 2, 3],\n", + " 'd': {'x': ['a', 'b', 'c'], 'y': [1, 2, 3]}}" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# get json file (directly loading json content)\n", + "json_file = api.get_object(in_memory_json_filename, binary=False)\n", + "json_file" + ] + }, { "cell_type": "markdown", "id": "f5e4ad11", @@ -934,7 +960,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "id": "fd38646e", "metadata": {}, "outputs": [], @@ -944,7 +970,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 36, "id": "7e323568", "metadata": {}, "outputs": [ @@ -989,66 +1015,66 @@ " \n", " \n", " mean\n", - " 0.505380\n", - " 0.503491\n", - " 0.488289\n", - " 0.507628\n", - " 0.498925\n", - " 0.502109\n", + " 0.512172\n", + " 0.499184\n", + " 0.496016\n", + " 0.502858\n", + " 0.496484\n", + " 0.517760\n", " \n", " \n", " std\n", - " 0.286202\n", - " 0.293247\n", - " 0.285330\n", - " 0.293311\n", - " 0.291313\n", - " 0.286579\n", + " 0.293573\n", + " 0.277218\n", + " 0.287446\n", + " 0.293018\n", + " 0.283005\n", + " 0.280917\n", " \n", " \n", " min\n", - " 0.000920\n", - " 0.000750\n", - " 0.000553\n", - " 0.000400\n", - " 0.000388\n", - " 0.000228\n", + " 0.000341\n", + " 0.000227\n", + " 0.002117\n", + " 0.000185\n", + " 0.000212\n", + " 0.000741\n", " \n", " \n", " 25%\n", - " 0.259061\n", - " 0.245827\n", - " 0.258364\n", - " 0.244225\n", - " 0.243813\n", - " 0.264616\n", + " 0.262993\n", + " 0.268395\n", + " 0.244554\n", + " 0.240054\n", + " 0.248327\n", + " 0.294368\n", " \n", " \n", " 50%\n", - " 0.514605\n", - " 0.505117\n", - " 0.473647\n", - " 0.504914\n", - " 0.499803\n", - " 0.495396\n", + " 0.533376\n", + " 0.499320\n", + " 0.490525\n", + " 0.494644\n", + " 0.493294\n", + " 0.514371\n", " \n", " \n", " 75%\n", - " 0.747422\n", - " 0.761440\n", - " 0.741520\n", - " 0.770293\n", - " 0.747238\n", - " 0.753323\n", + " 0.772015\n", + " 0.722625\n", + " 0.741738\n", + " 0.764896\n", + " 0.740318\n", + " 0.752120\n", " \n", " \n", " max\n", - " 0.999916\n", - " 0.999761\n", - " 0.999419\n", - " 0.996839\n", - " 0.996180\n", - " 0.997951\n", + " 0.999882\n", + " 0.998550\n", + " 0.999944\n", + " 0.999737\n", + " 0.994961\n", + " 0.996570\n", " \n", " \n", "\n", @@ -1057,26 +1083,26 @@ "text/plain": [ " A B C D E \\\n", "count 1000.000000 1000.000000 1000.000000 1000.000000 1000.000000 \n", - "mean 0.505380 0.503491 0.488289 0.507628 0.498925 \n", - "std 0.286202 0.293247 0.285330 0.293311 0.291313 \n", - "min 0.000920 0.000750 0.000553 0.000400 0.000388 \n", - "25% 0.259061 0.245827 0.258364 0.244225 0.243813 \n", - "50% 0.514605 0.505117 0.473647 0.504914 0.499803 \n", - "75% 0.747422 0.761440 0.741520 0.770293 0.747238 \n", - "max 0.999916 0.999761 0.999419 0.996839 0.996180 \n", + "mean 0.512172 0.499184 0.496016 0.502858 0.496484 \n", + "std 0.293573 0.277218 0.287446 0.293018 0.283005 \n", + "min 0.000341 0.000227 0.002117 0.000185 0.000212 \n", + "25% 0.262993 0.268395 0.244554 0.240054 0.248327 \n", + "50% 0.533376 0.499320 0.490525 0.494644 0.493294 \n", + "75% 0.772015 0.722625 0.741738 0.764896 0.740318 \n", + "max 0.999882 0.998550 0.999944 0.999737 0.994961 \n", "\n", " F \n", "count 1000.000000 \n", - "mean 0.502109 \n", - "std 0.286579 \n", - "min 0.000228 \n", - "25% 0.264616 \n", - "50% 0.495396 \n", - "75% 0.753323 \n", - "max 0.997951 " + "mean 0.517760 \n", + "std 0.280917 \n", + "min 0.000741 \n", + "25% 0.294368 \n", + "50% 0.514371 \n", + "75% 0.752120 \n", + "max 0.996570 " ] }, - "execution_count": 35, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -1089,7 +1115,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 37, "id": "828da513", "metadata": {}, "outputs": [ @@ -1097,11 +1123,11 @@ "data": { "text/plain": [ "{'FileName': 'PythonDataFrame',\n", - " 'FileSize': 45889,\n", - " 'LastModified': '2024-09-14T06:27:30+00:00'}" + " 'FileSize': 45908,\n", + " 'LastModified': '2024-09-14T08:24:42+00:00'}" ] }, - "execution_count": 36, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1113,7 +1139,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 38, "id": "676fbf50", "metadata": {}, "outputs": [ @@ -1158,66 +1184,66 @@ " \n", " \n", " mean\n", - " 0.505380\n", - " 0.503491\n", - " 0.488289\n", - " 0.507628\n", - " 0.498925\n", - " 0.502109\n", + " 0.512172\n", + " 0.499184\n", + " 0.496016\n", + " 0.502858\n", + " 0.496484\n", + " 0.517760\n", " \n", " \n", " std\n", - " 0.286202\n", - " 0.293247\n", - " 0.285330\n", - " 0.293311\n", - " 0.291313\n", - " 0.286579\n", + " 0.293573\n", + " 0.277218\n", + " 0.287446\n", + " 0.293018\n", + " 0.283005\n", + " 0.280917\n", " \n", " \n", " min\n", - " 0.000920\n", - " 0.000750\n", - " 0.000553\n", - " 0.000400\n", - " 0.000388\n", - " 0.000228\n", + " 0.000341\n", + " 0.000227\n", + " 0.002117\n", + " 0.000185\n", + " 0.000212\n", + " 0.000741\n", " \n", " \n", " 25%\n", - " 0.259061\n", - " 0.245827\n", - " 0.258364\n", - " 0.244225\n", - " 0.243813\n", - " 0.264616\n", + " 0.262993\n", + " 0.268395\n", + " 0.244554\n", + " 0.240054\n", + " 0.248327\n", + " 0.294368\n", " \n", " \n", " 50%\n", - " 0.514605\n", - " 0.505117\n", - " 0.473647\n", - " 0.504914\n", - " 0.499803\n", - " 0.495396\n", + " 0.533376\n", + " 0.499320\n", + " 0.490525\n", + " 0.494644\n", + " 0.493294\n", + " 0.514371\n", " \n", " \n", " 75%\n", - " 0.747422\n", - " 0.761440\n", - " 0.741520\n", - " 0.770293\n", - " 0.747238\n", - " 0.753323\n", + " 0.772015\n", + " 0.722625\n", + " 0.741738\n", + " 0.764896\n", + " 0.740318\n", + " 0.752120\n", " \n", " \n", " max\n", - " 0.999916\n", - " 0.999761\n", - " 0.999419\n", - " 0.996839\n", - " 0.996180\n", - " 0.997951\n", + " 0.999882\n", + " 0.998550\n", + " 0.999944\n", + " 0.999737\n", + " 0.994961\n", + " 0.996570\n", " \n", " \n", "\n", @@ -1226,26 +1252,26 @@ "text/plain": [ " A B C D E \\\n", "count 1000.000000 1000.000000 1000.000000 1000.000000 1000.000000 \n", - "mean 0.505380 0.503491 0.488289 0.507628 0.498925 \n", - "std 0.286202 0.293247 0.285330 0.293311 0.291313 \n", - "min 0.000920 0.000750 0.000553 0.000400 0.000388 \n", - "25% 0.259061 0.245827 0.258364 0.244225 0.243813 \n", - "50% 0.514605 0.505117 0.473647 0.504914 0.499803 \n", - "75% 0.747422 0.761440 0.741520 0.770293 0.747238 \n", - "max 0.999916 0.999761 0.999419 0.996839 0.996180 \n", + "mean 0.512172 0.499184 0.496016 0.502858 0.496484 \n", + "std 0.293573 0.277218 0.287446 0.293018 0.283005 \n", + "min 0.000341 0.000227 0.002117 0.000185 0.000212 \n", + "25% 0.262993 0.268395 0.244554 0.240054 0.248327 \n", + "50% 0.533376 0.499320 0.490525 0.494644 0.493294 \n", + "75% 0.772015 0.722625 0.741738 0.764896 0.740318 \n", + "max 0.999882 0.998550 0.999944 0.999737 0.994961 \n", "\n", " F \n", "count 1000.000000 \n", - "mean 0.502109 \n", - "std 0.286579 \n", - "min 0.000228 \n", - "25% 0.264616 \n", - "50% 0.495396 \n", - "75% 0.753323 \n", - "max 0.997951 " + "mean 0.517760 \n", + "std 0.280917 \n", + "min 0.000741 \n", + "25% 0.294368 \n", + "50% 0.514371 \n", + "75% 0.752120 \n", + "max 0.996570 " ] }, - "execution_count": 37, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -1266,7 +1292,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 39, "id": "3a3fd49a-bf2a-4ecc-833a-27ba6d03c06b", "metadata": {}, "outputs": [], @@ -1276,7 +1302,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 40, "id": "484ad45b-2b07-4ce8-bf30-1c4bbf60ce79", "metadata": {}, "outputs": [ @@ -1321,66 +1347,66 @@ " \n", " \n", " mean\n", - " 0.489670\n", - " 0.489180\n", - " 0.507504\n", - " 0.510191\n", - " 0.491957\n", - " 0.496886\n", + " 0.484961\n", + " 0.496264\n", + " 0.497050\n", + " 0.515552\n", + " 0.481781\n", + " 0.512973\n", " \n", " \n", " std\n", - " 0.287381\n", - " 0.283990\n", - " 0.288265\n", - " 0.286856\n", - " 0.290977\n", - " 0.285665\n", + " 0.291601\n", + " 0.278930\n", + " 0.288481\n", + " 0.291021\n", + " 0.285206\n", + " 0.289938\n", " \n", " \n", " min\n", - " 0.000099\n", - " 0.002739\n", - " 0.000985\n", - " 0.000608\n", - " 0.000994\n", - " 0.000573\n", + " 0.000192\n", + " 0.001169\n", + " 0.000231\n", + " 0.000552\n", + " 0.000192\n", + " 0.000312\n", " \n", " \n", " 25%\n", - " 0.246406\n", - " 0.253548\n", - " 0.258094\n", - " 0.257812\n", - " 0.236022\n", - " 0.249795\n", + " 0.219493\n", + " 0.261146\n", + " 0.256118\n", + " 0.259521\n", + " 0.229561\n", + " 0.261098\n", " \n", " \n", " 50%\n", - " 0.469498\n", - " 0.479472\n", - " 0.508597\n", - " 0.520490\n", - " 0.504487\n", - " 0.495216\n", + " 0.484880\n", + " 0.490613\n", + " 0.490742\n", + " 0.533099\n", + " 0.471350\n", + " 0.531393\n", " \n", " \n", " 75%\n", - " 0.743618\n", - " 0.731988\n", - " 0.753523\n", - " 0.764544\n", - " 0.723016\n", - " 0.742412\n", + " 0.741547\n", + " 0.734621\n", + " 0.748029\n", + " 0.766608\n", + " 0.722307\n", + " 0.764047\n", " \n", " \n", " max\n", - " 0.995917\n", - " 0.999964\n", - " 0.997376\n", - " 0.999637\n", - " 0.999195\n", - " 0.998996\n", + " 0.999975\n", + " 0.996931\n", + " 0.997797\n", + " 0.999450\n", + " 0.999285\n", + " 0.998011\n", " \n", " \n", "\n", @@ -1389,26 +1415,26 @@ "text/plain": [ " A B C D E \\\n", "count 1000.000000 1000.000000 1000.000000 1000.000000 1000.000000 \n", - "mean 0.489670 0.489180 0.507504 0.510191 0.491957 \n", - "std 0.287381 0.283990 0.288265 0.286856 0.290977 \n", - "min 0.000099 0.002739 0.000985 0.000608 0.000994 \n", - "25% 0.246406 0.253548 0.258094 0.257812 0.236022 \n", - "50% 0.469498 0.479472 0.508597 0.520490 0.504487 \n", - "75% 0.743618 0.731988 0.753523 0.764544 0.723016 \n", - "max 0.995917 0.999964 0.997376 0.999637 0.999195 \n", + "mean 0.484961 0.496264 0.497050 0.515552 0.481781 \n", + "std 0.291601 0.278930 0.288481 0.291021 0.285206 \n", + "min 0.000192 0.001169 0.000231 0.000552 0.000192 \n", + "25% 0.219493 0.261146 0.256118 0.259521 0.229561 \n", + "50% 0.484880 0.490613 0.490742 0.533099 0.471350 \n", + "75% 0.741547 0.734621 0.748029 0.766608 0.722307 \n", + "max 0.999975 0.996931 0.997797 0.999450 0.999285 \n", "\n", " F \n", "count 1000.000000 \n", - "mean 0.496886 \n", - "std 0.285665 \n", - "min 0.000573 \n", - "25% 0.249795 \n", - "50% 0.495216 \n", - "75% 0.742412 \n", - "max 0.998996 " + "mean 0.512973 \n", + "std 0.289938 \n", + "min 0.000312 \n", + "25% 0.261098 \n", + "50% 0.531393 \n", + "75% 0.764047 \n", + "max 0.998011 " ] }, - "execution_count": 39, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -1421,7 +1447,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 41, "id": "f7bf8f0b-7bec-4872-826a-32e482771bbd", "metadata": {}, "outputs": [ @@ -1429,11 +1455,11 @@ "data": { "text/plain": [ "{'FileName': 'PythonDataFrame.xlsx',\n", - " 'FileSize': 83452,\n", - " 'LastModified': '2024-09-14T06:27:31+00:00'}" + " 'FileSize': 83441,\n", + " 'LastModified': '2024-09-14T08:24:43+00:00'}" ] }, - "execution_count": 40, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1445,7 +1471,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 42, "id": "82bdc30b-fb2c-45a4-ac8d-ded705c65ddb", "metadata": {}, "outputs": [ @@ -1490,66 +1516,66 @@ " \n", " \n", " mean\n", - " 0.489670\n", - " 0.489180\n", - " 0.507504\n", - " 0.510191\n", - " 0.491957\n", - " 0.496886\n", + " 0.484961\n", + " 0.496264\n", + " 0.497050\n", + " 0.515552\n", + " 0.481781\n", + " 0.512973\n", " \n", " \n", " std\n", - " 0.287381\n", - " 0.283990\n", - " 0.288265\n", - " 0.286856\n", - " 0.290977\n", - " 0.285665\n", + " 0.291601\n", + " 0.278930\n", + " 0.288481\n", + " 0.291021\n", + " 0.285206\n", + " 0.289938\n", " \n", " \n", " min\n", - " 0.000099\n", - " 0.002739\n", - " 0.000985\n", - " 0.000608\n", - " 0.000994\n", - " 0.000573\n", + " 0.000192\n", + " 0.001169\n", + " 0.000231\n", + " 0.000552\n", + " 0.000192\n", + " 0.000312\n", " \n", " \n", " 25%\n", - " 0.246406\n", - " 0.253548\n", - " 0.258094\n", - " 0.257812\n", - " 0.236022\n", - " 0.249795\n", + " 0.219493\n", + " 0.261146\n", + " 0.256118\n", + " 0.259521\n", + " 0.229561\n", + " 0.261098\n", " \n", " \n", " 50%\n", - " 0.469498\n", - " 0.479472\n", - " 0.508597\n", - " 0.520490\n", - " 0.504487\n", - " 0.495216\n", + " 0.484880\n", + " 0.490613\n", + " 0.490742\n", + " 0.533099\n", + " 0.471350\n", + " 0.531393\n", " \n", " \n", " 75%\n", - " 0.743618\n", - " 0.731988\n", - " 0.753523\n", - " 0.764544\n", - " 0.723016\n", - " 0.742412\n", + " 0.741547\n", + " 0.734621\n", + " 0.748029\n", + " 0.766608\n", + " 0.722307\n", + " 0.764047\n", " \n", " \n", " max\n", - " 0.995917\n", - " 0.999964\n", - " 0.997376\n", - " 0.999637\n", - " 0.999195\n", - " 0.998996\n", + " 0.999975\n", + " 0.996931\n", + " 0.997797\n", + " 0.999450\n", + " 0.999285\n", + " 0.998011\n", " \n", " \n", "\n", @@ -1558,26 +1584,26 @@ "text/plain": [ " A B C D E \\\n", "count 1000.000000 1000.000000 1000.000000 1000.000000 1000.000000 \n", - "mean 0.489670 0.489180 0.507504 0.510191 0.491957 \n", - "std 0.287381 0.283990 0.288265 0.286856 0.290977 \n", - "min 0.000099 0.002739 0.000985 0.000608 0.000994 \n", - "25% 0.246406 0.253548 0.258094 0.257812 0.236022 \n", - "50% 0.469498 0.479472 0.508597 0.520490 0.504487 \n", - "75% 0.743618 0.731988 0.753523 0.764544 0.723016 \n", - "max 0.995917 0.999964 0.997376 0.999637 0.999195 \n", + "mean 0.484961 0.496264 0.497050 0.515552 0.481781 \n", + "std 0.291601 0.278930 0.288481 0.291021 0.285206 \n", + "min 0.000192 0.001169 0.000231 0.000552 0.000192 \n", + "25% 0.219493 0.261146 0.256118 0.259521 0.229561 \n", + "50% 0.484880 0.490613 0.490742 0.533099 0.471350 \n", + "75% 0.741547 0.734621 0.748029 0.766608 0.722307 \n", + "max 0.999975 0.996931 0.997797 0.999450 0.999285 \n", "\n", " F \n", "count 1000.000000 \n", - "mean 0.496886 \n", - "std 0.285665 \n", - "min 0.000573 \n", - "25% 0.249795 \n", - "50% 0.495216 \n", - "75% 0.742412 \n", - "max 0.998996 " + "mean 0.512973 \n", + "std 0.289938 \n", + "min 0.000312 \n", + "25% 0.261098 \n", + "50% 0.531393 \n", + "75% 0.764047 \n", + "max 0.998011 " ] }, - "execution_count": 41, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1598,7 +1624,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 43, "id": "ad8a6be7-8e54-4d19-b62a-01f5980d0c26", "metadata": {}, "outputs": [], @@ -1608,7 +1634,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 44, "id": "3ab40cbf-ea1b-44f2-b468-1511c278ef9f", "metadata": {}, "outputs": [ @@ -1653,66 +1679,66 @@ " \n", " \n", " mean\n", - " 0.511454\n", - " 0.522048\n", - " 0.504313\n", - " 0.504713\n", - " 0.494732\n", - " 0.500210\n", + " 0.494799\n", + " 0.494135\n", + " 0.506543\n", + " 0.519769\n", + " 0.492335\n", + " 0.488433\n", " \n", " \n", " std\n", - " 0.284970\n", - " 0.283053\n", - " 0.286638\n", - " 0.286273\n", - " 0.294515\n", - " 0.289024\n", + " 0.283438\n", + " 0.281720\n", + " 0.289256\n", + " 0.286991\n", + " 0.294640\n", + " 0.281300\n", " \n", " \n", " min\n", - " 0.003330\n", - " 0.000405\n", - " 0.000959\n", - " 0.000050\n", - " 0.001490\n", - " 0.000190\n", + " 0.000357\n", + " 0.000061\n", + " 0.000491\n", + " 0.002560\n", + " 0.001024\n", + " 0.001146\n", " \n", " \n", " 25%\n", - " 0.275897\n", - " 0.291933\n", - " 0.256520\n", - " 0.259792\n", - " 0.237938\n", - " 0.251599\n", + " 0.255175\n", + " 0.257041\n", + " 0.267001\n", + " 0.264351\n", + " 0.238453\n", + " 0.238830\n", " \n", " \n", " 50%\n", - " 0.508559\n", - " 0.539129\n", - " 0.501602\n", - " 0.520600\n", - " 0.471285\n", - " 0.512058\n", + " 0.486717\n", + " 0.492988\n", + " 0.506096\n", + " 0.535905\n", + " 0.500948\n", + " 0.488307\n", " \n", " \n", " 75%\n", - " 0.756777\n", - " 0.755231\n", - " 0.743460\n", - " 0.756497\n", - " 0.760238\n", - " 0.751268\n", + " 0.742316\n", + " 0.728733\n", + " 0.753189\n", + " 0.770897\n", + " 0.750457\n", + " 0.737440\n", " \n", " \n", " max\n", - " 0.999784\n", - " 0.997883\n", - " 0.999541\n", - " 0.998536\n", - " 0.998784\n", - " 0.998828\n", + " 0.998229\n", + " 0.999698\n", + " 0.999560\n", + " 0.999635\n", + " 0.999374\n", + " 0.997818\n", " \n", " \n", "\n", @@ -1721,26 +1747,26 @@ "text/plain": [ " A B C D E \\\n", "count 1000.000000 1000.000000 1000.000000 1000.000000 1000.000000 \n", - "mean 0.511454 0.522048 0.504313 0.504713 0.494732 \n", - "std 0.284970 0.283053 0.286638 0.286273 0.294515 \n", - "min 0.003330 0.000405 0.000959 0.000050 0.001490 \n", - "25% 0.275897 0.291933 0.256520 0.259792 0.237938 \n", - "50% 0.508559 0.539129 0.501602 0.520600 0.471285 \n", - "75% 0.756777 0.755231 0.743460 0.756497 0.760238 \n", - "max 0.999784 0.997883 0.999541 0.998536 0.998784 \n", + "mean 0.494799 0.494135 0.506543 0.519769 0.492335 \n", + "std 0.283438 0.281720 0.289256 0.286991 0.294640 \n", + "min 0.000357 0.000061 0.000491 0.002560 0.001024 \n", + "25% 0.255175 0.257041 0.267001 0.264351 0.238453 \n", + "50% 0.486717 0.492988 0.506096 0.535905 0.500948 \n", + "75% 0.742316 0.728733 0.753189 0.770897 0.750457 \n", + "max 0.998229 0.999698 0.999560 0.999635 0.999374 \n", "\n", " F \n", "count 1000.000000 \n", - "mean 0.500210 \n", - "std 0.289024 \n", - "min 0.000190 \n", - "25% 0.251599 \n", - "50% 0.512058 \n", - "75% 0.751268 \n", - "max 0.998828 " + "mean 0.488433 \n", + "std 0.281300 \n", + "min 0.001146 \n", + "25% 0.238830 \n", + "50% 0.488307 \n", + "75% 0.737440 \n", + "max 0.997818 " ] }, - "execution_count": 43, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -1753,7 +1779,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 45, "id": "46bb2cbe-26c3-4fb3-a730-6e3351f90809", "metadata": {}, "outputs": [ @@ -1761,11 +1787,11 @@ "data": { "text/plain": [ "{'FileName': 'PythonDataFrame.csv',\n", - " 'FileSize': 115541,\n", - " 'LastModified': '2024-09-14T06:27:32+00:00'}" + " 'FileSize': 115568,\n", + " 'LastModified': '2024-09-14T08:24:43+00:00'}" ] }, - "execution_count": 44, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1777,7 +1803,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 46, "id": "81e94131-ebf2-4489-8237-e878667655c0", "metadata": {}, "outputs": [ @@ -1822,66 +1848,66 @@ " \n", " \n", " mean\n", - " 0.511454\n", - " 0.522048\n", - " 0.504313\n", - " 0.504713\n", - " 0.494732\n", - " 0.500210\n", + " 0.494799\n", + " 0.494135\n", + " 0.506543\n", + " 0.519769\n", + " 0.492335\n", + " 0.488433\n", " \n", " \n", " std\n", - " 0.284970\n", - " 0.283053\n", - " 0.286638\n", - " 0.286273\n", - " 0.294515\n", - " 0.289024\n", + " 0.283438\n", + " 0.281720\n", + " 0.289256\n", + " 0.286991\n", + " 0.294640\n", + " 0.281300\n", " \n", " \n", " min\n", - " 0.003330\n", - " 0.000405\n", - " 0.000959\n", - " 0.000050\n", - " 0.001490\n", - " 0.000190\n", + " 0.000357\n", + " 0.000061\n", + " 0.000491\n", + " 0.002560\n", + " 0.001024\n", + " 0.001146\n", " \n", " \n", " 25%\n", - " 0.275897\n", - " 0.291933\n", - " 0.256520\n", - " 0.259792\n", - " 0.237938\n", - " 0.251599\n", + " 0.255175\n", + " 0.257041\n", + " 0.267001\n", + " 0.264351\n", + " 0.238453\n", + " 0.238830\n", " \n", " \n", " 50%\n", - " 0.508559\n", - " 0.539129\n", - " 0.501602\n", - " 0.520600\n", - " 0.471285\n", - " 0.512058\n", + " 0.486717\n", + " 0.492988\n", + " 0.506096\n", + " 0.535905\n", + " 0.500948\n", + " 0.488307\n", " \n", " \n", " 75%\n", - " 0.756777\n", - " 0.755231\n", - " 0.743460\n", - " 0.756497\n", - " 0.760238\n", - " 0.751268\n", + " 0.742316\n", + " 0.728733\n", + " 0.753189\n", + " 0.770897\n", + " 0.750457\n", + " 0.737440\n", " \n", " \n", " max\n", - " 0.999784\n", - " 0.997883\n", - " 0.999541\n", - " 0.998536\n", - " 0.998784\n", - " 0.998828\n", + " 0.998229\n", + " 0.999698\n", + " 0.999560\n", + " 0.999635\n", + " 0.999374\n", + " 0.997818\n", " \n", " \n", "\n", @@ -1890,26 +1916,26 @@ "text/plain": [ " A B C D E \\\n", "count 1000.000000 1000.000000 1000.000000 1000.000000 1000.000000 \n", - "mean 0.511454 0.522048 0.504313 0.504713 0.494732 \n", - "std 0.284970 0.283053 0.286638 0.286273 0.294515 \n", - "min 0.003330 0.000405 0.000959 0.000050 0.001490 \n", - "25% 0.275897 0.291933 0.256520 0.259792 0.237938 \n", - "50% 0.508559 0.539129 0.501602 0.520600 0.471285 \n", - "75% 0.756777 0.755231 0.743460 0.756497 0.760238 \n", - "max 0.999784 0.997883 0.999541 0.998536 0.998784 \n", + "mean 0.494799 0.494135 0.506543 0.519769 0.492335 \n", + "std 0.283438 0.281720 0.289256 0.286991 0.294640 \n", + "min 0.000357 0.000061 0.000491 0.002560 0.001024 \n", + "25% 0.255175 0.257041 0.267001 0.264351 0.238453 \n", + "50% 0.486717 0.492988 0.506096 0.535905 0.500948 \n", + "75% 0.742316 0.728733 0.753189 0.770897 0.750457 \n", + "max 0.998229 0.999698 0.999560 0.999635 0.999374 \n", "\n", " F \n", "count 1000.000000 \n", - "mean 0.500210 \n", - "std 0.289024 \n", - "min 0.000190 \n", - "25% 0.251599 \n", - "50% 0.512058 \n", - "75% 0.751268 \n", - "max 0.998828 " + "mean 0.488433 \n", + "std 0.281300 \n", + "min 0.001146 \n", + "25% 0.238830 \n", + "50% 0.488307 \n", + "75% 0.737440 \n", + "max 0.997818 " ] }, - "execution_count": 45, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1930,7 +1956,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 47, "id": "a34e9485", "metadata": {}, "outputs": [], @@ -1940,7 +1966,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 48, "id": "80719647", "metadata": {}, "outputs": [], @@ -1960,7 +1986,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 49, "id": "298c964d", "metadata": {}, "outputs": [ @@ -1969,10 +1995,10 @@ "text/plain": [ "{'FileName': 'pyobj',\n", " 'FileSize': 120,\n", - " 'LastModified': '2024-09-14T06:27:33+00:00'}" + " 'LastModified': '2024-09-14T08:24:44+00:00'}" ] }, - "execution_count": 48, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -1984,7 +2010,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 50, "id": "776a9def", "metadata": {}, "outputs": [ @@ -2014,7 +2040,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 51, "id": "8d1be04b", "metadata": { "tags": [] @@ -2129,7 +2155,7 @@ " 'zmap_example']" ] }, - "execution_count": 50, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } @@ -2142,7 +2168,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 52, "id": "4ebea39b", "metadata": {}, "outputs": [ @@ -2152,7 +2178,7 @@ "" ] }, - "execution_count": 51, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } diff --git a/tests/test_files.py b/tests/test_files.py new file mode 100644 index 0000000..db19919 --- /dev/null +++ b/tests/test_files.py @@ -0,0 +1,66 @@ +import numpy as np +import pandas as pd +from petrovisor import PetroVisor +import uuid + + +def test_files(api: PetroVisor): + # Dictionary to json file tests + d = { + "a": 1, + "b": "foo", + "c": [1, 2, 3], + "d": { + "x": [ + "a", + "b", + "c", + ], + "y": [1, 2, 3], + }, + } + + json_file_name = str(uuid.uuid4()) + ".json" + api.upload_object(d, json_file_name, binary=False) + + d_loaded1 = api.get_file(json_file_name, format="json") + assert d == d_loaded1 + + d_loaded2 = api.get_object(json_file_name, binary=False) + assert d == d_loaded2 + + api.delete_file(json_file_name) + + # DataFrame tests + df = pd.DataFrame( + np.random.uniform(0, 1, size=(int(1e3), 6)), columns=list("ABCDEF") + ) + + # DataFrame to csv tests + dataframe_csv_file_name = str(uuid.uuid4()) + ".csv" + api.upload_object(df, dataframe_csv_file_name) + + df_csv_loaded = api.get_object(dataframe_csv_file_name) + # assert df.equals(df_csv_loaded) + assert df.shape == df_csv_loaded.shape + + api.delete_file(dataframe_csv_file_name) + + # DataFrame to excel test + dataframe_excel_file_name = str(uuid.uuid4()) + ".xlsx" + api.upload_object(df, dataframe_excel_file_name) + + df_excel_loaded = api.get_object(dataframe_excel_file_name) + # assert df.equals(df_excel_loaded) + assert df.shape == df_excel_loaded.shape + + api.delete_file(dataframe_excel_file_name) + + # DataFrame to pickle test + dataframe_pickle_file_name = str(uuid.uuid4()) + ".pkl" + api.upload_object(df, dataframe_pickle_file_name) + + df_pickle_loaded = api.get_object(dataframe_pickle_file_name) + assert df.equals(df_pickle_loaded) + + api.delete_file(dataframe_pickle_file_name) diff --git a/tests/test_reference_tables.py b/tests/test_reference_tables.py index 191853d..8bbcec4 100644 --- a/tests/test_reference_tables.py +++ b/tests/test_reference_tables.py @@ -5,7 +5,6 @@ def test_ref_tables(api: PetroVisor): - # create entity entity_name = "Well 001" api.add_item( diff --git a/tests/test_units.py b/tests/test_units.py index b7eda45..d531812 100644 --- a/tests/test_units.py +++ b/tests/test_units.py @@ -4,7 +4,6 @@ def test_units(api: PetroVisor): - value = api.convert_units(3, "cm", "m") assert value == 0.03