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

[pre-commit.ci] pre-commit autoupdate #841

Closed
wants to merge 2 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exclude: '^/ccdproc/extern/.*.py|.*\.fits?$'
# | .*\.fits?$ # Ignore FITS files
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand Down
75 changes: 41 additions & 34 deletions ccdproc/extern/bitfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import numpy as np


__version__ = '1.1.1'
__vdate__ = '30-January-2018'
__author__ = 'Mihai Cara'
__version__ = "1.1.1"
__vdate__ = "30-January-2018"
__author__ = "Mihai Cara"


__all__ = ['bitfield_to_boolean_mask', 'interpret_bit_flags', 'is_bit_flag']
__all__ = ["bitfield_to_boolean_mask", "interpret_bit_flags", "is_bit_flag"]


# Revision history:
Expand Down Expand Up @@ -52,11 +52,16 @@
# the argument `bitfield` can hold.
# 1.1.1 (30-January-2018) - Improved filtering of high bits in flags.
#
INT_TYPE = (int, long,) if sys.version_info < (3,) else (int,)
INT_TYPE = (
(
int,
long,
)
if sys.version_info < (3,)
else (int,)
)
MAX_UINT_TYPE = np.uint64
SUPPORTED_FLAGS = int(np.bitwise_not(
0, dtype=MAX_UINT_TYPE, casting='unsafe'
))
SUPPORTED_FLAGS = int(np.bitwise_not(0, dtype=MAX_UINT_TYPE, casting="unsafe"))


def is_bit_flag(n):
Expand All @@ -79,13 +84,12 @@ def is_bit_flag(n):
if n < 1:
return False

return bin(n).count('1') == 1
return bin(n).count("1") == 1


def _is_int(n):
return (
(isinstance(n, INT_TYPE) and not isinstance(n, bool)) or
(isinstance(n, np.generic) and np.issubdtype(n, np.integer))
return (isinstance(n, INT_TYPE) and not isinstance(n, bool)) or (
isinstance(n, np.generic) and np.issubdtype(n, np.integer)
)


Expand Down Expand Up @@ -152,7 +156,7 @@ def interpret_bit_flags(bit_flags, flip_bits=None):
allow_non_flags = False

if _is_int(bit_flags):
return (~int(bit_flags) if flip_bits else int(bit_flags))
return ~int(bit_flags) if flip_bits else int(bit_flags)

elif bit_flags is None:
if has_flip_bits:
Expand All @@ -172,12 +176,12 @@ def interpret_bit_flags(bit_flags, flip_bits=None):

bit_flags = str(bit_flags).strip()

if bit_flags.upper() in ['', 'NONE', 'INDEF']:
if bit_flags.upper() in ["", "NONE", "INDEF"]:
return None

# check whether bitwise-NOT is present and if it is, check that it is
# in the first position:
bitflip_pos = bit_flags.find('~')
bitflip_pos = bit_flags.find("~")
if bitflip_pos == 0:
flip_bits = True
bit_flags = bit_flags[1:].lstrip()
Expand All @@ -188,31 +192,33 @@ def interpret_bit_flags(bit_flags, flip_bits=None):

# basic check for correct use of parenthesis:
while True:
nlpar = bit_flags.count('(')
nrpar = bit_flags.count(')')
nlpar = bit_flags.count("(")
nrpar = bit_flags.count(")")

if nlpar == 0 and nrpar == 0:
break

if nlpar != nrpar:
raise ValueError("Unbalanced parantheses in bit flag list.")

lpar_pos = bit_flags.find('(')
rpar_pos = bit_flags.rfind(')')
lpar_pos = bit_flags.find("(")
rpar_pos = bit_flags.rfind(")")
if lpar_pos > 0 or rpar_pos < (len(bit_flags) - 1):
raise ValueError("Incorrect syntax (incorrect use of "
"parenthesis) in bit flag list.")
raise ValueError(
"Incorrect syntax (incorrect use of "
"parenthesis) in bit flag list."
)

bit_flags = bit_flags[1:-1].strip()

if ',' in bit_flags:
bit_flags = bit_flags.split(',')
if "," in bit_flags:
bit_flags = bit_flags.split(",")

elif '+' in bit_flags:
bit_flags = bit_flags.split('+')
elif "+" in bit_flags:
bit_flags = bit_flags.split("+")

else:
if bit_flags == '':
if bit_flags == "":
raise ValueError(
"Empty bit flag lists not allowed when either bitwise-NOT "
"or parenthesis are present."
Expand All @@ -221,7 +227,7 @@ def interpret_bit_flags(bit_flags, flip_bits=None):

allow_non_flags = len(bit_flags) == 1

elif hasattr(bit_flags, '__iter__'):
elif hasattr(bit_flags, "__iter__"):
if not all([_is_int(flag) for flag in bit_flags]):
raise TypeError("Each bit flag in a list must be an integer.")

Expand All @@ -235,8 +241,9 @@ def interpret_bit_flags(bit_flags, flip_bits=None):
bitmask = 0
for v in bitset:
if not is_bit_flag(v) and not allow_non_flags:
raise ValueError("Input list contains invalid (not powers of two) "
"bit flags")
raise ValueError(
"Input list contains invalid (not powers of two) " "bit flags"
)
bitmask += v

if flip_bits:
Expand All @@ -245,8 +252,9 @@ def interpret_bit_flags(bit_flags, flip_bits=None):
return bitmask


def bitfield_to_boolean_mask(bitfield, ignore_flags=0, flip_bits=None,
good_mask_value=True, dtype=np.bool_):
def bitfield_to_boolean_mask(
bitfield, ignore_flags=0, flip_bits=None, good_mask_value=True, dtype=np.bool_
):
r"""
bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \
good_mask_value=True, dtype=numpy.bool\_)
Expand Down Expand Up @@ -438,11 +446,10 @@ def bitfield_to_boolean_mask(bitfield, ignore_flags=0, flip_bits=None,
ignore_mask = ignore_mask & SUPPORTED_FLAGS

# invert the "ignore" mask:
ignore_mask = np.bitwise_not(ignore_mask, dtype=bitfield.dtype,
casting='unsafe')
ignore_mask = np.bitwise_not(ignore_mask, dtype=bitfield.dtype, casting="unsafe")

mask = np.empty_like(bitfield, dtype=np.bool_)
np.bitwise_and(bitfield, ignore_mask, out=mask, casting='unsafe')
np.bitwise_and(bitfield, ignore_mask, out=mask, casting="unsafe")

if good_mask_value:
np.logical_not(mask, out=mask)
Expand Down
1 change: 0 additions & 1 deletion ccdproc/tests/data/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ Data directory
This directory contains data files included with the affiliated package source
code distribution. Note that this is intended only for relatively small files
- large files should be externally hosted and downloaded as needed.

1 change: 0 additions & 1 deletion docs/_static/ccdproc.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ div.topbar a.brand {
background-size: 32px 32px;

}

2 changes: 1 addition & 1 deletion docs/_templates/autosummary/base.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% extends "autosummary_core/base.rst" %}
{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}
{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}
2 changes: 1 addition & 1 deletion docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% extends "autosummary_core/class.rst" %}
{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}
{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}
2 changes: 1 addition & 1 deletion docs/_templates/autosummary/module.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% extends "autosummary_core/module.rst" %}
{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}
{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #}
48 changes: 25 additions & 23 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
#
# Astropy documentation build configuration file.
Expand Down Expand Up @@ -33,7 +32,9 @@
try:
from sphinx_astropy.conf.v1 import * # noqa
except ImportError:
print('ERROR: the documentation requires the sphinx-astropy package to be installed')
print(
"ERROR: the documentation requires the sphinx-astropy package to be installed"
)
sys.exit(1)

if sys.version_info < (3, 11):
Expand All @@ -50,7 +51,7 @@
# -- General configuration ----------------------------------------------------

# By default, highlight as Python 3.
highlight_language = 'python3'
highlight_language = "python3"

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.2'
Expand All @@ -61,7 +62,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns.append('_templates')
exclude_patterns.append("_templates")

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
Expand Down Expand Up @@ -103,64 +104,65 @@

# 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 = 'bootstrap-ccdproc'
# html_theme = 'bootstrap-ccdproc'


html_theme_options = {
'logotext1': 'ccd', # white, semi-bold
'logotext2': 'proc', # orange, light
'logotext3': ':docs' # white, light
"logotext1": "ccd", # white, semi-bold
"logotext2": "proc", # orange, light
"logotext3": ":docs", # white, light
}


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

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = ''
# html_logo = ''

# 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 = ''
from os.path import join
html_favicon = join('_static', 'ccd_proc.ico')

html_favicon = join("_static", "ccd_proc.ico")

# 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 = '{0} v{1}'.format(project, release)
html_title = f"{project} v{release}"

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

# Static files to copy after template files
html_static_path = ['_static']
html_style = 'ccdproc.css'
html_static_path = ["_static"]
html_style = "ccdproc.css"

# -- 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)]


# -- Options for the edit_on_github extension ---------------------------------
Expand All @@ -179,7 +181,7 @@
# edit_on_github_doc_root = "docs"

# -- Resolving issue number to links in changelog -----------------------------
github_issues_url = 'https://github.com/astropy/ccdproc/issues/'
github_issues_url = "https://github.com/astropy/ccdproc/issues/"

# -- Turn on nitpicky mode for sphinx (to warn about references not found) ----
#
Expand Down
1 change: 0 additions & 1 deletion docs/reduction_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Here are some examples and different repositories using `ccdproc`.
.. _reduceccd: https://github.com/rgbIAA/reduceccd
.. _astrolib: https://github.com/yucelkilic/astrolib
.. _mont4k_reduction: https://github.com/bjweiner/ARTN/tree/master/mont4k_pipeline

Loading