Skip to content

Commit

Permalink
🚨 Add ruff rules for docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Apr 30, 2024
1 parent dd800ec commit 07e92a6
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 2 deletions.
28 changes: 28 additions & 0 deletions examples/10_Advanced-GUI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions examples/3_Functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions examples/7_on-click-callback.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions examples/8_Rectangular-selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = '<table border=\"1\">'\n",
" s += \"<tr><th>MAIN_ID</th><th>RA</th><th>DEC</th></tr>\"\n",
" for source in sources:\n",
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions src/ipyaladin/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 07e92a6

Please sign in to comment.