Skip to content

Commit

Permalink
Merge pull request #263 from bessagroup/pr/1.4.7
Browse files Browse the repository at this point in the history
Pr/1.4.7
  • Loading branch information
mpvanderschelling committed Apr 19, 2024
2 parents 7f96e7e + f286232 commit f20d70d
Show file tree
Hide file tree
Showing 40 changed files with 1,504 additions and 319 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/push_to_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,6 @@ jobs:
- name: Test with pytest (excluding abaqus tests)
run: |
python -m pytest -S abaqus
publish-sphinx-documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
cache: "pip" # caching pip dependencies
- name: Install package dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install documentation requirements
run: |
pip install -r docs/requirements.txt
- name: Build documentation
run: |
sphinx-build -b html ./docs/source ./docs/build/html
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: html-docs
path: docs/build/html/
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
force_orphan: false
build-package:
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.6
1.4.7
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
project = 'f3dasm'
author = 'Martin van der Schelling'
copyright = '2022, Martin van der Schelling'
version = '1.4.6'
release = '1.4.6'
version = '1.4.7'
release = '1.4.7'


# -- General configuration ----------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ There are three methods available of handeling the :class:`~f3dasm.ExperimentSam
* :code:`sequential`: regular for-loop over each of the :class:`~f3dasm.ExperimentSample` objects in order
* :code:`parallel`: utilizing the multiprocessing capabilities (with the `pathos <https://pathos.readthedocs.io/en/latest/pathos.html>`_ multiprocessing library), each :class:`~f3dasm.ExperimentSample` object is run in a separate core
* :code:`cluster`: utilizing the multiprocessing capabilities, each :class:`~f3dasm.ExperimentSample` object is run in a separate node. After completion of an sample, the node will automatically pick the next available sample. More information on this mode can be found in the :ref:`cluster-mode` section.

* :code:`cluster_parallel`: Combination of the :code:`cluster` and :code:`parallel` mode. Each node will run multiple samples in parallel.

Implement your simulator
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 1 addition & 4 deletions docs/source/rst_doc_files/classes/sampling/sampling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ The function should return the samples (``input_data``) in one of the following
* A :class:`~pandas.DataFrame` object
* A :class:`~numpy.ndarray` object

.. note::

...


.. _implemented samplers:
Expand All @@ -36,7 +33,6 @@ To use the sampler in the data-driven process, you should pass the function to t
.. code-block:: python
from f3dasm.design import ExperimentData, Domain
from
domain = Domain(...)
# Create the ExperimentData object
Expand All @@ -63,4 +59,5 @@ Name Method
``"random"`` Random Uniform sampling `numpy.random.uniform <https://numpy.org/doc/stable/reference/random/generated/numpy.random.uniform.html>`_
``"latin"`` Latin Hypercube sampling `SALib.latin <https://salib.readthedocs.io/en/latest/api/SALib.sample.html?highlight=latin%20hypercube#SALib.sample.latin.sample>`_
``"sobol"`` Sobol Sequence sampling `SALib.sobol_sequence <https://salib.readthedocs.io/en/latest/api/SALib.sample.html?highlight=sobol%20sequence#SALib.sample.sobol_sequence.sample>`_
``"grid"`` Grid Search sampling `itertools.product <https://docs.python.org/3/library/itertools.html#itertools.product>`_
======================== ====================================================================== ===========================================================================================================
6 changes: 3 additions & 3 deletions docs/source/rst_doc_files/general/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Overview
========

.. _design-of-experiments: https://bessagroup.github.io/f3dasm/classes/design/experimentdata.html
.. _sampling: https://bessagroup.github.io/f3dasm/classes/sampling/sampling.html
.. _optimizing: https://bessagroup.github.io/f3dasm/classes/optimization/optimizers.html
.. _design-of-experiments: https://f3dasm.readthedocs.io/en/latest/rst_doc_files/classes/design/experimentdata.html
.. _sampling: https://f3dasm.readthedocs.io/en/latest/rst_doc_files/classes/sampling/sampling.html
.. _optimizing: https://f3dasm.readthedocs.io/en/latest/rst_doc_files/classes/optimization/optimizers.html
.. _parallelizing: <URL for parallelizing>
.. _TORQUE system: https://hpc-wiki.info/hpc/Torque

Expand Down
4 changes: 2 additions & 2 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ An overview of the different levels of abstraction is given in \autoref{fig:f3da

# Documentation and collaborative development

To improve the usability of the `f3dasm` frame­work, thorough documentation has been included with the Sphinx package. Documentation for this package can be accessed on [the homepage](https://bessagroup.github.io/f3dasm/) and will be kept up to date with the latest release of the package.
To improve the usability of the `f3dasm` frame­work, thorough documentation has been included with the Sphinx package. Documentation for this package can be accessed on [the homepage](https://f3dasm.readthedocs.io/en/latest/) and will be kept up to date with the latest release of the package.

The `f3dasm` framework relies on the collaborative efforts of scientists and developers to expand its capabilities. Therefore, it is essential to have a well-defined software development process in place. This is achieved by maintaining strict branching policies, and incorporating comprehensive testing suites and automatic continuous integration with GitHub Workflows.

Expand All @@ -138,7 +138,7 @@ To maintain the integrity of the framework, various (automatic) validation proce

# Availability

`f3dasm` and its extensions are available as a `pip` package and is compatible with Python 3.8 to 3.10 and all major operating systems (Linux, MacOS and Windows). Detailed installation instructions can be found on the ['Getting Started'](https://bessagroup.github.io/f3dasm/general/gettingstarted.html) documentation page.
`f3dasm` and its extensions are available as a `pip` package and is compatible with Python 3.8 to 3.10 and all major operating systems (Linux, MacOS and Windows). Detailed installation instructions can be found on the ['Getting Started'](https://f3dasm.readthedocs.io/en/latest/rst_doc_files/general/gettingstarted.html) documentation page.


# Acknowledgements
Expand Down
68 changes: 67 additions & 1 deletion src/f3dasm/_src/datageneration/datagenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
from abc import abstractmethod
from functools import partial
from typing import Any, Callable, Optional
from typing import Any, Callable, Dict, List, Optional

if sys.version_info < (3, 8): # NOQA
from typing_extensions import Protocol # NOQA
Expand Down Expand Up @@ -187,3 +187,69 @@ def add_post_process(self, func: Callable, **kwargs):
The keyword arguments to pass to the post-processing function
"""
self.post_process = partial(func, **kwargs)


def convert_function(f: Callable,
input: List[str],
output: Optional[List[str]] = None,
kwargs: Optional[Dict[str, Any]] = None,
to_disk: Optional[List[str]] = None) -> DataGenerator:
"""
Converts a given function `f` into a `DataGenerator` object.
Parameters
----------
f : Callable
The function to be converted.
input : List[str]
A list of argument names required by the function.
output : Optional[List[str]], optional
A list of names for the return values of the function.
Defaults to None.
kwargs : Optional[Dict[str, Any]], optional
Additional keyword arguments passed to the function. Defaults to None.
to_disk : Optional[List[str]], optional
The list of output names where the value needs to be stored on disk.
Defaults to None.
Returns
-------
DataGenerator
A converted `DataGenerator` object.
Notes
-----
The function `f` can have any number of arguments and any number of returns
as long as they are consistent with the `input` and `output` arguments that
are given to this function.
"""

kwargs = kwargs if kwargs is not None else {}
to_disk = to_disk if to_disk is not None else []
output = output if output is not None else []

class TempDataGenerator(DataGenerator):
def execute(self, **_kwargs) -> None:
_input = {input_name: self.experiment_sample.get(input_name)
for input_name in input}
_output = f(**_input, **kwargs)

# check if output is empty
if output is None:
return

if len(output) == 1:
_output = (_output,)

for name, value in zip(output, _output):
if name in to_disk:
self.experiment_sample.store(name=name,
object=value,
to_disk=True)
else:
self.experiment_sample.store(name=name,
object=value,
to_disk=False)

return TempDataGenerator()
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def augment(self, input: np.ndarray) -> np.ndarray:

scale = abs(self.noise * yy)

if isinstance(input, float):
# convert to numpy float
input = np.float64(input)

noise: np.ndarray = np.random.normal(
loc=0.0, scale=scale, size=input.shape)
y_noise = input + float(noise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ def _configure_offset(self):

unscaled_offset = np.atleast_1d(
[
# np.random.uniform(
# low=-abs(g[d] - self.scale_bounds[d, 0]),
# high=abs(g[d] - self.scale_bounds[d, 1]))

# This is added so we only create offsets in one quadrant

np.random.uniform(
low=-abs(g[d] - self.scale_bounds[d, 0]),
high=abs(g[d] - self.scale_bounds[d, 1]))
high=0.0)
for d in range(self.dimensionality)
]
)
Expand Down
4 changes: 2 additions & 2 deletions src/f3dasm/_src/datageneration/functions/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def execute(self, experiment_sample: ExperimentSample) -> ExperimentSample:
x = x._value
if isinstance(x, ArrayBox):
x = x._value

experiment_sample["y"] = float(self(x).ravel().astype(np.float32))
y = np.nan_to_num(self(x), nan=np.nan)
experiment_sample["y"] = float(y.ravel().astype(np.float64))
return experiment_sample

def _run(
Expand Down
28 changes: 14 additions & 14 deletions src/f3dasm/_src/datageneration/functions/pybenchfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Bartels(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -660,7 +660,7 @@ class BukinN6(PyBenchFunction):
continuous = True
convex = True
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -737,7 +737,7 @@ class CrossInTray(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -1249,7 +1249,7 @@ class HolderTable(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -1650,7 +1650,7 @@ class Powell(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2116,7 +2116,7 @@ class Schwefel(PyBenchFunction):
continuous = True
convex = False
separable = True
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2155,7 +2155,7 @@ class Schwefel2_20(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2193,7 +2193,7 @@ class Schwefel2_21(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2231,7 +2231,7 @@ class Schwefel2_22(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2270,7 +2270,7 @@ class Schwefel2_23(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2490,7 +2490,7 @@ class Sphere(PyBenchFunction):
continuous = True
convex = True
separable = True
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2750,7 +2750,7 @@ class XinSheYangN2(PyBenchFunction):
continuous = False
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = True
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2828,7 +2828,7 @@ class XinSheYangN4(PyBenchFunction):
continuous = True
convex = True
separable = False
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down Expand Up @@ -2866,7 +2866,7 @@ class Zakharov(PyBenchFunction):
continuous = True
convex = False
separable = False
differentiable = False
differentiable = True
multimodal = False
randomized_term = False
parametric = False
Expand Down
Loading

0 comments on commit f20d70d

Please sign in to comment.