From 07e92a669d283c72ebeea2d5203f55f56259132c Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Tue, 30 Apr 2024 09:12:20 +0200 Subject: [PATCH] :rotating_light: Add ruff rules for docstring --- examples/10_Advanced-GUI.ipynb | 28 ++++++++++++++++++++++++++ examples/3_Functions.ipynb | 14 +++++++++++++ examples/7_on-click-callback.ipynb | 7 +++++++ examples/8_Rectangular-selection.ipynb | 16 +++++++++++++++ pyproject.toml | 7 +++++-- src/ipyaladin/__init__.py | 13 ++++++++++++ 6 files changed, 83 insertions(+), 2 deletions(-) diff --git a/examples/10_Advanced-GUI.ipynb b/examples/10_Advanced-GUI.ipynb index 4c5dd064..8ce02836 100644 --- a/examples/10_Advanced-GUI.ipynb +++ b/examples/10_Advanced-GUI.ipynb @@ -37,6 +37,13 @@ "\n", "\n", "def on_survey_value_change(change: dict) -> None:\n", + " \"\"\"Survey change callback.\n", + "\n", + " Parameters\n", + " ----------\n", + " change : dict\n", + " The change dictionary.\n", + " \"\"\"\n", " aladin.survey = change[\"new\"]\n", "\n", "\n", @@ -64,6 +71,13 @@ "\n", "\n", "def on_survey_overlay_value_change(change: dict) -> None:\n", + " \"\"\"Survey overlay change callback.\n", + "\n", + " Parameters\n", + " ----------\n", + " change : dict\n", + " The change dictionary.\n", + " \"\"\"\n", " aladin.overlay_survey = change[\"new\"]\n", " aladin.overlay_survey_opacity = aladin.overlay_survey_opacity + 0.00000001\n", "\n", @@ -85,6 +99,13 @@ "\n", "\n", "def on_surveyoverlay_opacity_value_change(change: dict) -> None:\n", + " \"\"\"Survey overlay opacity change callback.\n", + "\n", + " Parameters\n", + " ----------\n", + " change : dict\n", + " The change dictionary.\n", + " \"\"\"\n", " aladin.overlay_survey_opacity = change[\"new\"]\n", "\n", "\n", @@ -106,6 +127,13 @@ "\n", "\n", "def on_zoom_slider_value_change(change: dict) -> None:\n", + " \"\"\"Zoom slider change callback.\n", + "\n", + " Parameters\n", + " ----------\n", + " change : dict\n", + " The change dictionary.\n", + " \"\"\"\n", " aladin.fov = 180 / change[\"new\"]\n", "\n", "\n", diff --git a/examples/3_Functions.ipynb b/examples/3_Functions.ipynb index 1db511f7..7864685c 100644 --- a/examples/3_Functions.ipynb +++ b/examples/3_Functions.ipynb @@ -80,11 +80,25 @@ "outputs": [], "source": [ "def get_object_data(data: dict) -> dict:\n", + " \"\"\"Print the clicked object data.\n", + "\n", + " Parameters\n", + " ----------\n", + " data : dict\n", + " The data of the clicked object.\n", + " \"\"\"\n", " print(\"It clicked.\")\n", " return data\n", "\n", "\n", "def get_object_ra_dec_product(data: dict) -> float:\n", + " \"\"\"Return the product of the ra and dec values of the clicked object.\n", + "\n", + " Parameters\n", + " ----------\n", + " data : dict\n", + " The data of the clicked object.\n", + " \"\"\"\n", " return data[\"ra\"] * data[\"dec\"]\n", "\n", "\n", diff --git a/examples/7_on-click-callback.ipynb b/examples/7_on-click-callback.ipynb index 6fad052d..814c7e21 100644 --- a/examples/7_on-click-callback.ipynb +++ b/examples/7_on-click-callback.ipynb @@ -38,6 +38,13 @@ "outputs": [], "source": [ "def process_result(data: dict) -> None:\n", + " \"\"\"Process the result of a click event on the Aladin widget.\n", + "\n", + " Parameters\n", + " ----------\n", + " data : dict\n", + " The data returned by the click event.\n", + " \"\"\"\n", " info.value = \"\"\n", " ra = data[\"ra\"]\n", " dec = data[\"dec\"]\n", diff --git a/examples/8_Rectangular-selection.ipynb b/examples/8_Rectangular-selection.ipynb index 62605ac4..7bff0560 100644 --- a/examples/8_Rectangular-selection.ipynb +++ b/examples/8_Rectangular-selection.ipynb @@ -34,6 +34,15 @@ "\n", "\n", "def on_button_clicked(_: any) -> None:\n", + " \"\"\"Button click event callback.\n", + "\n", + " It will trigger the rectangular selection in the Aladin widget.\n", + "\n", + " Parameters\n", + " ----------\n", + " _: any\n", + " The button widget that triggered the event.\n", + " \"\"\"\n", " aladin.rectangular_selection()\n", "\n", "\n", @@ -62,6 +71,13 @@ "\n", "\n", "def process_result(sources: dict) -> None:\n", + " \"\"\"Process the sources selected in the Aladin widget and display them in the table.\n", + "\n", + " Parameters\n", + " ----------\n", + " sources: dict\n", + " The sources selected in the Aladin widget.\n", + " \"\"\"\n", " s = ''\n", " s += \"\"\n", " for source in sources:\n", diff --git a/pyproject.toml b/pyproject.toml index 19cae0d0..0c301e02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,9 +44,12 @@ extend-include = ["*.ipynb"] extend-select = ["E", "W", "YTT", "ASYNC", "BLE", "B", "A", "C4", "ISC", "PIE", "PYI", "RSE", "RET", "SIM", "PTH", "TD", "ERA", "PL", "PERF", "RUF", "ARG", - "ANN" + "ANN", "D" ] -ignore = ["ISC001", "ANN101"] +ignore = ["ISC001", "ANN101", "D203", "D213", "D100", "D105"] + +[tool.ruff.lint.pydocstyle] +convention = "numpy" [tool.ruff.format] docstring-code-format = false diff --git a/src/ipyaladin/__init__.py b/src/ipyaladin/__init__.py index d9faa7a7..5601631e 100644 --- a/src/ipyaladin/__init__.py +++ b/src/ipyaladin/__init__.py @@ -1,3 +1,10 @@ +""" +Aladin Lite widget for Jupyter Notebook. + +This module provides a Python wrapper around the Aladin Lite JavaScript library. +It allows to display astronomical images and catalogs in an interactive way. +""" + import importlib.metadata import pathlib import typing @@ -27,6 +34,12 @@ class Aladin(anywidget.AnyWidget): + """Aladin Lite widget. + + This widget is a Python wrapper around the Aladin Lite JavaScript library. + It allows to display astronomical images and catalogs in an interactive way. + """ + _esm: Final = pathlib.Path(__file__).parent / "static" / "widget.js" _css: Final = pathlib.Path(__file__).parent / "static" / "widget.css"
MAIN_IDRADEC