Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge global refactoring to Master #82

Merged
merged 31 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5ac2fd7
:art: Improve add_table data transmission without private traitlets
Xen0Xys Apr 23, 2024
feb9153
:heavy_plus_sign: Add mocpy as a recommended dependency
Xen0Xys Apr 23, 2024
3361e61
:art: Unify js variable and function naming to camelCase
Xen0Xys Apr 23, 2024
7d7cfee
:construction: First iteration of the js refactoring
Xen0Xys Apr 23, 2024
1615261
:art: Replace custom message switch by a dictionary
Xen0Xys Apr 24, 2024
fd3d09b
:bug: Fix missing aladinDiv argument to EventHandler constructor
Xen0Xys Apr 24, 2024
51bf3b3
:fire: Remove Aladin#off because this function does not exist in the …
Xen0Xys Apr 24, 2024
7c52056
:sparkles: Add support for snake_case and camelCase options for add_t…
Xen0Xys Apr 24, 2024
f8d9433
:memo: Update examples for new snakecase support and set_table change
Xen0Xys Apr 24, 2024
0efeff2
:art: Change add_listener to set_listener for better user understandi…
Xen0Xys Apr 25, 2024
e33f5e5
:memo: Add comment line for initialization gotoRaDec function call
Xen0Xys Apr 25, 2024
94659a3
:art: Make A only imported once and not given in objects constructor
Xen0Xys Apr 25, 2024
64383d6
:art: Add typing check to python and add minor missing documentation
Xen0Xys Apr 26, 2024
c88f253
:art: Improve structure and add jsdoc when needed
Xen0Xys Apr 26, 2024
67db8d1
:art: Improve python typing
Xen0Xys Apr 29, 2024
d7da494
:rotating_light: Fix all linter errors
Xen0Xys Apr 29, 2024
8685c20
:pushpin: Define minimal python version to 3.8
Xen0Xys Apr 25, 2024
fda7d5b
:art: Merge test optional dependency to dev
Xen0Xys Apr 29, 2024
35ae8bd
:memo: Add add_listener deprecation to CHANGELOG.md
Xen0Xys Apr 29, 2024
259238b
:construction_worker: Add python testing for 3.8 and 3.12
Xen0Xys Apr 29, 2024
c48e5bd
:rotating_light: Fix linter error
Xen0Xys Apr 29, 2024
03b40df
:rotating_light: Add ruff rules for docstring
Xen0Xys Apr 30, 2024
ad5311c
:art: Migrate Aladin Lite API import to dedicated file
Xen0Xys Apr 30, 2024
e617c95
:art: Change the way add_listener deprecation warning is display
Xen0Xys Apr 30, 2024
bdc1330
:art: Migrate Aladin object from __init__ to dedicated file
Xen0Xys Apr 30, 2024
03c8b75
:art: Improve target and fov control flow using new Lock object
Xen0Xys Apr 30, 2024
15aa666
:fire: Remove useless default lineWidth for add_moc
Xen0Xys May 2, 2024
795b770
:art: Change imports.js to aladin_lite.js for better understanding
Xen0Xys May 2, 2024
6771c6f
:ambulance: Fix widget crash when moving from Aladin Lite view
Xen0Xys May 3, 2024
8c1bdce
:memo: Fix documentation
Xen0Xys May 7, 2024
576f3dc
:memo: Improve examples
Xen0Xys May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ on:
jobs:
python-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.12]
steps:
- name: "Checkout branch"
uses: actions/checkout@v4
- name: "Set up Python on Ubuntu"
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: ${{ matrix.python-version }}
- name: "Python codestyle"
run: |
pip install ".[dev]"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Change the jslink target trait from `target` to `shared_target` (#80)
- Change the jslink fov trait from `fov` to `shared_fov` (#83)
- Deprecate the `add_listener` method for a preferred use of `set_listener` method (#82)

## [0.3.0]

Expand Down
36 changes: 32 additions & 4 deletions examples/10_Advanced-GUI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@
")\n",
"\n",
"\n",
"def on_survey_value_change(change):\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 All @@ -63,7 +70,14 @@
")\n",
"\n",
"\n",
"def on_survey_overlay_value_change(change):\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 @@ -84,7 +98,14 @@
")\n",
"\n",
"\n",
"def on_surveyoverlay_opacity_value_change(change):\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 @@ -105,7 +126,14 @@
")\n",
"\n",
"\n",
"def on_zoom_slider_value_change(change):\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
33 changes: 33 additions & 0 deletions examples/2_Base_Commands.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
"aladin.target = \"sgr a*\""
]
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "aladin.target"
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -122,6 +129,32 @@
"source": [
"aladin.coo_frame"
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "Some commands can be used with astropy objects"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "from astropy.coordinates import Angle, SkyCoord"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "aladin.target = SkyCoord(\"12h00m00s\", \"-30d00m00s\", frame=\"icrs\")"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "aladin.fov = Angle(5, \"deg\")"
}
],
"metadata": {
Expand Down
24 changes: 19 additions & 5 deletions examples/3_Functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
" \"http://vizier.u-strasbg.fr/viz-bin/votable?-source=HIP2&-c=LMC&-out.add=_RAJ,_\"\n",
" \"DEJ&-oc.form=dm&-out.meta=DhuL&-out.max=9999&-c.rm=180\"\n",
")\n",
"options = {\"sourceSize\": 12, \"color\": \"#f08080\", \"onClick\": \"showTable\"}\n",
"options = {\"source_size\": 12, \"color\": \"#f08080\", \"on_click\": \"showTable\"}\n",
"aladin.add_catalog_from_URL(url, options)"
]
},
Expand All @@ -79,21 +79,35 @@
"metadata": {},
"outputs": [],
"source": [
"def getObjectData(data):\n",
"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 getObjectRaDecProduct(data):\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",
"# when triggered, the listeners on the js side of the application will send a\n",
"# json object whose parameter data will be used by the python functions\n",
"# (data is a literal object on the js side, it will be converted as a dictionary\n",
"# object on the python side)\n",
"aladin.add_listener(\"object_hovered\", getObjectRaDecProduct)\n",
"aladin.add_listener(\"object_clicked\", getObjectData)"
"aladin.set_listener(\"object_hovered\", get_object_ra_dec_product)\n",
"aladin.set_listener(\"object_clicked\", get_object_data)"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion examples/4_Importing_Tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"metadata": {},
"outputs": [],
"source": [
"aladin.add_table(table, shape=\"rhomb\", color=\"lightskyblue\", sourceSize=20)"
"aladin.add_table(table, shape=\"rhomb\", color=\"lightskyblue\", source_size=20)\n",
"# This line also works with camelCase instead of snake_case: sourceSize=20"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion examples/5_Display_a_MOC.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@
" external_radius=20 * u.deg,\n",
" max_depth=16,\n",
")\n",
"aladin.add_moc(moc, color=\"teal\", edge=True, lineWidth=3, fillColor=\"teal\", opacity=0.5)"
"aladin.add_moc(\n",
" moc, color=\"teal\", edge=True, line_width=3, fill_color=\"teal\", opacity=0.5\n",
")"
]
}
],
Expand Down
8 changes: 4 additions & 4 deletions examples/6_Linked-widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"c = Aladin(layout=Layout(width=\"33.33%\"), survey=\"P/2MASS/color\", **cosmetic_options)\n",
"\n",
"# synchronize target between 3 widgets\n",
"widgets.jslink((a, \"shared_target\"), (b, \"shared_target\"))\n",
"widgets.jslink((b, \"shared_target\"), (c, \"shared_target\"))\n",
"widgets.jslink((a, \"_target\"), (b, \"_target\"))\n",
"widgets.jslink((b, \"_target\"), (c, \"_target\"))\n",
"\n",
"# synchronize FoV (zoom level) between 3 widgets\n",
"widgets.jslink((a, \"shared_fov\"), (b, \"shared_fov\"))\n",
"widgets.jslink((b, \"shared_fov\"), (c, \"shared_fov\"))\n",
"widgets.jslink((a, \"_fov\"), (b, \"_fov\"))\n",
"widgets.jslink((b, \"_fov\"), (c, \"_fov\"))\n",
"\n",
"items = [a, b, c]\n",
"\n",
Expand Down
11 changes: 9 additions & 2 deletions examples/7_on-click-callback.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@
"metadata": {},
"outputs": [],
"source": [
"def process_result(data):\n",
"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 Expand Up @@ -78,7 +85,7 @@
" info.value = \"<h2>%s</h2><br><br>%s\" % (obj_name, sed_img)\n",
"\n",
"\n",
"aladin.add_listener(\"click\", process_result)"
"aladin.set_listener(\"click\", process_result)"
]
},
{
Expand Down
22 changes: 19 additions & 3 deletions examples/8_Rectangular-selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@
"button = widgets.Button(description=\"Select\")\n",
"\n",
"\n",
"def on_button_clicked(b): # noqa: ARG001\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 @@ -61,7 +70,14 @@
"aladin.add_table(table)\n",
"\n",
"\n",
"def process_result(sources):\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 All @@ -74,7 +90,7 @@
" table_info.value = s\n",
"\n",
"\n",
"aladin.add_listener(\"select\", process_result)"
"aladin.set_listener(\"select\", process_result)"
]
}
],
Expand Down
3 changes: 3 additions & 0 deletions js/aladin_lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import A from "https://esm.sh/aladin-lite@3.4.0-beta";

export default A;
Loading