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

Add T&S pre-commit settings to ts_imsim. #15

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 19 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ChangelogUpdated
on:
pull_request:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- develop
jobs:
build:
name: Check Actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Changelog check
uses: Zomzog/[email protected]
with:
fileName: doc/versionHistory.rst
checkNotification: Simple
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: lint

on:
- push
- pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Install
run: |
$CONDA/bin/conda install -c lsstts -y ts-pre-commit-config">=0.9.2"
$CONDA/bin/conda install -c conda-forge pre-commit -y
$CONDA/bin/generate_pre_commit_conf --skip-pre-commit-install

- name: Run pre commit checks
run: $CONDA/bin/pre-commit run --all
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ config.log
*Lib.py

# Pre-commit configs
.pre-commit-config.yaml
.mypy.ini
.flake8
.isort.cfg
.mypy.ini

# Built by sconsUtils
version.py
Expand All @@ -37,3 +36,4 @@ pytest_session.txt

# MacOS metadata
.DS_Store
.clang-format
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
teweitsai marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8

- repo: https://github.com/lsst-ts/pre-commit-xmllint
rev: v1.0.0
hooks:
- id: format-xmllint

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
exclude: conda/meta.yaml|^policy/config/[input|image|output|stamp|opd]
- id: check-xml

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
8 changes: 8 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ignore = ["E203", "E226", "E228", "E999", "N802", "N803", "N806", "N812", "N813", "N815", "N816", "N999"]
line-length = 110
exclude = ["__init__.py", "doc/conf.py"]
select = ["E", "F", "N", "W"]
[pycodestyle]
max-doc-length = 79
[pydocstyle]
convention = "numpy"
8 changes: 6 additions & 2 deletions .ts_pre_commit_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
check-yaml: true
check-xml: true
black: true
check-xml: true
check-yaml: true
clang-format: false
flake8: true
format-xmllint: false
isort: true
mypy: false
ruff: true
towncrier: false
8 changes: 4 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

import os

import lsst.ts.imsim
from documenteer.conf.pipelinespkg import *
import lsst.ts.imsim # noqa
from documenteer.conf.pipelinespkg import * # noqa

project = "ts_imsim"
html_theme_options["logotext"] = project
html_theme_options["logotext"] = project # noqa
html_title = project
html_short_title = project
doxylink = {}


# Support the sphinx extension of plantuml
extensions.append("sphinxcontrib.plantuml")
extensions.append("sphinxcontrib.plantuml") # noqa

# Put the path to plantuml.jar
plantuml_path = (
Expand Down
6 changes: 6 additions & 0 deletions doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
Version History
##################

-------------
0.6.4
-------------

* Add T&S pre-commit settings to ts_imsim.

-------------
0.6.3
-------------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ts/imsim/closedLoopTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def _generate_images(
imsim_config_yaml["output"]["opd"]["file_name"],
)
if os.path.exists(imsimOpdPath):
self.log.info(f"OPD already created, moving to analysis.")
self.log.info("OPD already created, moving to analysis.")
else:
self.log.info(
f"Writing Imsim Configuration file to {imsim_config_path}"
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/ts/imsim/imsimCmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ def add_config_header(self, obs_metadata: ObsMetadata) -> str:
Header information for ImSim config
"""
header_text = " header:\n"
header_text += f" mjd: *mjd\n"
header_text += " mjd: *mjd\n"
header_text += (
f" observationStartMJD: {obs_metadata.mjd - (15/(60*60*24))}\n"
)
header_text += f" seqnum: *seqnum\n"
header_text += f" band: *band\n"
header_text += " seqnum: *seqnum\n"
header_text += " band: *band\n"
header_text += f" fieldRA: {obs_metadata.ra}\n"
header_text += f" fieldDec: {obs_metadata.dec}\n"
header_text += f" rotTelPos: {obs_metadata.rotator_angle}\n"
Expand Down Expand Up @@ -605,8 +605,8 @@ def _map_opd_to_zk(self, rot_opd_in_deg: float, num_opd: int) -> np.ndarray:
opd_rot = opd.copy()
# Since to rotate the opd we need to substitue the nan values
# for zeros, we need to find the minimum value of the opd
# excluding the nan values. Then after the rotation we will discard
# the values that are smaller than the minimum value.
# excluding the nan values. Then after the rotation we will
# discard the values that are smaller than the minimum value.
# Note that we use order = 0 to avoid interpolation errors.
min_value = np.nanmin(np.abs(opd_rot))
opd_rot[np.isnan(opd_rot)] = 0.0
Expand Down
2 changes: 0 additions & 2 deletions python/lsst/ts/imsim/opdMetrology.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

__all__ = ["OpdMetrology"]

import os

import numpy as np
import yaml
from astropy.io import fits
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ts/imsim/skySim.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

class SkySim:
"""Initialization of sky simulator class."""

def __init__(self) -> None:
# Star ID
self.star_id = np.array([], dtype=int)
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ts/imsim/utils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def __enter__(self) -> None:

def __exit__(self, exc_type: None, exc_val: None, exc_tb: None) -> None:
for key in self._overrides:
# Restore original values, delete or keep as they are based on the original state
# Restore original values, delete or keep as they are
# based on the original state.
if key in self._originals:
os.environ[key] = self._originals[key]
else:
Expand Down
13 changes: 0 additions & 13 deletions setup.cfg

This file was deleted.

Loading