Skip to content
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
26 changes: 26 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run pre-commit

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Run prek
uses: j178/prek-action@v2
with:
extra_args: --all-files
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ repos:
- id: check-yaml
args:
- "--unsafe"
# These files are deliberately invalid YAML for testing error handling.
exclude: "^tests/config/dbAuth/badDbAuth.*\\.yaml$"
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
Expand Down
9 changes: 9 additions & 0 deletions doc/lsst.utils/CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
lsst-utils v30.0.9 (2026-07-14)
===============================

New Features
------------

- Added ``DeprecatedDict`` mapping.
This can be used to configure a `dict` that issues deprecation warnings when certain keys are accessed.

lsst-utils v30.0.0 (2026-01-15)
===============================

Expand Down
30 changes: 30 additions & 0 deletions python/lsst/utils/argparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,36 @@ class AppendDict(argparse.Action):
does not contain exactly one "=" character is invalid. If the default value
is non-empty, the default key-value pairs may be overwritten by values from
the command line.

Parameters
----------
option_strings : `str` | `list` [ `str` ]
The command-line option strings that trigger this action, e.g.
``--config``.
dest : `str`
The name of the `~argparse.Namespace` attribute in which the
accumulated `dict` is stored.
nargs : `int` | `str` | `None`, optional
The number of command-line arguments consumed each time the option
appears, as accepted by `argparse.ArgumentParser.add_argument`.
const : `typing.Any` | `None`, optional
A constant value required by some ``nargs`` settings; unused by this
action.
default : `typing.Any` | `None`, optional
The initial value of the mapping if the option does not appear on the
command line. Must be a `~collections.abc.Mapping` or `None`; `None`
is converted to an empty `dict`.
type : `type` | `None`, optional
A callable applied by argparse to each command-line argument before
it is passed to this action.
choices : `typing.Any` | `None`, optional
A container of the allowable values for the argument.
required : `bool`, optional
Whether the option must appear on the command line.
help : `str` | `None`, optional
A brief description of the argument for usage messages.
metavar : `str` | `None`, optional
The name for the argument's value(s) in usage messages.
"""

def __init__(
Expand Down
83 changes: 64 additions & 19 deletions python/lsst/utils/plotting/publication_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@


def set_rubin_plotstyle() -> None:
"""
Set the matplotlib style for Rubin publications
"""
"""Set the matplotlib style for Rubin publications."""
from matplotlib import style

style.use("lsst.utils.plotting.rubin")
Expand Down Expand Up @@ -98,16 +96,33 @@ def mk_colormap(colorNames): # type: ignore


def divergent_cmap(): # type: ignore
"""
Make a divergent color map.
"""Make a divergent color map.

Returns
-------
cmap : `matplotlib.colors.LinearSegmentedColormap`
A colormap stepping from the standard stars color through
gray to the accent color.
"""
cmap = mk_colormap([stars_color(), "#D9DCDE", accent_color()])

return cmap


def stars_cmap(single_color=False): # type: ignore
"""Make a color map for stars."""
"""Make a color map for stars.

Parameters
----------
single_color : `bool`, optional
If `True` use the standard stars color.

Returns
-------
cmap : `matplotlib.colors.Colormap`
A colormap derived from the standard stars color if
``single_color`` is `True`, otherwise the seaborn "mako" palette.
"""
import seaborn as sns
from matplotlib.colors import ListedColormap

Expand All @@ -119,20 +134,35 @@ def stars_cmap(single_color=False): # type: ignore


def stars_color() -> str:
"""Return the star color string for lines"""
"""Return the star color string for lines."""
return "#084d96"


def accent_color() -> str:
"""Return a contrasting color for overplotting,
black is the best for this but if you need two colors
"""Return a contrasting color for overplotting.

Notes
-----
Black is the best for this but if you need two colors
this works well on blue.
"""
return "#DE8F05"


def galaxies_cmap(single_color=False): # type: ignore
"""Make a color map for galaxies."""
def galaxies_cmap(single_color: bool = False): # type: ignore
"""Make a color map for galaxies.

Parameters
----------
single_color : `bool`, optional
If `True` use the standard galaxies color.

Returns
-------
cmap : `matplotlib.colors.LinearSegmentedColormap` or `str`
A colormap derived from the standard galaxies color if
``single_color`` is `True`, otherwise the colormap name "inferno".
"""
if single_color:
cmap = mk_colormap([galaxies_color()])
else:
Expand All @@ -141,17 +171,29 @@ def galaxies_cmap(single_color=False): # type: ignore


def galaxies_color() -> str:
"""Return the galaxy color string for lines"""
"""Return the galaxy color string for lines."""
return "#961A45"


def sso_color() -> str:
"""Return the SSO color string for lines"""
"""Return the SSO color string for lines."""
return "#01694c"


def sso_cmap(single_color=False): # type: ignore
"""Make a color map for solar system objects."""
def sso_cmap(single_color: bool = False): # type: ignore
"""Make a color map for solar system objects.

Parameters
----------
single_color : `bool`, optional
If `True` use the standard SSO color.

Returns
-------
cmap : `matplotlib.colors.LinearSegmentedColormap` or `str`
A colormap derived from the standard SSO color if
``single_color`` is `True`, otherwise the colormap name "viridis".
"""
if single_color:
cmap = mk_colormap([sso_color()])
else:
Expand All @@ -160,16 +202,19 @@ def sso_cmap(single_color=False): # type: ignore


def get_band_dicts() -> dict:
"""
Define palettes, from RTN-045. This includes dicts for colors (bandpass
colors for white background), colors_black (bandpass colors for
black background), plot symbols, and line_styles, keyed on band (ugrizy).
"""Define palettes, from RTN-045.

Returns
-------
band_dict : `dict` of `dict`
Dicts of colors, colors_black, symbols, and line_styles,
keyed on bands 'u', 'g', 'r', 'i', 'z', and 'y'.

Notes
-----
This includes dicts for colors (bandpass colors for white background),
colors_black (bandpass colors for black background), plot symbols, and
line_styles, keyed on band (ugrizy).
"""
colors = get_multiband_plot_colors()
colors_black = get_multiband_plot_colors(dark_background=True)
Expand Down
13 changes: 12 additions & 1 deletion tests/decorator_test/disable_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@

@timeMethod(logger=log, logLevel=logging.INFO)
def sleep_and_log(self, duration: float) -> None:
"""Check that this does not log if the decorator was disabled on import."""
"""Check that this does not log if the decorator was disabled on import.

Parameters
----------
duration : `float`
Time to sleep.
"""
time.sleep(duration)


@timeMethod
def sleep_and_nothing(self, duration: float) -> None:
"""Check that this does not have a `__wrapped__` attribute to confirm that
the decorator is disabled.

Parameters
----------
duration : `float`
Time to sleep.
"""
time.sleep(duration)
Loading