Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Reference Examples" #1042

Open
seanlaw opened this issue Nov 2, 2024 · 0 comments
Open

Add "Reference Examples" #1042

seanlaw opened this issue Nov 2, 2024 · 0 comments

Comments

@seanlaw
Copy link
Contributor

seanlaw commented Nov 2, 2024

In our API documentation, some parameters are described but it may not seem obvious how to use them. Thus, it would be beneficial to add additional "reference examples". For instance, throughout our API, we have the parameter T_A_subseq_isconstant, which has the rather technical description of:

A boolean array that indicates whether a subsequence in T_A is constant (True). Alternatively, a custom, user-defined function that returns a boolean array that indicates whether a subsequence in T_A is constant (True). The function must only take two arguments, a, a 1-D array, and w, the window size, while additional arguments may be specified by currying the user-defined function using functools.partial. Any subsequence with at least one np.nan/np.inf will automatically have its corresponding value set to False in this boolean array.

It would be nice to provide a separate example of what a "user-defined function" would look like and to stick it into a reference section outside of the API documentation but with a cross-reference inserted.

According to the diataxis:

Reference guides are technical descriptions of the machinery and how to operate it. Reference material is information-oriented.

Reference material contains propositional or theoretical knowledge that a user looks to in their work.

The only purpose of a reference guide is to describe, as succinctly as possible, and in an orderly way. Whereas the content of tutorials and how-to guides are led by needs of the user, reference material is led by the product it describes.

So, the reference example should be succinct and not verbose (like the tutorials). I'd prefer a short technical description (if necessary) and then a code example:

import numpy as np
import stumpy

def custom_isconstant_func(a, w):
    isconstant_array = numpy.full(a - w + 1, False, dtype=bool)
    for i in range(a - w + 1):
        if np.min(a[i : i + w]) == np.max(a[i : i + w]):
            isconstant_array[i] = True
    ...
    return isconstant_array

stumpy.stump(T, m, T_A_subseq_isconstant=custom_isconstant_func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant