<commit_before>from django import forms
from django.forms.models import formset_factory, BaseModelFormSet
from django.forms.widgets import NumberInput

from .models import Reading

class ReadingForm(forms.Form):
    ships_head = forms.FloatField(required=False, widget=NumberInput(attrs={'style': "width: 5em;"}))
    deviation  = forms.FloatField(required=False, widget=NumberInput(attrs={'style': "width: 5em;"}))

ReadingFormSet = formset_factory(form=ReadingForm)<commit_msg>Customize degree widget so that if formats floats more elegantly<commit_after>from django import forms
from django.forms.models import formset_factory, BaseModelFormSet
from django.forms.widgets import NumberInput

from .models import Reading

class DegreeInput(NumberInput):

    """Set the default style"""
    def __init__(self, attrs=None):
        if attrs is None:
            attrs = {}
        attrs['style'] = "width: 5em;"

        super(DegreeInput, self).__init__(attrs)

    """Strip decimal points if not needed"""
    def _format_value(self, value):
        return u"%g" % value


class ReadingForm(forms.Form):
    ships_head = forms.FloatField(
        required=False,
        widget=DegreeInput()
    )

    deviation = forms.FloatField(
        required=False,
        widget=DegreeInput()
    )

ReadingFormSet = formset_factory(form=ReadingForm)
{'fraction_non_alphanumeric': 0.10185873605947955, 'fraction_numerical': 0.0022304832713754648, 'mean_word_length': 4.237354085603113, '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': '6851908', 'n_tokens_mistral': 394, 'n_tokens_neox': 379, 'n_words': 99}