Skip to content

Commit

Permalink
👷 Add python testing for 3.8 and 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Apr 29, 2024
1 parent 17d0aa0 commit 83cf62c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .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
uses: actions/setup-python@v2
with:
python-version: 3.12
python-version: ${{ matrix.python-version }}
- name: "Python codestyle"
run: |
pip install ".[dev]"
Expand Down
14 changes: 7 additions & 7 deletions src/ipyaladin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import importlib.metadata
import pathlib
import typing
from typing import ClassVar, Union, Final, Optional
import warnings

import anywidget
from astropy.table.table import QTable
from astropy.table import Table
from astropy.coordinates import SkyCoord
import traitlets
from traitlets import (
Float,
Int,
Unicode,
Bool,
List,
Dict,
Any,
default,
)
Expand Down Expand Up @@ -76,21 +76,21 @@ class Aladin(anywidget.AnyWidget):
show_coo_grid_control = Bool(True).tag(sync=True, init_option=True)
grid_color = Unicode("rgb(178, 50, 178)").tag(sync=True, init_option=True)
grid_opacity = Float(0.5).tag(sync=True, init_option=True)
grid_options = Dict().tag(sync=True, init_option=True)
grid_options = traitlets.Dict().tag(sync=True, init_option=True)

# content of the last click
clicked_object = Dict().tag(sync=True)
clicked_object = traitlets.Dict().tag(sync=True)
# listener callback is on the python side and contains functions to link to events
listener_callback: ClassVar[dict[str, callable]] = {}
listener_callback: ClassVar[typing.Dict[str, callable]] = {}

# overlay survey
overlay_survey = Unicode("").tag(sync=True, init_option=True)
overlay_survey_opacity = Float(0.0).tag(sync=True, init_option=True)

init_options = List(trait=Any()).tag(sync=True)
init_options = traitlets.List(trait=Any()).tag(sync=True)

@default("init_options")
def _init_options(self) -> list[str]:
def _init_options(self) -> typing.List[str]:
return list(self.traits(init_option=True))

def __init__(self, *args: any, **kwargs: any) -> None:
Expand Down
6 changes: 4 additions & 2 deletions src/ipyaladin/coordinate_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Tuple

from astropy.coordinates import SkyCoord, Angle
import re

Expand All @@ -18,7 +20,7 @@ def parse_coordinate_string(string: str) -> SkyCoord:
"""
if not _is_coordinate_string(string):
return SkyCoord.from_name(string)
coordinates: tuple[str, str] = _split_coordinate_string(string)
coordinates: Tuple[str, str] = _split_coordinate_string(string)
# Parse ra and dec to astropy Angle objects
dec: Angle = Angle(coordinates[1], unit="deg")
if _is_hour_angle_string(coordinates[0]):
Expand Down Expand Up @@ -51,7 +53,7 @@ def _is_coordinate_string(string: str) -> bool:
return bool(re.match(regex, string))


def _split_coordinate_string(coo: str) -> tuple[str, str]:
def _split_coordinate_string(coo: str) -> Tuple[str, str]:
"""Split a string containing coordinates in two parts.
Parameters
Expand Down
4 changes: 3 additions & 1 deletion src/test/test_coordinate_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Tuple

from ipyaladin import Aladin
from ipyaladin.coordinate_parser import (
parse_coordinate_string,
Expand Down Expand Up @@ -68,7 +70,7 @@ def test_is_coordinate_string(inp: str, expected: bool) -> None:


@pytest.mark.parametrize(("inp", "expected"), test_split_coordinate_string_values)
def test_split_coordinate_string(inp: str, expected: tuple[str, str]) -> None:
def test_split_coordinate_string(inp: str, expected: Tuple[str, str]) -> None:
"""Test the function _split_coordinate_string.
Parameters
Expand Down

0 comments on commit 83cf62c

Please sign in to comment.