<commit_before>from __future__ import absolute_import, division, print_function
from plottool import interact_rois
from plottool import draw_func2 as df2
import os

class ROI_Interaction2:
    def __init__(self, ibs, gid):
        self.ibs = ibs
        self.gid = gid
        img = ibs.get_images(self.gid)
        self.rid_list = ibs.get_image_rids(self.gid)
        bbox_list = ibs.get_roi_bboxes(self.rid_list)
        theta_list = ibs.get_roi_thetas(self.rid_list)
        self.interact_ROIS = interact_rois.ROIInteraction(img, fnum=1, callback=self.callback,bbox_list=bbox_list, theta_list=theta_list)
        #exec(df2.present())
        df2.update()

    def callback(self, deleted_list, changed_list, new_list):
        #print("Deleted BBoxes")
        if len(deleted_list) > 0:
            deleted = [self.rid_list[del_index] for del_index in deleted_list]
            #print(deleted)
            self.ibs.delete_rois(deleted)
        #print("Changed BBoxes")
        if len(changed_list) > 0:
            changed_rid = [self.rid_list[changed[0]] for changed in changed_list]
            changed_bbox = [changed[1] for changed in changed_list]
            #print(changed_rid)
            #print(changed_bbox)
            self.ibs.set_roi_bboxes(changed_rid, changed_bbox)
        #print("New BBoxes")
        if len(new_list) > 0:
            #print(new_list)
            self.ibs.add_rois([self.gid] * len(new_list), new_list)
        thumb_path, image_path, bbox_list = self.ibs.get_image_thumbs_paths(self.gid)
        print("Current BBoxes")
        print(bbox_list)
        if os.path.exists(thumb_path):
            os.remove(thumb_path) #Force refresh
<commit_msg>Removed hard coded fnum<commit_after>from __future__ import absolute_import, division, print_function
from plottool import interact_rois
from plottool import draw_func2 as df2
import os

class ROI_Interaction2:
    def __init__(self, ibs, gid):
        self.ibs = ibs
        self.gid = gid
        img = ibs.get_images(self.gid)
        self.rid_list = ibs.get_image_rids(self.gid)
        bbox_list = ibs.get_roi_bboxes(self.rid_list)
        theta_list = ibs.get_roi_thetas(self.rid_list)
        self.interact_ROIS = interact_rois.ROIInteraction(img, callback=self.callback,bbox_list=bbox_list, theta_list=theta_list)
        #exec(df2.present())
        df2.update()

    def callback(self, deleted_list, changed_list, new_list):
        #print("Deleted BBoxes")
        if len(deleted_list) > 0:
            deleted = [self.rid_list[del_index] for del_index in deleted_list]
            #print(deleted)
            self.ibs.delete_rois(deleted)
        #print("Changed BBoxes")
        if len(changed_list) > 0:
            changed_rid = [self.rid_list[changed[0]] for changed in changed_list]
            changed_bbox = [changed[1] for changed in changed_list]
            #print(changed_rid)
            #print(changed_bbox)
            self.ibs.set_roi_bboxes(changed_rid, changed_bbox)
        #print("New BBoxes")
        if len(new_list) > 0:
            #print(new_list)
            self.ibs.add_rois([self.gid] * len(new_list), new_list)
        thumb_path, image_path, bbox_list = self.ibs.get_image_thumbs_paths(self.gid)
        print("Current BBoxes")
        print(bbox_list)
        if os.path.exists(thumb_path):
            os.remove(thumb_path) #Force refresh

{'fraction_non_alphanumeric': 0.0980975029726516, 'fraction_numerical': 0.00624256837098692, 'mean_word_length': 2.7851518560179978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4423332', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1148, 'n_words': 208}