Skip to content

Commit 82f87a7

Browse files
authored
fix: smart bounds, jax optimizer docs: add conda instructions (closes #171), add openblas comments (#172) (#173)
* docs: add conda instructions (closes #171), add openblas comments (#172) * fix: remove deprecated from plots * fix: do not deepcopy optimizer * fix: check first for sequence
1 parent ce55c52 commit 82f87a7

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
<img src="pyepal_logo.png" />
33
</p>
44

5-
| | |
6-
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7-
| Continuous integration | ![Python package](https://github.com/kjappelbaum/pyepal/workflows/Python%20package/badge.svg) ![pre-commit](https://github.com/kjappelbaum/pyepal/workflows/pre-commit/badge.svg) |
8-
| Code health | [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) [![Maintainability](https://api.codeclimate.com/v1/badges/db9b3f21528574dfb141/maintainability)](https://codeclimate.com/github/kjappelbaum/pyepal/maintainability) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/kjappelbaum/pyepal.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kjappelbaum/pyepal/context:python) ![GitHub last commit](https://img.shields.io/github/last-commit/kjappelbaum/pyepal) [![codecov](https://codecov.io/gh/kjappelbaum/pyepal/branch/master/graph/badge.svg?token=BL2CF4HQ06)](https://codecov.io/gh/kjappelbaum/pyepal)|
9-
| Documentation and tutorial | [![Documentation Status](https://readthedocs.org/projects/pyepal/badge/?version=latest)](https://pyepal.readthedocs.io/en/latest/?badge=latest) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kjappelbaum/pyepal/HEAD?filepath=examples) |
10-
| Social | [![Gitter](https://badges.gitter.im/kjappelbaum/pyepal.svg)](https://gitter.im/kjappelbaum/pyepal?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) |
11-
| Python | ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyepal) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) |
12-
| License | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) |
13-
| [Citation](#citation) |[![Paper DOI](https://img.shields.io/badge/DOI-10.26434/chemrxiv.13200197.v1-blue.svg)](https://chemrxiv.org/articles/preprint/Bias_Free_Multiobjective_Active_Learning_for_Materials_Design_and_Discovery/13200197) [![Zenodo archive](https://zenodo.org/badge/253408969.svg)](https://zenodo.org/badge/latestdoi/253408969) |
14-
5+
| | |
6+
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7+
| Continuous integration | ![Python package](https://github.com/kjappelbaum/pyepal/workflows/Python%20package/badge.svg) ![pre-commit](https://github.com/kjappelbaum/pyepal/workflows/pre-commit/badge.svg) |
8+
| Code health | [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) [![Maintainability](https://api.codeclimate.com/v1/badges/db9b3f21528574dfb141/maintainability)](https://codeclimate.com/github/kjappelbaum/pyepal/maintainability) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/kjappelbaum/pyepal.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kjappelbaum/pyepal/context:python) ![GitHub last commit](https://img.shields.io/github/last-commit/kjappelbaum/pyepal) [![codecov](https://codecov.io/gh/kjappelbaum/pyepal/branch/master/graph/badge.svg?token=BL2CF4HQ06)](https://codecov.io/gh/kjappelbaum/pyepal) |
9+
| Documentation and tutorial | [![Documentation Status](https://readthedocs.org/projects/pyepal/badge/?version=latest)](https://pyepal.readthedocs.io/en/latest/?badge=latest) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kjappelbaum/pyepal/HEAD?filepath=examples) |
10+
| Social | [![Gitter](https://badges.gitter.im/kjappelbaum/pyepal.svg)](https://gitter.im/kjappelbaum/pyepal?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) |
11+
| Python | ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyepal) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) |
12+
| License | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) |
13+
| [Citation](#citation) | [![Paper DOI](https://img.shields.io/badge/DOI-10.26434/chemrxiv.13200197.v1-blue.svg)](https://chemrxiv.org/articles/preprint/Bias_Free_Multiobjective_Active_Learning_for_Materials_Design_and_Discovery/13200197) [![Zenodo archive](https://zenodo.org/badge/253408969.svg)](https://zenodo.org/badge/latestdoi/253408969) |
1514

1615
Generalized Python implementation of a modified version of the ε-PAL algorithm [[1](#1), [2](#2)].
1716

@@ -25,6 +24,12 @@ To install the latest stable release use
2524
pip install pyepal
2625
```
2726

27+
or the conda channel (recommended)
28+
29+
```(bash)
30+
conda install pyepal -c conda-forge
31+
```
32+
2833
to install the latest development version from the head use
2934

3035
```(bash)
@@ -35,10 +40,11 @@ Developers can install the extras `[testing, docs, pre-commit]`. Installation sh
3540

3641
### Additional Notes
3742

38-
- On MacOS you might need to install `libomp` (e.g., `brew install libomp`) for multithreading in some of the models.
43+
- On macOS you might need to install `libomp` (e.g., `brew install libomp`) for multithreading in some models.
3944

4045
- We currently support Python 3.7 and 3.8.
4146

47+
- If you want to [limit how many CPUs openblas uses](https://github.com/numpy/numpy/issues/8120), you can `export OPENBLAS_NUM_THREADS=1`
4248

4349
## Usage
4450

@@ -158,6 +164,7 @@ To measure the performance, you can use the `get_hypervolume` function from `pye
158164
2. <a name="2"></a> Zuluaga, M.; Sergent, G.; Krause, A.; Püschel, M. Active Learning for Multi-Objective Optimization; Dasgupta, S., McAllester, D., Eds.; Proceedings of machine learning research; PMLR: Atlanta, Georgia, USA, 2013; Vol. 28, pp 462–470.
159165

160166
## Citation
167+
161168
<a name="citation"></a>
162169

163170
If you find this code useful for your work, please cite:

docs/getting_started.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ To install the latest stable release use
1313
1414
pip install pyepal
1515
16+
or the conda channel (recommended)
17+
18+
.. code-block:: bash
19+
20+
conda install pyepal -c conda-forge
21+
1622
1723
The latest version of PyePAL can be installed from GitHub using
1824

@@ -21,9 +27,11 @@ The latest version of PyePAL can be installed from GitHub using
2127
pip install git+https://github.com/kjappelbaum/pyepal.git
2228
2329
24-
On MacOS you might need to install `libomp` (e.g., `brew install libomp`) for multihreading in some of the models.
30+
On macOS you might need to install `libomp` (e.g., `brew install libomp`) for multihreading in some models.
31+
32+
If you want to `limit how many CPUs openblas uses <https://github.com/numpy/numpy/issues/8120>`_, you can :code:`export OPENBLAS_NUM_THREADS=1`
2533

26-
Which class do i use?
34+
Which class do I use?
2735
-----------------------
2836

2937
- For Gaussian processes built with :code:`sklearn` use :py:class:`~pyepal.pal.pal_sklearn.PALSklearn`

pyepal/pal/validate_inputs.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"""Methods to validate inputs for the PAL classes"""
1818
import collections
1919
import warnings
20-
from copy import deepcopy
2120
from typing import Any, Iterable, List, Sequence, Union
2221

2322
import numpy as np
@@ -383,17 +382,13 @@ def _is_jaxoptimizer(optimizer: Any) -> bool:
383382

384383
def validate_optimizers(optimizers: Any, ndim: int) -> Sequence:
385384
"""Make sure that we can work with a Sequence if JaxOptimizer"""
386-
if not isinstance(optimizers, collections.Sequence):
387-
if not _is_jaxoptimizer(optimizers):
388-
raise ValueError(
389-
"You need to provide a `pyepal.models.nt.JaxOptimizer` instance"
390-
)
391-
return [deepcopy(optimizers) for _ in range(ndim)]
392-
385+
if not isinstance(optimizers, Sequence):
386+
raise ValueError("You must have one optimizer per objective.")
393387
if not len(optimizers) == ndim:
394388
raise ValueError(
395389
"If you provide a sequence it must have one optimizer per objective."
396390
)
391+
397392
for optimizer in optimizers:
398393
if not _is_jaxoptimizer(optimizer):
399394
raise ValueError(

pyepal/plotting/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,6 @@ def plot_residuals( # pylint:disable=invalid-name
285285
ax[index].scatter(fitted, residuals)
286286
ax[index].spines["top"].set_color("none")
287287
ax[index].spines["right"].set_color("none")
288-
ax[index].spines["left"].set_smart_bounds(True)
289-
ax[index].spines["bottom"].set_smart_bounds(True)
290288

291289
if labels is None:
292290
labels = [f"objective {i}" for i in range(num_targets)]
@@ -361,8 +359,6 @@ def plot_jointplot( # pylint:disable=invalid-name
361359

362360
ax[row, column].spines["top"].set_color("none")
363361
ax[row, column].spines["right"].set_color("none")
364-
ax[row, column].spines["left"].set_smart_bounds(True)
365-
ax[row, column].spines["bottom"].set_smart_bounds(True)
366362

367363
if labels is None:
368364
labels = [f"objective {i}" for i in range(num_targets)]

tests/test_validate_inputs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ def test_validate_optimizers():
274274
validate_optimizers([optimizer], 2)
275275

276276
assert validate_optimizers(optimizers, 2) == optimizers
277-
assert validate_optimizers(optimizer, 2) == optimizers
277+
with pytest.raises(ValueError):
278+
validate_optimizers(optimizer, 2)
278279

279280

280281
def test_validate_nt_models():

0 commit comments

Comments
 (0)