Skip to content

Commit

Permalink
Merge pull request #21 from ajshajib/formatting
Browse files Browse the repository at this point in the history
Code formatting with black and docformatter
  • Loading branch information
sibirrer authored Dec 1, 2023
2 parents d442686 + f6b8523 commit 2e70aeb
Show file tree
Hide file tree
Showing 90 changed files with 4,597 additions and 2,258 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pytest
python -m pip install flake8 pytest pytest-cov coveralls
python -m pip install flake8 pytest pytest-cov
python -m pip install codecov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test_requirements.txt ]; then pip install -r test_requirements.txt; fi
python -m pip install .
Expand All @@ -36,15 +37,23 @@ jobs:
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest --cov=hierarc
- name: Test with pytest
run: |
pytest --cov=./ --cov-report=xml
codecov
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --service=github
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./coverage.xml

# - name: Coveralls
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# coveralls --service=github

# from this source for coveralls: https://github.com/marketplace/actions/coveralls-github-action
#- uses: actions/checkout@v1
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ ENV/
.mypy_cache/

# IDE settings
.vscode/
.vscode/
.idea/
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
skip: []
submodules: false

repos:
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black-jupyter
language_version: python3
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [-r, --black, --in-place]

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ clean-test: ## remove test and coverage artifacts

lint: ## check style with flake8
flake8 hierarc tests
black .
docformatter -r ./* --black --in-place

test: ## run tests quickly with the default Python
pytest
Expand Down
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ hierArc
:target: http://www.astropy.org
:alt: Powered by Astropy Badge

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black

.. image:: https://img.shields.io/badge/%20formatter-docformatter-fedcba.svg
:target: https://github.com/PyCQA/docformatter

.. image:: https://img.shields.io/badge/%20style-sphinx-0a507a.svg
:target: https://www.sphinx-doc.org/en/master/usage/index.html



Hierarchical analysis of strong lensing systems to infer lens properties and cosmological parameters simultaneously.
Expand Down
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
comment: # this is a top-level key
layout: " diff, flags, files"
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: false # [true :: must have a base report to post]
require_head: true # [true :: must have a head report to post]
56 changes: 24 additions & 32 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

import hierarc

Expand All @@ -31,22 +32,22 @@

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'hierArc'
project = "hierArc"
copyright = "2020, Simon Birrer"
author = "Simon Birrer"

Expand All @@ -64,15 +65,15 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -83,7 +84,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
html_theme = "default"

# Theme options are theme-specific and customize the look and feel of a
# theme further. For a list of options available for each theme, see the
Expand All @@ -94,13 +95,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Options for HTMLHelp output ---------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'hierarcdoc'
htmlhelp_basename = "hierarcdoc"


# -- Options for LaTeX output ------------------------------------------
Expand All @@ -109,15 +110,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -127,21 +125,15 @@
# (source start file, target name, title, author, documentclass
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'hierarc.tex',
'hierArc Documentation',
'Simon Birrer', 'manual'),
(master_doc, "hierarc.tex", "hierArc Documentation", "Simon Birrer", "manual"),
]


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

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'hierarc',
'hierArc Documentation',
[author], 1)
]
man_pages = [(master_doc, "hierarc", "hierArc Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------
Expand All @@ -150,13 +142,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'hierarc',
'hierArc Documentation',
author,
'hierarc',
'One line description of project.',
'Miscellaneous'),
(
master_doc,
"hierarc",
"hierArc Documentation",
author,
"hierarc",
"One line description of project.",
"Miscellaneous",
),
]



7 changes: 3 additions & 4 deletions hierarc/Diagnostics/blinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@


def blind_posterior(posterior, param_names):
"""
blinds H0 and lambda_int to default values
"""Blinds H0 and lambda_int to default values.
:param posterior: posterior samples of hierArc
:type posterior: flattened posterior with num_param x num_samples array
Expand All @@ -14,10 +13,10 @@ def blind_posterior(posterior, param_names):
"""
posterior_blind = copy.deepcopy(posterior)
for i, param_name in enumerate(param_names):
if param_name == 'lambda_mst':
if param_name == "lambda_mst":
# shift all lambda_int posteriors to a median = 1
posterior_blind[:, i] *= 1 / np.median(posterior_blind[:, i])
if param_name == 'h0':
if param_name == "h0":
# shift all H0 posteriors to a mean = 70
posterior_blind[:, i] *= 70 / np.median(posterior_blind[:, i])
return posterior_blind
Loading

0 comments on commit 2e70aeb

Please sign in to comment.