Skip to content

Commit

Permalink
Add admonition mentioning decorator utility
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Dec 20, 2024
1 parent 4c36257 commit 6a7d0ca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/userguide/simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ def lookup(df: pd.DataFrame) -> pd.DataFrame:
lookup(searchspace.continuous.sample_uniform(10))
```

````{admonition} Array-Based Callables
:class: tip
If you already have a lookup callable available in an array-based format (for instance,
if your lookup values are generated using third-party code that works with array inputs
and outputs), you can effortlessly convert this callable into the required
dataframe-based format by applying our
{func}`~baybe.utils.dataframe.arrays_to_dataframes` decorator.
For example, the above lookup can be equivalently created as follows:
```python
@arrays_to_dataframes(["p1"], ["t1"])
def lookup(array: np.ndarray) -> np.ndarray:
"""The same lookup function in array logic."""
return array ** 2
```
````


### Using a Dataframe

When dealing with discrete search spaces, it is also possible to provide the lookup values in a tabular representation using a dataframe.
Expand Down

0 comments on commit 6a7d0ca

Please sign in to comment.