Skip to content

Commit

Permalink
Make clean with ruff pydocstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jul 12, 2023
1 parent e87b1b4 commit ecc2136
Show file tree
Hide file tree
Showing 30 changed files with 100 additions and 50 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ ignore = [
"D100",
"D200",
"D205",
"D400",
]
line-length = 110
select = [
"E", # pycodestyle
"F", # pyflakes
"N", # pep8-naming
"W", # pycodestyle
"D", # pydocstyle
]
target-version = "py310"
extend-select = [
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def getCamera(self) -> Camera:
@classmethod
@lru_cache
def getObsDataPackageDir(cls) -> str | None:
"""The root of the obs data package that provides specializations for
this instrument.
"""Return the root of the obs data package that provide
specializations for this instrument.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/_read_curated_calibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def check_metadata(
filepath: str,
data_name: str,
) -> None:
"""Check that the metadata is complete and self consistent
"""Check that the metadata is complete and self consistent.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/butler_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_get_linearizer(self):
linearizer.checkDetector(detector)

def test_get_linearizer_bad_detectorIds(self):
"""Do bad detectorIds raise?"""
"""Check that bad detectorIds raise."""
if self.butler_get_data.linearizer_type is unittest.SkipTest:
self.skipTest("Skipping %s as requested" % (inspect.currentframe().f_code.co_name))

Expand Down
6 changes: 2 additions & 4 deletions python/lsst/obs/base/camera_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ def _butler_args(self):
return kwargs

def test_iterable(self):
"""Simplest camera test: can we get a Camera instance, and does
iterating return Detectors?
"""
"""Get a camera instance and check it is an iterable."""
camera = self.butler.get("camera", **self._butler_args())
self.assertIsInstance(camera, lsst.afw.cameraGeom.Camera)
for detector in camera:
Expand All @@ -101,7 +99,7 @@ def test_camera_butler(self):
self.assertEqual(next(iter(camera)).getName(), self.camera_data.first_detector_name)

def test_plate_scale(self):
"""Check the plate scale at center of focal plane
"""Check the plate scale at center of focal plane.
Check plate_scale using the FOCAL_PLANE to FIELD_ANGLE transform
from the camera.
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def define_visits(*args, **kwargs):
@failfast_option()
@options_file_option()
def ingest_raws(*args, **kwargs):
"""Ingest raw frames into from a directory into the butler registry"""
"""Ingest raw frames into from a directory into the butler registry."""
script.ingestRaws(*args, **kwargs)


Expand Down
3 changes: 3 additions & 0 deletions python/lsst/obs/base/cli/doc/butlerCmdDocGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@


class ButlerCmdDocGen(click.MultiCommand):
"""Provide access of butler subcommand plugins to Sphinx."""

def list_commands(self, ctx):
"""List the click commands provided by this package.
Expand Down Expand Up @@ -65,4 +67,5 @@ def get_command(self, context, name):

@click.command(cls=ButlerCmdDocGen)
def cli():
"""Run the command."""
pass
6 changes: 5 additions & 1 deletion python/lsst/obs/base/defineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class _VisitRecords:


class GroupExposuresConfig(Config):
pass
"""Configure exposure grouping."""


class GroupExposuresTask(Task, metaclass=ABCMeta):
Expand Down Expand Up @@ -276,6 +276,8 @@ def getVisitSystems(self) -> set[VisitSystem]:


class ComputeVisitRegionsConfig(Config):
"""Configure visit region calculations."""

padding: Field[int] = Field(
dtype=int,
default=250,
Expand Down Expand Up @@ -373,6 +375,8 @@ def compute(


class DefineVisitsConfig(Config):
"""Configure visit definition."""

groupExposures = GroupExposuresTask.registry.makeField(
doc="Algorithm for grouping exposures into visits.",
default="one-to-one-and-by-counter",
Expand Down
6 changes: 5 additions & 1 deletion python/lsst/obs/base/exposureAssembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@


class ExposureAssembler(StorageClassDelegate):
"""Knowledge of how to assemble and disassemble an
`~lsst.afw.image.Exposure`.
"""

EXPOSURE_COMPONENTS = {"image", "variance", "mask", "wcs", "psf"}
EXPOSURE_INFO_COMPONENTS = {
"apCorrMap",
Expand Down Expand Up @@ -85,7 +89,7 @@ def _groupRequestedComponents(self) -> tuple[set[str], set[str]]:
return expItems, expInfoItems

def getComponent(self, composite: lsst.afw.image.Exposure, componentName: str) -> Any:
"""Get a component from an Exposure
"""Get a component from an Exposure.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/exposureIdInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ExposureIdInfo:
"""

def __init__(self, expId: int = 0, expBits: int = 1, maxBits: int | None = None):
"""Construct an ExposureIdInfo
"""Construct an ExposureIdInfo.
See the class doc string for an explanation of the arguments.
"""
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/base/formatters/fitsExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def validateWriteRecipes(cls, recipes):
return recipes

def checkUnrecognized(entry, allowed, description):
"""Check to see if the entry contains unrecognised keywords"""
"""Check to see if the entry contains unrecognised keywords."""
unrecognized = set(entry) - set(allowed)
if unrecognized:
raise RuntimeError(
Expand Down Expand Up @@ -426,7 +426,7 @@ def readComponent(self, component):


def standardizeAmplifierParameters(parameters, on_disk_detector):
"""Preprocess the Exposure storage class's "amp" and "detector" parameters
"""Preprocess the Exposure storage class's "amp" and "detector" parameters.
This checks the given objects for consistency with the on-disk geometry and
converts amplifier IDs/names to Amplifier instances.
Expand Down
7 changes: 4 additions & 3 deletions python/lsst/obs/base/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def extractMetadata(self, filename: ResourcePath) -> RawFileData:

@classmethod
def getObservationInfoSubsets(cls) -> tuple[set, set]:
"""Return subsets of fields in the `ObservationInfo` that we care about
"""Return subsets of fields in the `ObservationInfo` that we care
about.
These fields will be used in constructing an exposure record.
Expand Down Expand Up @@ -797,7 +798,7 @@ def groupByExposure(self, files: Iterable[RawFileData]) -> list[RawExposureData]
def makeExposureRecord(
self, obsInfo: ObservationInfo, universe: DimensionUniverse, **kwargs: Any
) -> DimensionRecord:
"""Construct a registry record for an exposure
"""Construct a registry record for an exposure.
This is a method that subclasses will often want to customize. This can
often be done by calling this base class implementation with additional
Expand All @@ -823,7 +824,7 @@ def makeExposureRecord(
def makeDependencyRecords(
self, obsInfo: ObservationInfo, universe: DimensionUniverse
) -> dict[str, DimensionRecord]:
"""Construct dependency records
"""Construct dependency records.
These dependency records will be inserted into the
`~lsst.daf.butler.Registry` before the exposure records, because they
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/obs/base/instrument_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def getMetadata(self) -> dict[str, Any]:


class DummyCam(Instrument):
"""Instrument class used for testing."""

filterDefinitions = DUMMY_FILTER_DEFINITIONS
additionalCuratedDatasetTypes = frozenset(["testCalib"])
policyName = "dummycam"
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/makeRawVisitInfoViaObsInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __call__(self, md):
@staticmethod
def observationInfo2visitInfo(obsInfo, log=None):
"""Construct a `~lsst.afw.image.VisitInfo` from an
`~astro_metadata_translator.ObservationInfo`
`~astro_metadata_translator.ObservationInfo`.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/script/defineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def defineVisits(
incremental=False,
raw_name="raw",
):
"""Implements the command line interface `butler define-visits` subcommand,
"""Implement the command line interface `butler define-visits` subcommand,
should only be called by command line tools and unit test code that tests
this function.
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/script/ingestRaws.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def ingestRaws(
ingest_task="lsst.obs.base.RawIngestTask",
track_file_attrs=True,
):
"""Ingests raw frames into the butler registry
"""Ingests raw frames into the butler registry.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def createInitialSkyWcsFromBoresight(boresight, orientation, detector, flipX=Fal


def bboxFromIraf(irafBBoxStr):
"""Return a Box2I corresponding to an IRAF-style BBOX
"""Return a Box2I corresponding to an IRAF-style BBOX.
[x0:x1,y0:y1] where x0 and x1 are the one-indexed start and end columns,
and correspondingly y0 and y1 are the start and end rows.
Expand Down
23 changes: 11 additions & 12 deletions python/lsst/obs/base/yamlCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

@lru_cache
def makeCamera(cameraFile):
"""An imaging camera (e.g. the LSST 3Gpix camera)
"""Construct an imaging camera (e.g. the LSST 3Gpix camera).
Parameters
----------
Expand Down Expand Up @@ -68,7 +68,7 @@ def makeCamera(cameraFile):


def makeDetectorConfigList(ccdParams):
"""Make a list of detector configs
"""Make a list of detector configs.
Returns
-------
Expand Down Expand Up @@ -111,7 +111,7 @@ def makeDetectorConfigList(ccdParams):


def makeAmplifierList(ccd):
"""Construct a list of AmplifierBuilder objects"""
"""Construct a list of AmplifierBuilder objects."""
# Much of this will need to be filled in when we know it.
assert len(ccd) > 0
amp = list(ccd["amplifiers"].values())[0]
Expand Down Expand Up @@ -198,15 +198,15 @@ def makeAmpInfoCatalog(ccd):

def makeBBoxFromList(ylist):
"""Given a list [(x0, y0), (xsize, ysize)], probably from a yaml file,
return a BoxI
return a BoxI.
"""
(x0, y0), (xsize, ysize) = ylist
return geom.BoxI(geom.PointI(x0, y0), geom.ExtentI(xsize, ysize))


def makeTransformDict(nativeSys, transformDict, plateScale):
"""Make a dictionary of TransformPoint2ToPoint2s from yaml, mapping from
nativeSys
nativeSys.
Parameters
----------
Expand Down Expand Up @@ -276,7 +276,7 @@ def makeCameraFromCatalogs(
pupilFactoryClass=cameraGeom.pupil.PupilFactory,
):
"""Construct a Camera instance from a dictionary of
detector name : `lsst.afw.cameraGeom.amplifier`
detector name and `lsst.afw.cameraGeom.amplifier`.
Parameters
----------
Expand All @@ -290,12 +290,11 @@ def makeCameraFromCatalogs(
transformDict : `dict`
A dict of lsst.afw.cameraGeom.CameraSys :
`lsst.afw.geom.TransformPoint2ToPoint2`
amplifierDict : `dict`
A dictionary of detector name :
`lsst.afw.cameraGeom.Amplifier.Builder`
pupilFactoryClass : `type`, optional
Class to attach to camera;
`lsst.default afw.cameraGeom.PupilFactory`
amplifierDict : `dict` [`str`, `lsst.afw.cameraGeom.Amplifier.Builder` ]
A dictionary of detector name and amplifier builders.
pupilFactoryClass : `type` [ `lsst.default afw.cameraGeom.PupilFactory`], \
optional
Class to attach to camera.
Returns
-------
Expand Down
8 changes: 5 additions & 3 deletions tests/test_butlerFits.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@


class ButlerFitsTests(lsst.utils.tests.TestCase):
"""Tests for butler interaction with FITS files."""

@classmethod
def setUpClass(cls):
"""Create a new butler once only."""
Expand Down Expand Up @@ -214,7 +216,7 @@ def testFundamentalTypes(self) -> None:
self.runFundamentalTypeTest("pl", pl)

def testFitsCatalog(self) -> None:
"""Test reading of a FITS catalog"""
"""Test reading of a FITS catalog."""
catalog = self.makeExampleCatalog()
dataId = {"visit": 42, "instrument": "DummyCam", "physical_filter": "d-r"}
ref = self.butler.put(catalog, "testCatalog", dataId)
Expand All @@ -227,14 +229,14 @@ def testFitsCatalog(self) -> None:
self.assertEqual(len(astropy_table), len(stored))

def testExposureCompositePutGetConcrete(self) -> None:
"""Test composite with no disassembly"""
"""Test composite with no disassembly."""
ref = self.runExposureCompositePutGetTest("calexp")

uri = self.butler.getURI(ref)
self.assertTrue(uri.exists(), f"Checking URI {uri} existence")

def testExposureCompositePutGetVirtual(self) -> None:
"""Testing composite disassembly"""
"""Testing composite disassembly."""
ref = self.runExposureCompositePutGetTest("unknown")

primary, components = self.butler.getURIs(ref)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_cliCmdDefineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@


class DefineVisitsTest(CliCmdTestBase, unittest.TestCase):
"""Test the define-visits command-line tool."""

mockFuncName = "lsst.obs.base.cli.cmd.commands.script.defineVisits"

@staticmethod
Expand Down Expand Up @@ -82,7 +84,7 @@ def test_all(self):
)

def test_missing(self):
"""Test a missing argument"""
"""Test a missing argument."""
self.run_missing(["define-visits"], "Missing argument ['\"]REPO['\"]")
self.run_missing(["define-visits", "here"], "Missing argument ['\"]INSTRUMENT['\"]")

Expand Down
Loading

0 comments on commit ecc2136

Please sign in to comment.