<commit_before>from __future__ import print_function, absolute_import, division

import numpy as np


def path_index(movement, stop_threshold, min_path_length):
    r"""
    Return a list object containing start and end indices
    for a specific movement. Each element in the list is
    a list containing two indices: the first element is
    the start index and the second element is the end index.

    Parameters
    ----------
    movement : pandas.DataFrame
        CT, CX, CY coordinates and homebase status
        for the unique combination of strain, mouse and day
    stop_threshold : float
        positive number indicating the path cutoff criteria
        if the time difference between two observations is
        less than this threhold, they will be in the same path

    min_path_length : int
        positive integer indicating how many observations in
        a path

    Returns
    -------
    paths index : a list containing the indices for all paths

    Examples
    --------
    >>> movement = data.load_movement(1, 2, 1)
    >>> paths = path_index(movement, 1, 1)[:5]
    >>> paths
    [[0, 2], [6, 8], [107, 113], [129, 131], [144, 152]]
    """
    # check if all inputs are positive integers
    conditions_value = [stop_threshold <= 0, min_path_length <= 0]
    conditions_type = type(min_path_length) != int
    if any(conditions_value):
        raise ValueError("Input values need to be positive")
    if conditions_type:
        raise TypeError("min_path_length needs to be integer")

    # Pull out time variable
    T = movement['t'].ravel()
    # Calculate time differences
    TD = np.diff(T)
    path = []

    # index
    i = 0
    while i < len(TD):
        start_index = i
        # If time difference is less than stop_threshold
        # start to track the index in this path
        while TD[i] < stop_threshold:
            i += 1
            if i == len(TD):
                break
        end_index = i

        # Check whether start index is equal to end index
        # If they are equal jump to next index
        if start_index == end_index:
            next
        else:
            path.append([start_index, end_index])

        i += 1
    path = [p for p in path if (p[1] - p[0]) > min_path_length]

    return(path)<commit_msg>ENH: add get_dist_speed to __init__.py<commit_after>from __future__ import print_function, absolute_import, division

from mousestyles import data
from .path_index import path_index
from .filter_path import filter_paths
from .get_dist_speed import get_dist_speed

{'fraction_non_alphanumeric': 0.07773851590106007, 'fraction_numerical': 0.013741656851197487, 'mean_word_length': 2.480874316939891, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3732492', 'n_tokens_mistral': 731, 'n_tokens_neox': 687, 'n_words': 283}