Skip to content

Commit

Permalink
Merge branch 'nf_density' into kj_disc_debug
Browse files Browse the repository at this point in the history
  • Loading branch information
kylajones committed May 10, 2024
2 parents ff0f882 + a5ac1bc commit a014134
Show file tree
Hide file tree
Showing 53 changed files with 5,021 additions and 305 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/test_publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ jobs:
- name: Run tests
run: |
it=100 python3 -m unittest linfa.linfa_test_suite.trivial_example
it=100 python3 -m unittest linfa.linfa_test_suite.highdim_example
it=100 python3 -m unittest linfa.linfa_test_suite.rc_example
it=100 python3 -m unittest linfa.linfa_test_suite.rcr_example
it=100 python3 -m unittest linfa.linfa_test_suite.adaann_example
it=100 coverage run -m unittest linfa.linfa_test_suite.trivial_example
it=100 coverage run -m unittest linfa.linfa_test_suite.highdim_example
it=100 coverage run -m unittest linfa.linfa_test_suite.rc_example
it=100 coverage run -m unittest linfa.linfa_test_suite.rcr_example
it=100 coverage run -m unittest linfa.linfa_test_suite.adaann_example
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: desResLab/LINFA

- name: Publish to PyPI
# if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}

8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/LINFA.iml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

103 changes: 103 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Contributing to CONTRIBUTING.md

First off, thanks for taking the time to contribute!

All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions.

> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
## Table of Contents

- [Code of Conduct](#code-of-conduct)
- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)
- [Improving The Documentation](#improving-the-documentation)
- [Styleguides](#styleguides)
- [Commit Messages](#commit-messages)
- [Join The Project Team](#join-the-project-team)

## Code of Conduct

This project and everyone participating in it is governed by the [CONTRIBUTING.md Code of Conduct](blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior.

## I Have a Question

> If you want to ask a question, we assume that you have read the available [Documentation](https://linfa-vi.readthedocs.io/en/latest/).
Before you ask a question, it is best to search for existing [Issues](https://github.com/desResLab/LINFA/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Open an [Issue](https://github.com/desResLab/LINFA/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.

We will then take care of the issue as soon as possible.

## I Want To Contribute

> ### Legal Notice
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
### Reporting Bugs

#### Before Submitting a Bug Report

A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://linfa-vi.readthedocs.io/en/latest/). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the bug tracker.
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- Stack trace (Traceback)
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
- Possibly your input and the output
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?

#### How Do I Submit a Good Bug Report?

We use GitHub issues to track bugs and errors. If you run into an issue with the project:

- Open an [Issue](https://github.com/desResLab/LINFA/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.

Once it's filed:

- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).

### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for CONTRIBUTING.md, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.

#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Read the [documentation](https://linfa-vi.readthedocs.io/en/latest/) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/desResLab/LINFA/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.

#### How Do I Submit a Good Enhancement Suggestion?

Enhancement suggestions are tracked as [GitHub issues](https://github.com/desResLab/LINFA/issues).

- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
- **Explain why this enhancement would be useful** to most CONTRIBUTING.md users. You may also want to point out the other projects that solved it better and which could serve as inspiration.

## Attribution
This guide is based on the **contributing.md**. [Make your own](https://contributing.md/)!
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ To run the tests type
```sh
python -m unittest linfa.linfa_test_suite.NAME_example
```
To run a limited number of iterations (say 100), you can instead type
```sh
it=100 python3 -m unittest linfa.linfa_test_suite.NAME_example
```
where `NAME` need to be replaced by
* `trivial` for the trivial example (Ex 1).
* `highdim` for the high-dimensional example (Ex 2).
Expand All @@ -57,7 +61,9 @@ where `NAME` need to be replaced by
* `adaann` for the Friedman model example (Ex 5).
* `rcr_nofas_adaann` for the RCR model, combining NoFAS with adaptive annealing (AdaAnn)

At regular intervals set by the parameter `experiment.save_interval` LINFA writes a few results files. The sub-string `NAME` refers to the experiment name specified in the `experiment.name` variable, and `IT` indicates the iteration at which the file is written. The results files are
If used with adaptive annealing (AdaAnn) the `it=100` option runs 100 iterations only at `T=1` (i.e., to approximate the untempered posterior distribution). Therefore the total number of iterations is generally higher than specified through the `it` option.

At regular intervals, set by the parameter `experiment.save_interval`, LINFA writes a few results files. The sub-string `NAME` refers to the experiment name specified in the `experiment.name` variable, and `IT` indicates the iteration at which the file is written. The results files are

* `log.txt` contains the log profile information, i.e.
* Iteration number.
Expand All @@ -77,6 +83,8 @@ python -m linfa.plot_res -n NAME -i IT -f FOLDER
```
where `NAME` and `IT` are again the experiment name and iteration number corresponding to the result file of interest, while `FOLDER` is the name of the folder with the results of the inference task are kept. Also the file format can be specified throught the `-p` option (options: `pdf`, `png`, `jpg`) and images with dark background can be generated using the `-d` flag.

The coverage resulting from these tests can be found at [this link](https://app.codecov.io/gh/desResLab/LINFA)

### Usage

To use LINFA with your model you need to specify the following components:
Expand All @@ -90,7 +98,11 @@ In addition you need to specify a list of options as discussed in the [documenta

### Tutorial

Two step-by-step tutorials ([tutorial 1](tutorial/tutorial_linfa_2d.ipynb) and [tutorial 2](tutorial/tutorial_linfa_3d.ipynb)) are also available which will guide you through the an inference problem for a ballistic simulation.
Two step-by-step tutorials ([tutorial 1](docs/content/tutorial/tutorial_linfa_2d.ipynb) and [tutorial 2](docs/content/tutorial/tutorial_linfa_3d.ipynb)) are also available which will guide you through an inference problem for a ballistic simulation.

### Contributing

If you are interested in contributing to this project, plase take a look at the [contributed guide](CONTRIBUTING.md) provided with LINFA.

### Citation

Expand Down
14 changes: 11 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@
'sphinx.ext.coverage',
'sphinx.ext.napoleon',
'sphinx_rtd_theme',
'sphinxcontrib.bibtex']
'sphinxcontrib.bibtex',
'nbsphinx',
'sphinx.ext.mathjax',
]

# Suppress warnings for notebooks
suppress_warnings = [
'nbsphinx',
]

numfig = True

Expand All @@ -48,7 +56,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']


# -- Options for HTML output -------------------------------------------------
Expand All @@ -60,4 +68,4 @@
# 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 = []
5 changes: 5 additions & 0 deletions docs/content/friedman.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ We impose a non-informative uniform prior :math:`p(\boldsymbol{\beta})` and, unl
:name: fig_adaann_res

Loss profile (left) and posterior marginal statistics for positive mode in the modified Friedman test case.

An implementation of this model can be found below.

.. literalinclude:: /../linfa/tests/test_linfa.py
:pyobject: linfa_test_suite.adaann_example
1 change: 1 addition & 0 deletions docs/content/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Modules for the LINFA library
nofas
maf
run_experiment
post_processing
5 changes: 3 additions & 2 deletions docs/content/num_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ Numerical Examples
.. toctree::
:maxdepth: 2

tutorial/tutorial_linfa_2d
tutorial/tutorial_linfa_3d
trivial
sobol
rc
rcr
friedman



10 changes: 10 additions & 0 deletions docs/content/post_processing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Post-processing and plotting
============================

A post processing script is also available to plot all results. To run it type

```sh
python -m linfa.plot_res -n NAME -i IT -f FOLDER
```

where `NAME` and `IT` are again the experiment name and iteration number corresponding to the result file of interest, while `FOLDER` is the name of the folder with the results of the inference task are kept. Also the file format can be specified throught the `-p` option (options: `pdf`, `png`, `jpg`) and images with dark background can be generated using the `-d` flag.
4 changes: 4 additions & 0 deletions docs/content/rc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ The aim is to quantify the uncertainty in the RC model parameters given 50 repea

Results from the RC model. Loss profile (top), posterior samples (center) for R and C and the posterior predictive distribution (bottom) for :math:`P_{p,\text{min}}` and :math:`P_{p,\text{max}}` (right, :math:`P_{p,\text{avg}}` not shown).

An implementation of this model can be found below.

.. literalinclude:: /../linfa/tests/test_linfa.py
:pyobject: linfa_test_suite.rc_example
Loading

0 comments on commit a014134

Please sign in to comment.