Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"baseBranchPatterns":["main-with-renovate-comments"],
"packageRules": [
{
"matchManagers": ["pip_requirements", "conda"],
"groupName": "Python dependencies",
"separateMajorMinor": false
},
{
"matchManagers": ["github-actions"],
"groupName": "GitHub actions",
"separateMajorMinor": false
}
],
"dependencyDashboard": true
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ doc/build
doc/source/*.rst
doc/source/*.md

doc/source/tutorials/1-monte_carlo_uq.rst
doc/source/tutorials/*.ipynb

# No results or logs
Expand Down
8 changes: 7 additions & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ We believe that documentation is essential and therefore welcome any improvement

## :woman_teacher: Build the documentation

To build the documentation, you first need a development QUEENS installation as mentioned in the [CONTRIBUTING.md](../CONTRIBUTING.md). This adds additional packages needed for the html build. Once this is done, follow the next steps in the activated Python environment with the development installation.
To build the documentation, you first need to set up a QUEENS environment as described in the [README.md](../README.md).
In this Python environment, you also need to install packages for QUEENS development and tutorials and register the environment as a Jupyter kernel:

```bash
pip install -e .[safe_develop,tutorial]
python -m ipykernel install --user --name queens --display-name "Python (queens)"
```

When building the documentation on your machine for the first time or after adding new modules or classes to QUEENS, one needs to first rebuild the `autodoc index` by running:

Expand Down
16 changes: 8 additions & 8 deletions doc/source/_ext/create_documentation_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def create_development():
inject({"md_paths": md_paths}, development_template, development_path)


def create_intro():
def create_introduction():
"""Generate landing page."""
intro_template = get_template_path_by_name("intro.md.j2")
into_path = relative_to_doc_source("intro.md")
intro_template = get_template_path_by_name("introduction.md.j2")
into_path = relative_to_doc_source("introduction.md")

def extract_from_markdown_by_marker(marker_name, md_path):
return clean_markdown(extract_from_markdown_file_by_marker(marker_name, md_path))
Expand All @@ -176,10 +176,10 @@ def extract_from_markdown_by_marker(marker_name, md_path):
)


def create_overview():
def create_packages():
"""Create overview of the QUEENS package."""
overview_template = get_template_path_by_name("overview.rst.j2")
overview_path = relative_to_doc_source("overview.rst")
overview_template = get_template_path_by_name("packages.rst.j2")
overview_path = relative_to_doc_source("packages.rst")

def get_module_description(python_file):
"""Get module description.
Expand Down Expand Up @@ -298,7 +298,7 @@ def copy_tutorials():

def main():
"""Create all the rst files."""
create_intro()
create_introduction()
copy_tutorials()
create_development()
create_overview()
create_packages()
15 changes: 0 additions & 15 deletions doc/source/_ext/templates/1-monte_carlo_uq.rst.j2

This file was deleted.

11 changes: 11 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@
"myst_parser",
]

# Control how typehints are displayed in the documentation.
# 'description' shows typehints as content of the function (next to the parameters), not in the
# function signature.
# This mirrors the behavior of types provided in the docstrings.
autodoc_typehints = "description"

# Control how class signatures will be displayed.
# 'separated' will display the signature as a method, meaning the __init__ method is explicitly
# shown in the documentation.
autodoc_class_signature = "separated"

# Custom command to make the returns in the docstring behave like the parameter/argument section.
# This will basically make the documentation a bit prettier as different returns are directly
# rendered as bullet points.
Expand Down
5 changes: 2 additions & 3 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ Contents
.. toctree::
:maxdepth: 1

intro
overview
introduction
packages
tutorials
development
queens
faq


Expand Down
11 changes: 5 additions & 6 deletions doc/source/tutorials/0-onboarding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Steps to get started with QUEENS

.. code-block:: bash

git clone git@github.com:queens-py/queens.git
git clone git@github.com:queens-py/queens.git

#. Read through our `introduction <https://queens-py.github.io/queens/intro.html>`_ and
follow the instructions in the "Installation" section to set up your local environment.
Expand All @@ -34,11 +34,10 @@ Steps to get started with QUEENS

.. code-block:: json

"python.pythonPath": "<path_to_your_QUEENS_environment>/bin/python",
"python.defaultInterpreterPath": "<path_to_your_QUEENS_environment>/bin/python",
"editor.formatOnSave": True,
"python.formatting.provider": "black",
"python.formatting.blackPath": "<path_to_your_QUEENS_environment>/bin/black",
"python.defaultInterpreterPath": "<path_to_your_QUEENS_environment>/bin/python",
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter",
"black-formatter.args": ["--line-length", "100"],

#. Browse through our `documentation <https://queens-py.github.io/queens/overview.html>`_ and our
other tutorials to get a first impression.
Expand Down
59 changes: 35 additions & 24 deletions src/queens/data_processors/csv_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,44 @@ def __init__(
"""Instantiate data processor class for csv data.

Args:
file_name_identifier (str): Identifier of file name
The file prefix can contain regex expression
and subdirectories.
file_name_identifier (str): Identifier of file name. The file prefix can contain regex
expression and subdirectories.
file_options_dict (dict): Dictionary with read-in options for the file:
- header_row (int): Integer that determines which csv-row contains labels/headers of
the columns. Default is 'None', meaning no header used.
- use_cols_lst (lst): (optional) list with column numbers that should be read-in.
- skip_rows (int): Number of rows that should be skipped to be read-in in csv file.
- index_column (int, str): Column to use as the row labels of the DataFrame, either
given as string name or column index.
Note: index_column=False can be used to force pandas to
not use the first column as the index. Index_column is
used for filtering the remaining columns.
- returned_filter_format (str): Returned data format after filtering
- filter (dict): Dictionary with filter options:
-- type (str): Filter type to use
-- rows (lst): In case this options is used, the list contains the indices of
rows in the csv file that should be used as data
-- range (lst): After data is selected by `use_cols_lst` and a filter column
is specified by `index_column`, this option selects which data
range shall be filtered by providing a minimum and maximum
value pair in list format
-- target_values (list): target values to filter
-- tolerance (float): Tolerance for the filter range

- header_row (int):
Integer that determines which csv-row contains labels/headers of
the columns. Default is 'None', meaning no header used.
- use_cols_lst (lst):
(optional) list with column numbers that should be read-in.
- skip_rows (int):
Number of rows that should be skipped to be read-in in csv file.
- index_column (int, str):
Column to use as the row labels of the DataFrame, either
given as string name or column index.
Note: ``index_column=False`` can be used to force pandas to not use the first
column as the index. ``index_column`` is used for filtering the remaining
columns.
- returned_filter_format (str):
Returned data format after filtering
- filter (dict):
Dictionary with filter options:

-- type (str):
Filter type to use
-- rows (lst):
In case this options is used, the list contains the indices of
rows in the csv file that should be used as data
-- range (lst):
After data is selected by `use_cols_lst` and a filter column is specified
by `index_column`, this option selects which data range shall be filtered
by providing a minimum and maximum value pair in list format
-- target_values (list):
target values to filter
-- tolerance (float):
Tolerance for the filter range

files_to_be_deleted_regex_lst (lst): List with paths to files that should be deleted.
The paths can contain regex expressions.
The paths can contain regex expressions.

Returns:
Instance of CsvFile class
Expand Down
8 changes: 4 additions & 4 deletions src/queens/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import logging
from pathlib import Path

from queens.schedulers._dask import SHUTDOWN_CLIENTS
from queens.schedulers._scheduler import CLEANUP_SCHEDULERS
from queens.utils.ascii_art import print_banner_and_description
from queens.utils.logger_settings import reset_logging, setup_basic_logging
from queens.utils.path import PATH_TO_ROOT, create_folder_if_not_existent
Expand Down Expand Up @@ -168,8 +168,8 @@ def __exit__(self, exception_type, exception_value, traceback):
exception_value: indicates exception instance
traceback: traceback object
"""
for shutdown_client in SHUTDOWN_CLIENTS.copy():
SHUTDOWN_CLIENTS.remove(shutdown_client)
shutdown_client()
for cleanup_scheduler in CLEANUP_SCHEDULERS.copy():
CLEANUP_SCHEDULERS.remove(cleanup_scheduler)
cleanup_scheduler()

reset_logging()
16 changes: 9 additions & 7 deletions src/queens/iterators/elementary_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ def print_results(self, results):

Args:
results (dict): Dictionary with the results of the sensitivity analysis, including:
- 'parameter_names': List of parameter names.
- 'sensitivity_indices': Contains indices like:
- 'names': Parameter names.
- 'mu_star': Mean absolute effect.
- 'mu': Mean effect.
- 'mu_star_conf': Confidence interval for 'mu_star'.
- 'sigma': Standard deviation of the effect.

- `parameter_names`: List of parameter names.
- `sensitivity_indices`: Contains indices like:

- `names`: Parameter names.
- `mu_star`: Mean absolute effect.
- `mu`: Mean effect.
- `mu_star_conf`: Confidence interval for `mu_star`.
- `sigma`: Standard deviation of the effect.
"""
_logger.info(
"%-20s %10s %10s %15s %10s", "Parameter", "Mu_Star", "Mu", "Mu_Star_Conf", "Sigma"
Expand Down
13 changes: 5 additions & 8 deletions src/queens/iterators/hamiltonian_monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
"""HMC algorithm.

"The Hamiltonian Monte Carlo sampler is a gradient based MCMC algortihm.
The Hamiltonian Monte Carlo sampler is a gradient based MCMC algorithm.
It is used to sample from arbitrary probability distributions.
"""

Expand All @@ -35,16 +35,13 @@ class HamiltonianMonteCarlo(PyMC):

Attributes:
max_steps (int): Maximum of leapfrog steps to take in one iteration
target_accept (float): Target accpetance rate which should be conistent after burn-in
target_accept (float): Target acceptance rate which should be consistent after burn-in
path_length (float): Maximum length of particle trajectory
step_size (float): Step size, scaled by 1/(parameter dimension **0.25)
step_size (float): Step size, scaled by 1/(parameter dimension^0.25)
scaling (np.array): The inverse mass, or precision matrix
is_cov (boolean): Setting if the scaling is a mass or covariance matrix
init_strategy (str): Strategy to tune mass damping matrix
advi_iterations (int): Number of iteration steps of ADVI based init strategies

Returns:
hmc_iterator (obj): Instance of HMC Iterator
"""

@log_init_args
Expand Down Expand Up @@ -94,10 +91,10 @@ def __init__(
functions
progressbar (boolean, opt): Setting for printing progress bar while sampling
max_steps (int, opt): Maximum of leapfrog steps to take in one iteration
target_accept (float, opt): Target accpetance rate which should be conistent after
target_accept (float, opt): Target acceptance rate which should be consistent after
burn-in
path_length (float, opt): Maximum length of particle trajectory
step_size (float, opt): Step size, scaled by 1/(parameter dimension **0.25)
step_size (float, opt): Step size, scaled by 1/(parameter dimension^0.25)
scaling (np.array, opt): The inverse mass, or precision matrix
is_cov (boolean, opt): Setting if the scaling is a mass or covariance matrix
init_strategy (str, opt): Strategy to tune mass damping matrix
Expand Down
51 changes: 26 additions & 25 deletions src/queens/iterators/least_squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ class LeastSquares(Optimization):
Attributes:
algorithm (str): Algorithm to perform minimization:

- trf : Trust Region Reflective algorithm, particularly suitable for large
sparse problems with bounds. Generally robust method.

- dogbox : dogleg algorithm with rectangular trust regions, typical use
case is small problems with bounds. Not recommended for problems
with rank-deficient Jacobian.
- lm : Levenberg-Marquardt algorithm as implemented in MINPACK. Doesn’t
handle bounds and sparse Jacobians. Usually the most efficient
method for small unconstrained problems.
- trf:
Trust Region Reflective algorithm, particularly suitable for large sparse problems
with bounds. Generally robust method.
- dogbox:
dogleg algorithm with rectangular trust regions, typical use case is small problems
with bounds. Not recommended for problems with rank-deficient Jacobian.
- lm:
Levenberg-Marquardt algorithm as implemented in MINPACK. Doesn’t handle bounds and
sparse Jacobians. Usually the most efficient method for small unconstrained
problems.
"""

@log_init_args
Expand Down Expand Up @@ -75,31 +76,31 @@ def __init__(
verbose_output (int): Integer encoding which kind of verbose information should be
printed by the optimizers.
bounds (sequence, Bounds): Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP,
Powell, and trust-constr methods.
There are two ways to specify the bounds:

1. Instance of `Bounds` class.
2. A sequence with 2 elements. The first element corresponds
to a sequence of lower bounds and the second element to
sequence of upper bounds. The length of each of the two
subsequences must be equal to the number of variables.
Powell, and trust-constr methods. There are two ways to specify the bounds:

1. Instance of `Bounds` class.
2. A sequence with 2 elements. The first element corresponds to a sequence of lower
bounds and the second element to a sequence of upper bounds. The length of each
of the two subsequences must be equal to the number of variables.

max_feval (int): Maximum number of function evaluations.
algorithm (str): Algorithm to perform minimization:

- trf : Trust Region Reflective algorithm, particularly suitable for
large sparse problems with bounds. Generally robust method.
- 'trf': Trust Region Reflective algorithm, particularly suitable for large sparse
problems with bounds. Generally robust method.
- 'dogbox': dogleg algorithm with rectangular trust regions, typical use case is
small problems with bounds. Not recommended for problems with rank-deficient
Jacobian.
- 'lm': Levenberg-Marquardt algorithm as implemented in MINPACK. Doesn’t handle
bounds and sparse Jacobians. Usually the most efficient method for small
unconstrained problems.

- dogbox : dogleg algorithm with rectangular trust regions, typical use
case is small problems with bounds. Not recommended for
problems with rank-deficient Jacobian.
- lm : Levenberg-Marquardt algorithm as implemented in MINPACK.
Doesn’t handle bounds and sparse Jacobians. Usually the most
efficient method for small unconstrained problems.
jac_method (str): Method to calculate a finite difference based approximation of the
Jacobian matrix:

- '2-point': a one-sided scheme by definition
- '3-point': more exact but needs twice as many function evaluations

jac_rel_step (array_like): Relative step size to use for finite difference approximation
of Jacobian matrix. If None (default) then it is selected
automatically. (see SciPy documentation for details)
Expand Down
2 changes: 1 addition & 1 deletion src/queens/iterators/metropolis_hastings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
"""Metropolis-Hastings algorithm.

"The Metropolis-Hastings algorithm is a Markov Chain Monte Carlo (MCMC)
The Metropolis-Hastings algorithm is a Markov Chain Monte Carlo (MCMC)
method for obtaining a sequence of random samples from a probability
distribution from which direct sampling is difficult." [1]

Expand Down
Loading
Loading