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

chore: ensure typeshed compatible mypy types are exported #101

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 14 additions & 25 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
{
"editor.formatOnSave": true,
"python.formatting.provider": "none",
"python.formatting.blackArgs": [
"--line-length=88"
],
"python.linting.enabled": true,
"python.linting.flake8Enabled": false,
"python.linting.pylintEnabled": false,
"python.linting.flake8Args": [
"--max-line-length=88"
],
"python.linting.mypyEnabled": true,
"isort.args": [
"--profile",
"black"
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnPaste": false,
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.semanticHighlighting.enabled": true
},
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///Users/michael/Developer/observerly/perseus/.github/workflows/deploy.yml"
}
}
"editor.cursorBlinking": "smooth",
"editor.cursorSmoothCaretAnimation": "on",
"editor.cursorStyle": "line",
"editor.formatOnSave": true,
"editor.rulers": [88],
"explorer.compactFolders": true,
"explorer.confirmDelete": true,
}
3 changes: 1 addition & 2 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[virtualenvs]
create = false
in-project = true
in-project = true
59 changes: 50 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
name = "celerity"
version = "0.23.0"
description = "Celerity is a lightweight, zero-dependency and type-safe Python library for astronomical calculations."
authors = [
"Michael J. Roberts <[email protected]>"
]
maintainers = [
"Michael J. Roberts <[email protected]>"
]
authors = ["Michael J. Roberts <[email protected]>"]
maintainers = ["Michael J. Roberts <[email protected]>"]
readme = "README.md"
packages = [{include = "celerity", from = "src"}]
packages = [{ include = "celerity", from = "src" }]
repository = "https://github.com/michaelroberts/celerity"
keywords = ["astronomy", "astrometry", "ephemeris"]

Expand All @@ -33,7 +29,52 @@ select = ["E", "F"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
fixable = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"I",
"N",
"Q",
"S",
"T",
"W",
"ANN",
"ARG",
"BLE",
"COM",
"DJ",
"DTZ",
"EM",
"ERA",
"EXE",
"FBT",
"ICN",
"INP",
"ISC",
"NPY",
"PD",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
unfixable = []

# Exclude a variety of commonly ignored directories.
Expand Down Expand Up @@ -71,4 +112,4 @@ target-version = "py310"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
max-complexity = 10
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pytest.ini
[pytest]
pythonpath = .
addopts = --maxfail=2 -rf
61 changes: 55 additions & 6 deletions src/celerity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
# *****************************************************************************************************************
# **************************************************************************************

# @author Michael Roberts <[email protected]>
# @package @observerly/celerity
# @license Copyright © 2021-2023 observerly

# *****************************************************************************************************************
# **************************************************************************************

"""Celerity is a lightweight, zero-dependency and type-safe Python library for astronomical calculations."""
"""
Celerity is a lightweight, zero-dependency and type-safe
Python library for astronomical calculations.
"""

__version__ = "0.1.0"

# *****************************************************************************************************************
# **************************************************************************************

from .temporal import Time
from . import (
aberration,
astrometry,
common,
constants,
coordinates,
earth,
equinox,
humanize,
moon,
night,
nutation,
parallax,
precession,
refraction,
seeing,
solstice,
sun,
temporal,
transit,
utilities,
)

# *****************************************************************************************************************
# **************************************************************************************

__all__ = [
"aberration",
"astrometry",
"common",
"constants",
"coordinates",
"earth",
"equinox",
"humanize",
"moon",
"night",
"nutation",
"parallax",
"precession",
"refraction",
"seeing",
"solstice",
"sun",
"temporal",
"transit",
"utilities",
]

# **************************************************************************************
14 changes: 9 additions & 5 deletions src/celerity/aberration.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# *****************************************************************************************************************
# **************************************************************************************

# @author Michael Roberts <[email protected]>
# @package @observerly/celerity
# @license Copyright © 2021-2023 observerly

# *****************************************************************************************************************
# **************************************************************************************

from datetime import datetime
from math import cos, degrees, pow, radians, sin, tan
from math import cos, pow, radians, sin, tan

from .astrometry import get_obliquity_of_the_ecliptic
from .common import EquatorialCoordinate
Expand All @@ -20,7 +20,7 @@
from .sun import get_true_geometric_longitude as get_solar_true_geometric_longitude
from .temporal import get_julian_date

# *****************************************************************************************************************
# **************************************************************************************


def get_correction_to_equatorial_for_aberration(
Expand All @@ -40,7 +40,8 @@ def get_correction_to_equatorial_for_aberration(
# Get the Julian date:
JD = get_julian_date(date)

# Get the difference in fractional Julian centuries between the target date and J2000.0
# Get the difference in fractional Julian centuries between the target
# date and J2000.0
T = (JD - 2451545.0) / 36525

# Get the ecliptic longitude of the ascending node of the mode (in degrees):
Expand Down Expand Up @@ -90,3 +91,6 @@ def get_correction_to_equatorial_for_aberration(
)

return {"ra": Δra, "dec": Δdec}


# **************************************************************************************
30 changes: 16 additions & 14 deletions src/celerity/astrometry.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# *****************************************************************************************************************
# **************************************************************************************

# @author Michael Roberts <[email protected]>
# @package @observerly/celerity
# @license Copyright © 2021-2023 observerly

# *****************************************************************************************************************
# **************************************************************************************

from datetime import datetime
from math import acos, atan2, cos, degrees, pow, radians, sin, tan

from .common import EquatorialCoordinate, GeographicCoordinate
from .temporal import get_julian_date, get_local_sidereal_time

# *****************************************************************************************************************
# **************************************************************************************


def get_angular_separation(A: EquatorialCoordinate, B: EquatorialCoordinate) -> float:
"""
The angular separation between two objects in the sky is the angle between the two objects
as seen by an observer on Earth.
The angular separation between two objects in the sky is the angle between
the two objects as seen by an observer on Earth.

:param A: The equatorial coordinate of the observed object.
:param B: The equatorial coordinate of the observed object.
Expand All @@ -44,15 +44,16 @@ def get_angular_separation(A: EquatorialCoordinate, B: EquatorialCoordinate) ->
return θ


# *****************************************************************************************************************
# **************************************************************************************


def get_hour_angle(date: datetime, ra: float, longitude: float) -> float:
"""
Gets the hour angle for a particular object for a particular observer at a given datetime
Gets the hour angle for a particular object for a particular observer
at a given datetime

:param date: The datetime object to convert.
:param ra: The right ascension of the observed object's equatorial coordinate in degrees.
:param ra: The right ascension of the observed object's equatorial coordinate.
:param longitude: The longitude of the observer in degrees.
:return The hour angle in degrees.
"""
Expand All @@ -67,15 +68,15 @@ def get_hour_angle(date: datetime, ra: float, longitude: float) -> float:
return ha


# *****************************************************************************************************************
# **************************************************************************************


def get_obliquity_of_the_ecliptic(date: datetime) -> float:
"""
Gets the obliquity of the ecliptic for a particular datetime

The obliquity of the ecliptic is the angle between the ecliptic and the celestial equator, and is used to
convert between ecliptic and equatorial coordinates.
The obliquity of the ecliptic is the angle between the ecliptic and the celestial
equator, and is used to convert between ecliptic and equatorial coordinates.

:param date: The datetime object to convert.
:return The obliquity of the ecliptic in degrees.
Expand All @@ -90,7 +91,7 @@ def get_obliquity_of_the_ecliptic(date: datetime) -> float:
return 23.439292 - (46.845 * T + 0.00059 * pow(T, 2) + 0.001813 * pow(T, 3)) / 3600


# *****************************************************************************************************************
# **************************************************************************************


def get_parallactic_angle(
Expand All @@ -99,7 +100,8 @@ def get_parallactic_angle(
target: EquatorialCoordinate,
) -> float:
"""
Gets the parallactic angle for a particular object for a particular observer at a given datetime
Gets the parallactic angle for a particular object for a particular observer
at a given datetime

:param date: The datetime object to convert.
:param observer: The geographic coordinate of the observer.
Expand All @@ -122,4 +124,4 @@ def get_parallactic_angle(
)


# *****************************************************************************************************************
# **************************************************************************************
Loading
Loading