{ "cells": [ { "cell_type": "markdown", "id": "73496983-6bd2-413e-ae07-d8e090db51ae", "metadata": {}, "source": [ "# ... change the package settings?" ] }, { "cell_type": "markdown", "id": "8fa4612a-bcb6-40f0-92a0-e9b75d3bcb44", "metadata": {}, "source": [ "Here are all settings:" ] }, { "cell_type": "code", "execution_count": 1, "id": "18c84d99-1c68-44fb-aeb7-013e65fd45ba", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'return_xarray': True,\n", " 'advanced_shape_repr': True,\n", " 'natural_naming': True,\n", " 'hdf_compression': 'gzip',\n", " 'hdf_compression_opts': 5,\n", " 'adjusting_plotting_labels': True,\n", " 'xarray_unit_repr_in_plots': 'in',\n", " 'plotting_name_order': ('plot_name', 'long_name', 'standard_name'),\n", " 'require_unit': True,\n", " 'ureg_format': 'C~',\n", " 'init_logger_level': 'ERROR',\n", " 'dtime_fmt': '%Y%m%d%H%M%S%f',\n", " 'expose_user_prop_to_attrs': True,\n", " 'scale_attribute_name': 'scale',\n", " 'offset_attribute_name': 'offset',\n", " 'add_provenance': False,\n", " 'ignore_standard_attribute_errors': False,\n", " 'allow_deleting_standard_attributes': False,\n", " 'parallel_find': True}" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import h5rdmtoolbox as h5tbx\n", "\n", "h5tbx.get_config()" ] }, { "cell_type": "markdown", "id": "dfce8e4d-245a-44ad-8bad-2ef14dc8c522", "metadata": {}, "source": [ "Set a setting with context manager only for a block of code:" ] }, { "cell_type": "code", "execution_count": 2, "id": "8a69b063-56ce-465e-a944-3f5ff2f01d00", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "berfore: C~\n", "during: L~\n", "after: C~\n" ] } ], "source": [ "print('berfore: ', h5tbx.get_config('ureg_format'))\n", "\n", "with h5tbx.set_config(ureg_format='L~'):\n", " pass\n", " print('during: ', h5tbx.get_config('ureg_format'))\n", "\n", "print('after: ', h5tbx.get_config('ureg_format'))" ] }, { "cell_type": "markdown", "id": "2bfbe514-ae2d-4583-89f0-9f6ab66e3cf1", "metadata": {}, "source": [ "Set it for the session:" ] }, { "cell_type": "code", "execution_count": 3, "id": "22883f33-37c7-4317-80f0-4cd28ead53da", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "h5tbx.set_config(ureg_format='C~')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.18" } }, "nbformat": 4, "nbformat_minor": 5 }