<commit_before>import random
import string
import json

from django.template.loader import render_to_string


random_letter = lambda: random.choice(string.ascii_letters)

DEFAULT_HEIGHT = 400
DEFAULT_WIDTH = 800


class BaseChart(object):
    def __init__(self, data_source, html_id=None,
                 width=None, height=None,
                 options=None, *args, **kwargs):
        self.data_source = data_source
        self.html_id = html_id or "".join([random_letter()
                                          for el in range(10)])

        self.height = height or DEFAULT_HEIGHT
        self.width = width or DEFAULT_WIDTH
        self.options = options or {}
        self.header = data_source.get_header()

    def get_data(self):
        return self.data_source.get_data()

    def get_data_json(self):
        return json.dumps(self.get_data())

    def get_options(self):
        options = self.options
        if not 'title' in options:
            options['title'] = "Chart"
        return options

    def get_options_json(self):
        return json.dumps(self.get_options())

    def get_html_id(self):
        return self.html_id

    def get_template(self):
        return 'charts/base_chart.html'

    def as_html(self):
        context = {"chart": self}
        return render_to_string(self.get_template(), context)<commit_msg>used get_default_options in get_options method<commit_after>import random
import string
import json

from django.template.loader import render_to_string
from ..utils import get_default_options


random_letter = lambda: random.choice(string.ascii_letters)

DEFAULT_HEIGHT = 400
DEFAULT_WIDTH = 800


class BaseChart(object):
    def __init__(self, data_source, html_id=None,
                 width=None, height=None,
                 options=None, *args, **kwargs):
        self.data_source = data_source
        self.html_id = html_id or "".join([random_letter()
                                          for el in range(10)])

        self.height = height or DEFAULT_HEIGHT
        self.width = width or DEFAULT_WIDTH
        self.options = options or {}
        self.header = data_source.get_header()

    def get_data(self):
        return self.data_source.get_data()

    def get_data_json(self):
        return json.dumps(self.get_data())

    def get_options(self):
        options = get_default_options()
        options.update(self.options)
        return options

    def get_options_json(self):
        return json.dumps(self.get_options())

    def get_html_id(self):
        return self.html_id

    def get_template(self):
        return 'charts/base_chart.html'

    def as_html(self):
        context = {"chart": self}
        return render_to_string(self.get_template(), context)
{'fraction_non_alphanumeric': 0.09143897996357013, 'fraction_numerical': 0.0058287795992714025, 'mean_word_length': 2.5616083009079116, 'pattern_counts': {'":': 2, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3483148', 'n_tokens_mistral': 820, 'n_tokens_neox': 778, 'n_words': 185}