<commit_before>from django.contrib.humanize.templatetags.humanize import intcomma
from django.template import Library, Context
from django.conf import settings
from django.utils.timezone import utc
from django.db.models import Q, Avg, Max, Min, Sum, Count
from django.core.serializers import serialize
from django.db.models.query import QuerySet
from django.template import Library
from dateutil import parser
from datetime import datetime, date, time, timedelta
import json
import logging
import decimal
import calculate
import math

logger = logging.getLogger("kpcc_backroom_handshakes")

register = Library()


@register.filter
def currency(dollars):
    dollars = round(int(dollars), 2)
    return "$%s" % (intcomma(int(dollars)))


@register.filter
def neg_to_posi(value):
    return abs(value)


@register.filter
def percentage(value):
    return "%s" % (value*100)

register.filter(currency)
register.filter(neg_to_posi)
register.filter(percentage)<commit_msg>fixes issue where we assume we'd get a value to offer back to the template as a percentage<commit_after>from django.contrib.humanize.templatetags.humanize import intcomma
from django.template import Library, Context
from django.conf import settings
from django.utils.timezone import utc
from django.db.models import Q, Avg, Max, Min, Sum, Count
from django.core.serializers import serialize
from django.db.models.query import QuerySet
from django.template import Library
from dateutil import parser
from datetime import datetime, date, time, timedelta
import json
import logging
import decimal
import calculate
import math

logger = logging.getLogger("kpcc_backroom_handshakes")

register = Library()


@register.filter
def currency(dollars):
    dollars = round(int(dollars), 2)
    return "$%s" % (intcomma(int(dollars)))


@register.filter
def neg_to_posi(value):
    return abs(value)


@register.filter
def percentage(value):
    if value == None:
        return "N/A"
    else:
        return "%s" % (value*100)


register.filter(currency)
register.filter(neg_to_posi)
register.filter(percentage)
{'fraction_non_alphanumeric': 0.08796520057999033, 'fraction_numerical': 0.0038666022232962784, 'mean_word_length': 5.408668730650155, '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': '6265911', 'n_tokens_mistral': 629, 'n_tokens_neox': 605, 'n_words': 194}