Skip to content

Commit

Permalink
Prepare for new release v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwen committed Apr 28, 2022
1 parent 541a639 commit 4211123
Show file tree
Hide file tree
Showing 37 changed files with 253 additions and 527 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [created]

jobs:
deploy:
deploy-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v3
with:
python-version: 3.9

Expand Down
9 changes: 8 additions & 1 deletion devtool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
- Change the version by modifying `major`, `minor` and `patch` in `./update_version.py`
and then `$ python update_version.py`

- Format code `$ python format_sources.py`
- Format code
```shell
$ mamba update -c conda-forge black
$ python format_sources.py
````

- Update `kliff/docs/source/changelog.rst`

- Update docs at `kliff/docs/source` as necessary

- Generate docs by running `$ make html` in the `kliff/docs` directory
- remove `.git/hooks/pre-commit` so that it will not correct the generated
doc files, otherwise ReadTheDoc will try to regenerate it and then fail
- after commit it, then `$ pre-commit install` to get pre-commit back

- Commit and merge it to the `docs` branch. [ReadTheDocs](https://readthedocs.org)
is set up to watch this branch and will automatically generate the docs.)
Expand Down
4 changes: 2 additions & 2 deletions devtool/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def update_version(version, path, key, in_quotes=False, extra_space=False):

if __name__ == "__main__":
major = 0
minor = 3
patch = 3
minor = 4
patch = 0

mmp = f"{major}.{minor}.{patch}"
mm = f"{major}.{minor}"
Expand Down
Binary file modified docs/source/auto_examples/auto_examples_jupyter.zip
Binary file not shown.
Binary file modified docs/source/auto_examples/auto_examples_python.zip
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/source/auto_examples/example_kim_SW_Si.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"outputs": [],
"source": [
"from kliff.calculators import Calculator\nfrom kliff.dataset import Dataset\nfrom kliff.loss import Loss\nfrom kliff.models import KIMModel\nfrom kliff.utils import download_dataset"
"from kliff.calculators import Calculator\nfrom kliff.dataset import Dataset\nfrom kliff.dataset.weight import Weight\nfrom kliff.loss import Loss\nfrom kliff.models import KIMModel\nfrom kliff.utils import download_dataset"
]
},
{
Expand Down Expand Up @@ -76,7 +76,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here, we tell KLIFF to fit four parameters ``B``, ``gamma``, ``sigma``, and ``A`` of the\nSW model. The information for each fitting parameter should be provided as a list of\nlist, where the size of the outer list should be equal to the ``size`` of the parameter\ngiven by ``model.echo_model_params()``. For each inner list, you can provide either one,\ntwo, or three items.\n\n- One item. You can use a numerical value (e.g. ``gamma``) to provide an initial guess\n of the parameter. Alternatively, the string ``'default'`` can be provided to use the\n default value in the model (e.g. ``B``).\n\n- Two items. The first item should be a numerical value and the second item should be\n the string ``'fix'`` (e.g. ``sigma``), which tells KLIFF to use the value for the\n parameter, but do not optimize it.\n\n- Three items. The first item can be a numerical value or the string ``'default'``,\n having the same meanings as the one item case. In the second and third items, you can\n list the lower and upper bounds for the parameters, respectively. A bound could be\n provided as a numerical values or ``None``. The latter indicates no bound is applied.\n\nThe call of ``model.echo_opt_params()`` prints out the fitting parameters that we\nrequire KLIFF to optimize. The number ``1`` after the name of each parameter indicates\nthe size of the parameter.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>The parameters that are not included as a fitting parameter are fixed to the default\n values in the model during the optimization.</p></div>\n\n\n## Training set\n\nKLIFF has a :class:`~kliff.dataset.Dataset` to deal with the training data (and possibly\ntest data). For the silicon training set, we can read and process the files by:\n\n"
"Here, we tell KLIFF to fit four parameters ``B``, ``gamma``, ``sigma``, and ``A`` of the\nSW model. The information for each fitting parameter should be provided as a list of\nlist, where the size of the outer list should be equal to the ``size`` of the parameter\ngiven by ``model.echo_model_params()``. For each inner list, you can provide either one,\ntwo, or three items.\n\n- One item. You can use a numerical value (e.g. ``gamma``) to provide an initial guess\n of the parameter. Alternatively, the string ``'default'`` can be provided to use the\n default value in the model (e.g. ``B``).\n\n- Two items. The first item should be a numerical value and the second item should be\n the string ``'fix'`` (e.g. ``sigma``), which tells KLIFF to use the value for the\n parameter, but do not optimize it.\n\n- Three items. The first item can be a numerical value or the string ``'default'``,\n having the same meanings as the one item case. In the second and third items, you can\n list the lower and upper bounds for the parameters, respectively. A bound could be\n provided as a numerical values or ``None``. The latter indicates no bound is applied.\n\nThe call of ``model.echo_opt_params()`` prints out the fitting parameters that we\nrequire KLIFF to optimize. The number ``1`` after the name of each parameter indicates\nthe size of the parameter.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>The parameters that are not included as a fitting parameter are fixed to the default\n values in the model during the optimization.</p></div>\n\n\n## Training set\n\nKLIFF has a :class:`~kliff.dataset.Dataset` to deal with the training data (and possibly\ntest data). Additionally, we define the ``energy_weight`` and ``forces_weight``\ncorresponding to each configuration using :class:`~kliff.dataset.weight.Weight`. In\nthis example, we set ``energy_weight`` to ``1.0`` and ``forces_weight`` to ``0.1``.\nFor the silicon training set, we can read and process the files by:\n\n"
]
},
{
Expand All @@ -87,7 +87,7 @@
},
"outputs": [],
"source": [
"dataset_path = download_dataset(dataset_name=\"Si_training_set\")\ntset = Dataset(dataset_path)\nconfigs = tset.get_configs()"
"dataset_path = download_dataset(dataset_name=\"Si_training_set\")\nweight = Weight(energy_weight=1.0, forces_weight=0.1)\ntset = Dataset(dataset_path, weight)\nconfigs = tset.get_configs()"
]
},
{
Expand All @@ -112,7 +112,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"where ``calc.create(configs)`` does some initializations for each\nconfiguration in the training set, such as creating the neighbor list.\n\n\n## Loss function\n\nKLIFF uses a loss function to quantify the difference between the training set data and\npotential predictions and uses minimization algorithms to reduce the loss as much as\npossible. KLIFF provides a large number of minimization algorithms by interacting with\nSciPy_. For physics-motivated potentials, any algorithm listed on\n`scipy.optimize.minimize`_ and `scipy.optimize.least_squares`_ can be used. In the\nfollowing code snippet, we create a loss of energy and forces, where the residual\nfunction uses an ``energy_weight`` of ``1.0`` and a ``forces_weight`` of ``0.1``, and\n``2`` processors will be used to calculate the loss. The ``L-BFGS-B`` minimization\nalgorithm is applied to minimize the loss, and the minimization is allowed to run for\na max number of 100 iterations.\n\n"
"where ``calc.create(configs)`` does some initializations for each\nconfiguration in the training set, such as creating the neighbor list.\n\n\n## Loss function\n\nKLIFF uses a loss function to quantify the difference between the training set data and\npotential predictions and uses minimization algorithms to reduce the loss as much as\npossible. KLIFF provides a large number of minimization algorithms by interacting with\nSciPy_. For physics-motivated potentials, any algorithm listed on\n`scipy.optimize.minimize`_ and `scipy.optimize.least_squares`_ can be used. In the\nfollowing code snippet, we create a loss of energy and forces and use ``2`` processors\nto calculate the loss. The ``L-BFGS-B`` minimization algorithm is applied to minimize\nthe loss, and the minimization is allowed to run for a max number of 100 iterations.\n\n"
]
},
{
Expand All @@ -123,7 +123,7 @@
},
"outputs": [],
"source": [
"steps = 100\nresidual_data = {\"energy_weight\": 1.0, \"forces_weight\": 0.1}\nloss = Loss(calc, residual_data=residual_data, nprocs=2)\nloss.minimize(method=\"L-BFGS-B\", options={\"disp\": True, \"maxiter\": steps})"
"steps = 100\nloss = Loss(calc, nprocs=2)\nloss.minimize(method=\"L-BFGS-B\", options={\"disp\": True, \"maxiter\": steps})"
]
},
{
Expand Down
20 changes: 11 additions & 9 deletions docs/source/auto_examples/example_kim_SW_Si.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

from kliff.calculators import Calculator
from kliff.dataset import Dataset
from kliff.dataset.weight import Weight
from kliff.loss import Loss
from kliff.models import KIMModel
from kliff.utils import download_dataset
Expand Down Expand Up @@ -107,10 +108,14 @@
# ------------
#
# KLIFF has a :class:`~kliff.dataset.Dataset` to deal with the training data (and possibly
# test data). For the silicon training set, we can read and process the files by:
# test data). Additionally, we define the ``energy_weight`` and ``forces_weight``
# corresponding to each configuration using :class:`~kliff.dataset.weight.Weight`. In
# this example, we set ``energy_weight`` to ``1.0`` and ``forces_weight`` to ``0.1``.
# For the silicon training set, we can read and process the files by:

dataset_path = download_dataset(dataset_name="Si_training_set")
tset = Dataset(dataset_path)
weight = Weight(energy_weight=1.0, forces_weight=0.1)
tset = Dataset(dataset_path, weight)
configs = tset.get_configs()


Expand Down Expand Up @@ -149,15 +154,12 @@
# possible. KLIFF provides a large number of minimization algorithms by interacting with
# SciPy_. For physics-motivated potentials, any algorithm listed on
# `scipy.optimize.minimize`_ and `scipy.optimize.least_squares`_ can be used. In the
# following code snippet, we create a loss of energy and forces, where the residual
# function uses an ``energy_weight`` of ``1.0`` and a ``forces_weight`` of ``0.1``, and
# ``2`` processors will be used to calculate the loss. The ``L-BFGS-B`` minimization
# algorithm is applied to minimize the loss, and the minimization is allowed to run for
# a max number of 100 iterations.
# following code snippet, we create a loss of energy and forces and use ``2`` processors
# to calculate the loss. The ``L-BFGS-B`` minimization algorithm is applied to minimize
# the loss, and the minimization is allowed to run for a max number of 100 iterations.

steps = 100
residual_data = {"energy_weight": 1.0, "forces_weight": 0.1}
loss = Loss(calc, residual_data=residual_data, nprocs=2)
loss = Loss(calc, nprocs=2)
loss.minimize(method="L-BFGS-B", options={"disp": True, "maxiter": steps})


Expand Down
2 changes: 1 addition & 1 deletion docs/source/auto_examples/example_kim_SW_Si.py.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7b261ef6ac84d9734bd967d57109e034
aa103f8edc37ca96254be2e86d1426f3
Loading

0 comments on commit 4211123

Please sign in to comment.