<commit_before>from itertools import cycle
from matplotlib.pyplot import cm, figure, gcf, imshow
from geist.colour import rgb_to_hsv, hsv
import numpy


class Viewer(object):
    def __init__(self, gui, repo):
        self._gui = gui
        self._repo = repo

    def save(self, name, force=False):
        self._save(name, self.visible, force=force)

    def _save(self, name, image_to_save, force=False):
        if name in self._repo.entries and force==False:
            raise KeyError(
                name + ' already exists, to overwrite, pass force=True')
        self._repo[name] = image_to_save

    def visible(self):
        a = gcf().get_axes()[0]
        x1, x2 = a.get_xbound()
        y1, y2 = a.get_ybound()
        x1 = int(x1 + 0.5)
        x2 = int(numpy.ceil(x2 + 0.5))
        y1 = int(y1 + 0.5)
        y2 = int(numpy.ceil(y2 + 0.5))
        return numpy.array(a.get_images()[-1].get_array()[y1:y2, x1:x2])
<commit_msg>Fixed save bug<commit_after>from itertools import cycle
from matplotlib.pyplot import cm, figure, gcf, imshow
from geist.colour import rgb_to_hsv, hsv
import numpy


class Viewer(object):
    def __init__(self, gui, repo):
        self._gui = gui
        self._repo = repo

    def save(self, name, force=False):
        self._save(name, self.visible(), force=force)

    def _save(self, name, image_to_save, force=False):
        if name in self._repo.entries and force==False:
            raise KeyError(
                name + ' already exists, to overwrite, pass force=True')
        self._repo[name] = image_to_save

    def visible(self):
        a = gcf().get_axes()[0]
        x1, x2 = a.get_xbound()
        y1, y2 = a.get_ybound()
        x1 = int(x1 + 0.5)
        x2 = int(numpy.ceil(x2 + 0.5))
        y1 = int(y1 + 0.5)
        y2 = int(numpy.ceil(y2 + 0.5))
        return numpy.array(a.get_images()[-1].get_array()[y1:y2, x1:x2])

{'fraction_non_alphanumeric': 0.13022763366860773, 'fraction_numerical': 0.02752779248279513, 'mean_word_length': 2.442622950819672, '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': '2525452', 'n_tokens_mistral': 699, 'n_tokens_neox': 674, 'n_words': 166}