Skip to content

Commit

Permalink
Merge pull request #954 from Libensemble/formatting/all_precommit
Browse files Browse the repository at this point in the history
Running all precommit hooks (except on .xml and .svg)
  • Loading branch information
jmlarson1 committed Jan 5, 2023
2 parents df7406f + cc0ed46 commit 5fd6376
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 56 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ jobs:
sed -i -e "s/pyzmq>=22.1.0,<23.0.0/pyzmq>=23.0.0,<24.0.0/" ./balsam/setup.cfg
cd balsam; pip install -e .; cd ..
- name: Find MPI, Install libEnsemble, flake8, ulimit adjust
run: |
pip install -e .
Expand Down
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: ^(.*\.xml|.*\.svg)$
- id: trailing-whitespace
exclude: ^(.*\.xml|.*\.svg)$

- repo: https://github.com/pycqa/isort
rev: 5.11.4
Expand All @@ -29,3 +31,4 @@ repos:
- id: blacken-docs
additional_dependencies: [black==22.12.0]
files: ^(.*\.py|.*\.rst)$
args: [--line-length=120]
2 changes: 1 addition & 1 deletion docs/data_structures/data_structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ a complete libEnsemble workflow, or using the alternative yaml interface.
alloc_specs
persis_info
exit_criteria
ensemble_specs
ensemble_specs
2 changes: 1 addition & 1 deletion docs/data_structures/ensemble_specs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Optional model used to validate each component of a libEnsemble workflow togethe
:model-show-config-summary: False
:model-show-validator-members: False
:model-show-validator-summary: False
:field-list-validators: False
:field-list-validators: False
2 changes: 1 addition & 1 deletion docs/dev_guide/dev_API/scheduler_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Scheduler Module
.. autoclass:: ResourceScheduler
:member-order: bysource
:members:
:noindex:
:noindex:
2 changes: 1 addition & 1 deletion docs/examples/aposmm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ LocalOptInterfacer
.. _mpmath: https://pypi.org/project/mpmath
.. _nlopt: http://ab-initio.mit.edu/wiki/index.php/NLopt
.. _petsc4py: https://bitbucket.org/petsc/petsc4py
.. _DFO-LS: https://github.com/numericalalgorithmsgroup/dfols
.. _DFO-LS: https://github.com/numericalalgorithmsgroup/dfols
2 changes: 1 addition & 1 deletion docs/examples/fd_param_finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ persistent_fd_param_finder
--------------------------
.. automodule:: persistent_fd_param_finder
:members:
.. :undoc-members:
.. :undoc-members:
2 changes: 1 addition & 1 deletion docs/history_output_logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ without simulation-specific directories.
The ``scripts`` directory, in the libEnsemble project root directory,
contains scripts to compare outputs and create plots based on the ensemble output.

.. include:: ../scripts/readme.rst
.. include:: ../scripts/readme.rst
12 changes: 3 additions & 9 deletions docs/tutorials/local_sine_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ the history array. ``flag`` should be zero if no errors occur.
.. code-block:: python
:linenos:
H, persis_info, flag = libE(
sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs
)
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs)
print([i for i in H.dtype.fields]) # (optional) to visualize our history array
print(H)
Expand Down Expand Up @@ -391,9 +389,7 @@ Write a Calling Script with the following specifications:
persis_info = add_unique_random_streams({}, nworkers + 1)
exit_criteria = {"gen_max": 160}
H, persis_info, flag = libE(
sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs
)
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs)
if flag != 0:
print("Oh no! An error occurred!")
Expand Down Expand Up @@ -450,9 +446,7 @@ modify the bottom of the calling script like this:
:linenos:
:emphasize-lines: 4
H, persis_info, flag = libE(
sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs
)
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs)
if is_manager:
# Some (optional) statements to visualize our history array
Expand Down
2 changes: 1 addition & 1 deletion examples/libE_submission_scripts/summit_submit_mproc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ hash -r # Check no commands hashed (pip/python...)
# Launch libE
# python $EXE $NUM_WORKERS > out.txt 2>&1 # No args. All defined in calling script
# python $EXE $COMMS $NWORKERS > out.txt 2>&1 # If calling script is using parse_args()
python $EXE $LIBE_WALLCLOCK $COMMS $NWORKERS > out.txt 2>&1 # If calling script takes wall-clock as positional arg.
python $EXE $LIBE_WALLCLOCK $COMMS $NWORKERS > out.txt 2>&1 # If calling script takes wall-clock as positional arg.
2 changes: 1 addition & 1 deletion install/testing_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pytest-cov==4.0.0
pytest-timeout==2.1.0
mock==4.0.3
coveralls==3.3.1
python-dateutil==2.8.2
python-dateutil==2.8.2
47 changes: 18 additions & 29 deletions libensemble/libE.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,19 @@
libE_specs["save_every_k_gens"] = 20
gen_specs = {"gen_f": gen_random_sample,
"out": [("x", float, (1,))],
"user": {
"lower": np.array([-3]),
"upper": np.array([3]),
"gen_batch_size": 5
}
}
gen_specs = {
"gen_f": gen_random_sample,
"out": [("x", float, (1,))],
"user": {"lower": np.array([-3]), "upper": np.array([3]), "gen_batch_size": 5},
}
sim_specs = {"sim_f": sim_find_sine,
"in": ["x"],
"out": [("y", float)]}
sim_specs = {"sim_f": sim_find_sine, "in": ["x"], "out": [("y", float)]}
persis_info = add_unique_random_streams({}, nworkers+1)
persis_info = add_unique_random_streams({}, nworkers + 1)
exit_criteria = {"sim_max": 80}
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info,
libE_specs=libE_specs)
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs)
This will initiate libEnsemble with a Manager and ``nworkers`` workers (parsed from
the command line), and runs on laptops or supercomputers. If an exception is
Expand Down Expand Up @@ -201,38 +195,33 @@
from simulator import sim_find_sine
from libensemble.tools import add_unique_random_streams
if __name__ == "__main__:
if __name__ == "__main__":
nworkers, is_manager, libE_specs, _ = parse_args()
libE_specs["save_every_k_gens"] = 20
gen_specs = {"gen_f": gen_random_sample,
"out": [("x", float, (1,))],
"user": {
"lower": np.array([-3]),
"upper": np.array([3]),
"gen_batch_size": 5
}
}
gen_specs = {
"gen_f": gen_random_sample,
"out": [("x", float, (1,))],
"user": {"lower": np.array([-3]), "upper": np.array([3]), "gen_batch_size": 5},
}
sim_specs = {"sim_f": sim_find_sine,
"in": ["x"],
"out": [("y", float)]}
sim_specs = {"sim_f": sim_find_sine, "in": ["x"], "out": [("y", float)]}
persis_info = add_unique_random_streams({}, nworkers+1)
persis_info = add_unique_random_streams({}, nworkers + 1)
exit_criteria = {"sim_max": 80}
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info,
libE_specs=libE_specs)
H, persis_info, flag = libE(sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs)
Alternatively, you may set the multiprocessing start method to ``"fork"`` via the following:
.. code-block:: python
:linenos:
from multiprocessing import set_start_method
set_start_method("fork")
But note that this is incompatible with some libraries.
Expand Down
6 changes: 3 additions & 3 deletions tex/bibs/masterbib.bib
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ @BOOK{ATAZ89
}

@article{Gheribi20111323,
title = "Calculating all local minima on liquidus surfaces using the {FactSage} software and databases and the {Mesh Adaptive Direct Search} algorithm ",
title = "Calculating all local minima on liquidus surfaces using the {FactSage} software and databases and the {Mesh Adaptive Direct Search} algorithm ",
journal = "The Journal of Chemical Thermodynamics",
volume = "43",
number = "9",
Expand All @@ -529,7 +529,7 @@ @article{doi:10.1137/070707518
number = {3},
pages = {1150--1170},
year = {2008},
doi = {10.1137/070707518},
doi = {10.1137/070707518},
}

@article{McKay1979,
Expand Down Expand Up @@ -588,7 +588,7 @@ @Misc{petsc-web-page
uncommenthowpublished = {\url{http://www.mcs.anl.gov/petsc}},
year = {2017}
}

@Misc{nlopt,
author = {Steven G. Johnson},
title = {The {NLopt} nonlinear-optimization package},
Expand Down
7 changes: 3 additions & 4 deletions tex/planning_doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ TEXFILES = *.tex
PICS = ../images
BIBFILES = ../bibs/*.bib

all: $(SOURCE).pdf
all: $(SOURCE).pdf

$(SOURCE).pdf: $(TEXFILES) $(BIBFILES) $(PICS)
pdflatex $(SOURCE).tex
bibtex $(SOURCE)
pdflatex $(SOURCE).tex
pdflatex $(SOURCE).tex

#$(preprint).pdf: $(TEXFILES)
#$(preprint).pdf: $(TEXFILES)
# pdflatex $(preprint).tex

#$(response).pdf: $(TEXFILES)
#$(response).pdf: $(TEXFILES)
# pdflatex $(response).tex

view: $(SOURCE).pdf
open $(SOURCE).pdf
clean:
-rm -f $(SOURCE).log $(SOURCE).aux $(SOURCE).bbl $(SOURCE).blg \
$(SOURCE).pdf $(SOURCE).out *.backup *.tex~ *.log

0 comments on commit 5fd6376

Please sign in to comment.