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

apply ruff format . and ruff check --fix . #144

Closed
wants to merge 4 commits into from
Closed
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
46 changes: 22 additions & 24 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
else:
import tomllib

#sys.path.insert(0, os.path.abspath('../'))
# sys.path.insert(0, os.path.abspath('../'))


def find_mod_objs_patched(*args, **kwargs):
Expand All @@ -73,26 +73,26 @@ def setup(app):


extensions = [
'sphinx_automodapi.automodapi',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
"sphinx_automodapi.automodapi",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
]
# -- General configuration ----------------------------------------------------

master_doc = 'index'
master_doc = "index"

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.2'
# needs_sphinx = '1.2'

# To perform a Sphinx version check that needs to be more specific than
# major.minor, call `check_sphinx_version("x.y.z")` here.
# check_sphinx_version("1.2.1")

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_templates']
exclude_patterns = ["_templates"]

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
Expand All @@ -102,9 +102,9 @@ def setup(app):
# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = metadata['name']
author = metadata['authors'][0]['name']
copyright = f'{datetime.datetime.now().year}, {author }'
project = metadata["name"]
author = metadata["authors"][0]["name"]
copyright = f"{datetime.datetime.now().year}, {author }"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -114,7 +114,7 @@ def setup(app):
package = sys.modules[project]

# The short X.Y version.
version = package.__version__.split('-', 1)[0]
version = package.__version__.split("-", 1)[0]
# The full version, including alpha/beta/rc tags.
release = package.__version__

Expand All @@ -130,44 +130,42 @@ def setup(app):

# Add any paths that contain custom themes here, relative to this directory.
# To use a different custom theme, add the directory containing the theme.
#html_theme_path = []
# html_theme_path = []

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. To override the custom theme, set this to the
# name of a builtin theme or the name of a custom theme in html_theme_path.
#html_theme = None
# html_theme = None

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# html_sidebars = {}

# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = ''
# html_favicon = ''

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = ''
# html_last_updated_fmt = ''

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = f'{project} v{release}'
html_title = f"{project} v{release}"

# Output file base name for HTML help builder.
htmlhelp_basename = project + 'doc'
htmlhelp_basename = project + "doc"


# -- Options for LaTeX output --------------------------------------------------

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [('index', project + '.tex', project + u' Documentation',
author, 'manual')]
latex_documents = [("index", project + ".tex", project + " Documentation", author, "manual")]


# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [('index', project.lower(), project + u' Documentation',
[author], 1)]
man_pages = [("index", project.lower(), project + " Documentation", [author], 1)]
3 changes: 2 additions & 1 deletion drizzle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
A package for combining dithered images into a single image
"""

from importlib.metadata import PackageNotFoundError, version


try:
__version__ = version(__name__)
except PackageNotFoundError:
# package is not installed
__version__ = 'unknown'
__version__ = "unknown"

Check warning on line 12 in drizzle/__init__.py

View check run for this annotation

Codecov / codecov/patch

drizzle/__init__.py#L12

Added line #L12 was not covered by tests
4 changes: 2 additions & 2 deletions drizzle/calc_pixmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def calc_pixmap(first_wcs, second_wcs):
# between the pixel co-ordinates in the first image to pixel co-ordinates in the
# co-ordinate system of the second.

one = np.ones(2, dtype='float64')
idxmap = np.indices((first_naxis1, first_naxis2), dtype='float64')
one = np.ones(2, dtype="float64")
idxmap = np.indices((first_naxis1, first_naxis2), dtype="float64")
idxmap = idxmap.transpose() + one

idxmap = idxmap.reshape(first_naxis2 * first_naxis1, 2)
Expand Down
27 changes: 23 additions & 4 deletions drizzle/doblot.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
"""
STScI Python compatable blot module
"""

import numpy as np

from drizzle import calc_pixmap
from drizzle import cdrizzle


def doblot(source, source_wcs, blot_wcs, exptime, coeffs=True,
interp='poly5', sinscl=1.0, stepsize=10, wcsmap=None):
def doblot(
source,
source_wcs,
blot_wcs,
exptime,
coeffs=True,
interp="poly5",
sinscl=1.0,
stepsize=10,
wcsmap=None,
):
"""
Low level routine for performing the 'blot' operation.

Expand Down Expand Up @@ -74,7 +84,16 @@ def doblot(source, source_wcs, blot_wcs, exptime, coeffs=True,
pixmap = calc_pixmap.calc_pixmap(blot_wcs, source_wcs)
pix_ratio = source_wcs.pscale / blot_wcs.pscale

cdrizzle.tblot(source, pixmap, _outsci, scale=pix_ratio, kscale=1.0,
interp=interp, exptime=exptime, misval=0.0, sinscl=sinscl)
cdrizzle.tblot(
source,
pixmap,
_outsci,
scale=pix_ratio,
kscale=1.0,
interp=interp,
exptime=exptime,
misval=0.0,
sinscl=sinscl,
)

return _outsci
58 changes: 44 additions & 14 deletions drizzle/dodrizzle.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
"""
STScI Python compatable drizzle module
"""

import numpy as np

from . import util
from . import calc_pixmap
from . import cdrizzle


def dodrizzle(insci, input_wcs, inwht,
output_wcs, outsci, outwht, outcon,
expin, in_units, wt_scl,
wcslin_pscale=1.0, uniqid=1,
xmin=0, xmax=0, ymin=0, ymax=0,
pixfrac=1.0, kernel='square', fillval="INDEF"):
def dodrizzle(
insci,
input_wcs,
inwht,
output_wcs,
outsci,
outwht,
outcon,
expin,
in_units,
wt_scl,
wcslin_pscale=1.0,
uniqid=1,
xmin=0,
xmax=0,
ymin=0,
ymax=0,
pixfrac=1.0,
kernel="square",
fillval="INDEF",
):
"""
Low level routine for performing 'drizzle' operation.on one image.

Expand Down Expand Up @@ -134,18 +150,18 @@
# Ensure that the fillval parameter gets properly interpreted
# for use with tdriz
if util.is_blank(fillval):
fillval = 'INDEF'
fillval = "INDEF"

Check warning on line 153 in drizzle/dodrizzle.py

View check run for this annotation

Codecov / codecov/patch

drizzle/dodrizzle.py#L153

Added line #L153 was not covered by tests
else:
fillval = str(fillval)

if in_units == 'cps':
if in_units == "cps":
expscale = 1.0
else:
expscale = expin

# Add input weight image if it was not passed in

if (insci.dtype > np.float32):
if insci.dtype > np.float32:
insci = insci.astype(np.float32)

if inwht is None:
Expand Down Expand Up @@ -180,10 +196,24 @@
# This call to 'cdriz.tdriz' uses the new C syntax
#
_vers, nmiss, nskip = cdrizzle.tdriz(
insci, inwht, pixmap, outsci, outwht, outcon,
uniqid=uniqid, xmin=xmin, xmax=xmax,
ymin=ymin, ymax=ymax, scale=pix_ratio, pixfrac=pixfrac,
kernel=kernel, in_units=in_units, expscale=expscale,
wtscale=wt_scl, fillstr=fillval)
insci,
inwht,
pixmap,
outsci,
outwht,
outcon,
uniqid=uniqid,
xmin=xmin,
xmax=xmax,
ymin=ymin,
ymax=ymax,
scale=pix_ratio,
pixfrac=pixfrac,
kernel=kernel,
in_units=in_units,
expscale=expscale,
wtscale=wt_scl,
fillstr=fillval,
)

return _vers, nmiss, nskip
Loading
Loading