aeon icon indicating copy to clipboard operation
aeon copied to clipboard

[ENH] Type hints for primitives and string arguments

Open TonyBagnall opened this issue 10 months ago • 6 comments

Describe the feature or idea you want to propose

we would like to increase the use of type hints, and a good first issue is to add them for the simplest case when arguments are primitives (int, float, bool) or strings. Pick a package, look through the code and add type hints. Just for primitives for now, more complex types need a bit of thought. Many have npt.ArrayLike types, but we have not decided on standardising on that, so leave these alone. Dont feel you have to do them all, this is a good first issue to get you started.

Describe your proposed solution

for example, the constructor for the anomaly detection algorithm STRAY has these type hints

    def __init__(
        self,
        alpha: float = 0.01,
        k: int = 10,
        knn_algorithm: str = "brute",
        p: float = 0.5,
        size_threshold: int = 50,
        outlier_tail: str = "max",
    ):

but the segmentation algorithm CLASP does not

def _is_trivial_match(candidate, change_points, n_timepoints, exclusion_radius=0.05):
    """Check if a candidate change point is in close proximity to other change points.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

TonyBagnall avatar Apr 22 '24 11:04 TonyBagnall

Hello,

I would like to start on this issue. I am taking up "aeon.classification.distance_based._time_series_neighbors.py" script to start with.

nileenagp avatar Apr 23 '24 19:04 nileenagp

@all-contributors please add @nileenagp for Code

nileenagp avatar Apr 24 '24 21:04 nileenagp

@nileenagp

I've put up a pull request to add @nileenagp! :tada:

allcontributors[bot] avatar Apr 24 '24 21:04 allcontributors[bot]

Hello, I have a doubt here. If I need to use Type[keras.optimizers.Optimizer] in type hints for a parameter, Is it allowed to import "keras" as per the project standards, when it is not required anywhere else in the script?

nileenagp avatar May 08 '24 18:05 nileenagp

No, if the dependency is optional it should not be imported at the top level of a file. This would exclude it from specific type hints like that I imagine.

MatthewMiddlehurst avatar May 08 '24 18:05 MatthewMiddlehurst

Thanks for the confirmation, I will leave that type hint for now.

nileenagp avatar May 08 '24 18:05 nileenagp

Hello @TonyBagnall , is this issue still open to work on ? I would like to work on it , could you please assign it.

Thank you!

YashviMehta03 avatar Nov 16 '24 04:11 YashviMehta03

Hi @YashviMehta03, this one is a bit too big for a single person really. I would post here selecting a part of the package you want to add type hints too and go from there.

MatthewMiddlehurst avatar Nov 28 '24 19:11 MatthewMiddlehurst

Hello @MatthewMiddlehurst , yes right. So to start with, these are the modules where I could add type hints since they are missing :

  1. all the .py files under the following directories : aeon/classification/convolution_based aeon/classification/feature_based

  2. this particular file aeon/classification/early_classification/_probability_threshold.py

I would like to work on it , could you assign it?

YashviMehta03 avatar Dec 19 '24 12:12 YashviMehta03

@YashviMehta03 feel free to open a PR

MatthewMiddlehurst avatar Jan 09 '25 12:01 MatthewMiddlehurst

Hello @TonyBagnall , I would like to work on this issue. I'll start with the aeon/segmentation/_clasp.py script. Could you please assign it? Thank you!

m-jayashreee avatar Feb 07 '25 22:02 m-jayashreee

Hi not going to assign this since it's a large issue people are taking on incrementally but feel free to open a PR.

MatthewMiddlehurst avatar Feb 11 '25 22:02 MatthewMiddlehurst