<commit_before>"""Utilities and helper functions."""

import json
import datetime


def isfloat(v):
    try:
        float(v)
        return True
    except ValueError:
        return False


# Extend JSON Encoder to support ISO 8601 format dates
class DateEncoder(json.JSONEncoder):
    def default(self, obj):

        if isinstance(obj, (datetime.date, datetime.datetime)):
            return obj.replace(microsecond=0).isoformat() + ".%03dZ" % (obj.microsecond // 1000)<commit_msg>catch TypeError when testing for float<commit_after>"""Utilities and helper functions."""

import json
import datetime


def isfloat(v):
    try:
        float(v)
        return True
    except (ValueError, TypeError):
        return False


# Extend JSON Encoder to support ISO 8601 format dates
class DateEncoder(json.JSONEncoder):
    def default(self, obj):

        if isinstance(obj, (datetime.date, datetime.datetime)):
            return obj.replace(microsecond=0).isoformat() + ".%03dZ" % (obj.microsecond // 1000)
{'fraction_non_alphanumeric': 0.10813492063492064, 'fraction_numerical': 0.021825396825396824, 'mean_word_length': 3.221757322175732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7282274', 'n_tokens_mistral': 304, 'n_tokens_neox': 279, 'n_words': 87}