<commit_before>from datetime import datetime

import numpy as np
from matplotlib.dates import date2num


def ensure_float(value):
    """Make sure datetime values are properly converted to floats."""
    try:
        # the last 3 boolean checks are for arrays with datetime64 and with
        # a timezone, see these SO posts:
        # https://stackoverflow.com/q/60714568/4549682
        # https://stackoverflow.com/q/23063362/4549682
        # somewhere, the datetime64 with timezone is getting converted to 'O' dtype
        if (
            isinstance(value, datetime)
            or isinstance(value, np.datetime64)
            or np.issubdtype(value.dtype, np.datetime64)
            or str(value.dtype).startswith("datetime64")
            or value.dtype == "O"
        ):
            return date2num(value)
        else:  # another numpy dtype like float64
            return np.asarray(value, dtype=float)
    except AttributeError:  # possibly int or other float/int dtype
        return value


# From https://www.geeksforgeeks.org/maximum-bipartite-matching/
class GFG:
    def __init__(self, graph):

        # residual graph
        self.graph = graph
        self.ppl = len(graph)
        self.jobs = len(graph[0])

    # A DFS based recursive function that returns true if a matching for vertex
    # u is possible
    def bpm(self, u, matchR, seen):

        # Try every job one by one
        for v in range(self.jobs):<commit_msg>More thorough check of datetime<commit_after>from datetime import datetime

import numpy as np
from matplotlib.dates import date2num


def ensure_float(value):
    """Make sure datetime values are properly converted to floats."""
    try:
        # the last 3 boolean checks are for arrays with datetime64 and with
        # a timezone, see these SO posts:
        # https://stackoverflow.com/q/60714568/4549682
        # https://stackoverflow.com/q/23063362/4549682
        is_date_array = np.issubdtype(value.dtype, np.datetime64) or str(
            value.dtype
        ).startswith("datetime64")
        is_array_of_dates = value.dtype == "O" and all(
            isinstance(val, (datetime, np.datetime64)) for val in value
        )
        if (
            isinstance(value, (datetime, np.datetime64))
            or is_date_array
            or is_array_of_dates
        ):
            return date2num(value)
        else:  # another numpy dtype like float64
            return np.asarray(value, dtype=float)
    except AttributeError:  # possibly int or other float/int dtype
        return value


# From https://www.geeksforgeeks.org/maximum-bipartite-matching/
class GFG:
    def __init__(self, graph):

        # residual graph
        self.graph = graph
        self.ppl = len(graph)
        self.jobs = len(graph[0])

    # A DFS based recursive function that returns true if a matching for vertex
    # u is possible
    def bpm(self, u, matchR, seen):

        # Try every job one by one
        for v in range(self.jobs):
{'fraction_non_alphanumeric': 0.08333333333333333, 'fraction_numerical': 0.030789825970548863, 'mean_word_length': 2.343400447427293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '5244162', 'n_tokens_mistral': 906, 'n_tokens_neox': 840, 'n_words': 277}