From 895ea0da46b4ed1ddcb81ff5dbff15ed20c7377b Mon Sep 17 00:00:00 2001 From: Kimoon Han <98246499+kmnhan@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:57:45 +0900 Subject: [PATCH] test: refactor directory structure --- docs/source/user-guide/indexing.ipynb | 427 +++++++++--------- docs/source/user-guide/io.ipynb | 6 +- docs/source/user-guide/kconv.ipynb | 1 + docs/source/user-guide/plotting.ipynb | 1 + pyproject.toml | 28 -- tests/{ => analysis}/test_fastbinning.py | 0 .../test_fit_functions_dynamic.py | 0 .../test_fit_functions_general.py | 0 tests/{ => analysis}/test_image.py | 0 tests/{ => analysis}/test_interpolate.py | 0 tests/{ => analysis}/test_kspace.py | 0 tests/{ => analysis}/test_utilities.py | 0 12 files changed, 219 insertions(+), 244 deletions(-) rename tests/{ => analysis}/test_fastbinning.py (100%) rename tests/{ => analysis}/test_fit_functions_dynamic.py (100%) rename tests/{ => analysis}/test_fit_functions_general.py (100%) rename tests/{ => analysis}/test_image.py (100%) rename tests/{ => analysis}/test_interpolate.py (100%) rename tests/{ => analysis}/test_kspace.py (100%) rename tests/{ => analysis}/test_utilities.py (100%) diff --git a/docs/source/user-guide/indexing.ipynb b/docs/source/user-guide/indexing.ipynb index 492cc051..044c0f3a 100644 --- a/docs/source/user-guide/indexing.ipynb +++ b/docs/source/user-guide/indexing.ipynb @@ -1,216 +1,217 @@ { - "cells": [ - { - "cell_type": "raw", - "id": "37312770", - "metadata": { - "editable": true, - "raw_mimetype": "text/restructuredtext", - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "source": [ - "Selecting and indexing data\n", - "===========================\n", - "\n", - "In most cases, the powerful data manipulation and indexing methods provided by :mod:`xarray` are sufficient. In this page, some frequently used :mod:`xarray` features are summarized in addition to some utilities provided by this package. Refer to the `xarray user guide `_ for more information.\n", - "\n", - "First, let us import some example data: a simple tight binding simulation of graphene." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a1be0841", - "metadata": {}, - "outputs": [], - "source": [ - "import xarray as xr\n", - "xr.set_options(display_expand_data=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8633209c", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "from erlab.interactive.exampledata import generate_data\n", - "\n", - "dat = generate_data()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "082ec477", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "dat" - ] - }, - { - "cell_type": "raw", - "id": "0d36f0c0", - "metadata": { - "editable": true, - "raw_mimetype": "text/restructuredtext", - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "source": [ - "We can see that the generated data is a three-dimensional :class:`xarray.DataArray` . Now, let's extract a cut along :math:`k_y = 0.3`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c00a34a2", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [], - "source": [ - "dat.sel(ky=0.3, method=\"nearest\")" - ] - }, - { - "cell_type": "markdown", - "id": "8f54de42", - "metadata": {}, - "source": [ - "How about the Fermi surface?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ee860369", - "metadata": {}, - "outputs": [], - "source": [ - "dat.sel(eV=0.0, method=\"nearest\")" - ] - }, - { - "cell_type": "raw", - "id": "41bac675", - "metadata": { - "editable": true, - "raw_mimetype": "text/restructuredtext", - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "source": [ - "In many scenarios, it is necessary to perform integration across multiple array slices. This can be done by slicing and averaging. The following code integrates the intensity over a window of 50 meV centered at :math:`E_F`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b495a686", - "metadata": {}, - "outputs": [], - "source": [ - "dat.sel(eV=slice(-0.025, 0.025)).mean(\"eV\")" - ] - }, - { - "cell_type": "raw", - "id": "9e68fdb4", - "metadata": { - "editable": true, - "raw_mimetype": "text/restructuredtext", - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "source": [ - "However, doing this every time is cumbersome, and we have lost the coordinate `eV`. ERLabPy provides a callable accessor :class:`qsel ` to streamline this process." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "00d3b00f", - "metadata": {}, - "outputs": [], - "source": [ - "dat.qsel(eV=0.0, eV_width=0.05)" - ] - }, - { - "cell_type": "raw", - "id": "dfc0348b", - "metadata": { - "editable": true, - "raw_mimetype": "text/restructuredtext", - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "source": [ - "Note that the averaged coordinate is automatically added to the data array. This is useful for plotting and further analysis.\n", - "\n", - "If the width is not specified, :class:`qsel ` behaves like passing `method='nearest'` to `sel`. If a slice is given instead of a single value, no integration is performed. All of these methods can be combined:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e3bdd1ba", - "metadata": {}, - "outputs": [], - "source": [ - "dat.qsel(kx=slice(-0.3, 0.3), ky=0.3, eV=0.0, eV_width=0.05)" - ] - } - ], - "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.11.8" - } + "cells": [ + { + "cell_type": "raw", + "id": "37312770", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" }, - "nbformat": 4, - "nbformat_minor": 5 + "tags": [] + }, + "source": [ + "Selecting and indexing data\n", + "===========================\n", + "\n", + "In most cases, the powerful data manipulation and indexing methods provided by :mod:`xarray` are sufficient. In this page, some frequently used :mod:`xarray` features are summarized in addition to some utilities provided by this package. Refer to the `xarray user guide `_ for more information.\n", + "\n", + "First, let us import some example data: a simple tight binding simulation of graphene." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a1be0841", + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "\n", + "xr.set_options(display_expand_data=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8633209c", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "from erlab.interactive.exampledata import generate_data\n", + "\n", + "dat = generate_data()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "082ec477", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "dat" + ] + }, + { + "cell_type": "raw", + "id": "0d36f0c0", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "We can see that the generated data is a three-dimensional :class:`xarray.DataArray` . Now, let's extract a cut along :math:`k_y = 0.3`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c00a34a2", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "dat.sel(ky=0.3, method=\"nearest\")" + ] + }, + { + "cell_type": "markdown", + "id": "8f54de42", + "metadata": {}, + "source": [ + "How about the Fermi surface?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ee860369", + "metadata": {}, + "outputs": [], + "source": [ + "dat.sel(eV=0.0, method=\"nearest\")" + ] + }, + { + "cell_type": "raw", + "id": "41bac675", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "In many scenarios, it is necessary to perform integration across multiple array slices. This can be done by slicing and averaging. The following code integrates the intensity over a window of 50 meV centered at :math:`E_F`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b495a686", + "metadata": {}, + "outputs": [], + "source": [ + "dat.sel(eV=slice(-0.025, 0.025)).mean(\"eV\")" + ] + }, + { + "cell_type": "raw", + "id": "9e68fdb4", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "However, doing this every time is cumbersome, and we have lost the coordinate `eV`. ERLabPy provides a callable accessor :class:`qsel ` to streamline this process." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "00d3b00f", + "metadata": {}, + "outputs": [], + "source": [ + "dat.qsel(eV=0.0, eV_width=0.05)" + ] + }, + { + "cell_type": "raw", + "id": "dfc0348b", + "metadata": { + "editable": true, + "raw_mimetype": "text/restructuredtext", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "source": [ + "Note that the averaged coordinate is automatically added to the data array. This is useful for plotting and further analysis.\n", + "\n", + "If the width is not specified, :class:`qsel ` behaves like passing `method='nearest'` to `sel`. If a slice is given instead of a single value, no integration is performed. All of these methods can be combined:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e3bdd1ba", + "metadata": {}, + "outputs": [], + "source": [ + "dat.qsel(kx=slice(-0.3, 0.3), ky=0.3, eV=0.0, eV_width=0.05)" + ] + } + ], + "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.11.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 } diff --git a/docs/source/user-guide/io.ipynb b/docs/source/user-guide/io.ipynb index 65a8e59b..e357a830 100644 --- a/docs/source/user-guide/io.ipynb +++ b/docs/source/user-guide/io.ipynb @@ -219,11 +219,11 @@ "source": [ "from erlab.io.dataloader import LoaderBase\n", "\n", + "\n", "class MyLoader(LoaderBase):\n", - " name = 'my_loader'\n", + " name = \"my_loader\"\n", "\n", - " skip_validate = True\n", - "\n" + " skip_validate = True" ] } ], diff --git a/docs/source/user-guide/kconv.ipynb b/docs/source/user-guide/kconv.ipynb index 652164e4..ec8a6e54 100644 --- a/docs/source/user-guide/kconv.ipynb +++ b/docs/source/user-guide/kconv.ipynb @@ -65,6 +65,7 @@ "plt.rcParams[\"figure.dpi\"] = 96\n", "\n", "import xarray\n", + "\n", "_ = xarray.set_options(display_expand_data=False, keep_attrs=True)" ] }, diff --git a/docs/source/user-guide/plotting.ipynb b/docs/source/user-guide/plotting.ipynb index ddfa3961..6bcd04b9 100644 --- a/docs/source/user-guide/plotting.ipynb +++ b/docs/source/user-guide/plotting.ipynb @@ -52,6 +52,7 @@ "%config InlineBackend.figure_formats = [\"svg\", \"pdf\"]\n", "plt.rcParams[\"figure.dpi\"] = 96\n", "import xarray as xr\n", + "\n", "xr.set_options(display_expand_data=False)\n", "nb_execution_mode = \"cache\"" ] diff --git a/pyproject.toml b/pyproject.toml index a4cd4280..5c06f57e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,34 +151,6 @@ upload_to_vcs_release = true [tool.ruff] line-length = 88 indent-width = 4 -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".git-rewrite", - ".hg", - ".ipynb_checkpoints", - ".mypy_cache", - ".nox", - ".pants.d", - ".pyenv", - ".pytest_cache", - ".pytype", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - ".vscode", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "site-packages", - "venv", -] [tool.ruff.lint] select = [ diff --git a/tests/test_fastbinning.py b/tests/analysis/test_fastbinning.py similarity index 100% rename from tests/test_fastbinning.py rename to tests/analysis/test_fastbinning.py diff --git a/tests/test_fit_functions_dynamic.py b/tests/analysis/test_fit_functions_dynamic.py similarity index 100% rename from tests/test_fit_functions_dynamic.py rename to tests/analysis/test_fit_functions_dynamic.py diff --git a/tests/test_fit_functions_general.py b/tests/analysis/test_fit_functions_general.py similarity index 100% rename from tests/test_fit_functions_general.py rename to tests/analysis/test_fit_functions_general.py diff --git a/tests/test_image.py b/tests/analysis/test_image.py similarity index 100% rename from tests/test_image.py rename to tests/analysis/test_image.py diff --git a/tests/test_interpolate.py b/tests/analysis/test_interpolate.py similarity index 100% rename from tests/test_interpolate.py rename to tests/analysis/test_interpolate.py diff --git a/tests/test_kspace.py b/tests/analysis/test_kspace.py similarity index 100% rename from tests/test_kspace.py rename to tests/analysis/test_kspace.py diff --git a/tests/test_utilities.py b/tests/analysis/test_utilities.py similarity index 100% rename from tests/test_utilities.py rename to tests/analysis/test_utilities.py