<commit_before>#Named such to not clash with matplotlib
from .base import BaseChart

import StringIO
import base64


class BaseMatplotlibChart(BaseChart):

    def get_template(self):
        return "graphos/matplotlib_renderer/line_chart.html"

    def get_serieses(self):
        data_only = self.get_data()[1:]
        serieses = []
        for i in range(0, len(self.header)):
            current_column = [float(el[i]) for el in data_only]
            serieses.append(current_column)
        return serieses


class LineChart(BaseMatplotlibChart):

    def get_image(self):
        import matplotlib.pyplot as plt
        serieses = self.get_serieses()
        for i in range(1, len(serieses)):
            plt.plot(serieses[0], serieses[i])
        plt.axis("off")
        out = StringIO.StringIO()
        plt.savefig(out)
        out.seek(0)
        return "data:image/png;base64,%s" % base64.encodestring(out.read())


class BarChart(BaseMatplotlibChart):

    def get_image(self):
        import matplotlib.pyplot as plt
        fig = plt.figure()
        ax = fig.add_subplot(111)
        serieses = self.get_serieses()
        for i in range(1, len(serieses)):
            ax.bar(serieses[0], serieses[1], 0.35)
        plt.axis("off")
        out = StringIO.StringIO()
        plt.savefig(out)
        out.seek(0)
        return "data:image/png;base64,%s" % base64.encodestring(out.read())<commit_msg>used global imports<commit_after>#Named such to not clash with matplotlib
from .base import BaseChart
import matplotlib.pyplot as plt
import StringIO
import base64


class BaseMatplotlibChart(BaseChart):

    def get_template(self):
        return "graphos/matplotlib_renderer/line_chart.html"

    def get_serieses(self):
        data_only = self.get_data()[1:]
        serieses = []
        for i in range(0, len(self.header)):
            current_column = [float(el[i]) for el in data_only]
            serieses.append(current_column)
        return serieses


class LineChart(BaseMatplotlibChart):

    def get_image(self):
        serieses = self.get_serieses()
        for i in range(1, len(serieses)):
            plt.plot(serieses[0], serieses[i])
        plt.axis("off")
        out = StringIO.StringIO()
        plt.savefig(out)
        out.seek(0)
        return "data:image/png;base64,%s" % base64.encodestring(out.read())


class BarChart(BaseMatplotlibChart):

    def get_image(self):
        fig = plt.figure()
        ax = fig.add_subplot(111)
        serieses = self.get_serieses()
        for i in range(1, len(serieses)):
            ax.bar(serieses[0], serieses[1], 0.35)
        plt.axis("off")
        out = StringIO.StringIO()
        plt.savefig(out)
        out.seek(0)
        return "data:image/png;base64,%s" % base64.encodestring(out.read())
{'fraction_non_alphanumeric': 0.11741472172351886, 'fraction_numerical': 0.017953321364452424, 'mean_word_length': 2.6134889753566797, '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': '1070131', 'n_tokens_mistral': 938, 'n_tokens_neox': 904, 'n_words': 187}