<commit_before>from mirqi.core import inquiry
from mirqi.inquiries.operator_improvement import get_procedures_helper, sort_by_rads_helper
import collections
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
import matplotlib.pyplot as plt
import numpy as np

class Operator_Improvement_Surface(inquiry.Inquiry):
    MIN_REPS = inquiry.Inquiry_Parameter(50, "Minimum procedure count",
                                         "The minimum number of times a procedure with the same CPT codes must occur to be considered to have a reasonable distribution")
    PROCS_PER_WINDOW = inquiry.Inquiry_Parameter(100, "Procedures Per Window",
                                                 "Number of procedures that should be considered in the sliding window calculation of the operators performance metric.")
    STEP_SIZE = inquiry.Inquiry_Parameter(50, "Step size",
                                          "Number of procedures between the beginnings of each window. ")
    
    def run(self, procs, context, extra_procs):
        cpt_to_procs = get_procedures_helper(procs, extra_procs, self.MIN_REPS.value)
        self.rad1_to_procs = sort_by_rads_helper(sum(cpt_to_procs.values(),[]), self.PROCS_PER_WINDOW.value)
                                          

    def get_figures2(self):
        
        ys = [(1.0/self.PROCS_PER_WINDOW.value)*(i+1) for i in range(self.PROCS_PER_WINDOW.value)]
        figs= []
        for rad1, procs in self.rad1_to_procs.iteritems():
            max_x = 0
            verts = []
            for i in range(0, len(procs), self.STEP_SIZE.value):
                if i+self.PROCS_PER_WINDOW.value < len(procs):
                    xs = sorted([proc.fluoro for proc in procs[i:i+self.PROCS_PER_WINDOW.value]])
                    if xs[-1]>max_x:
                        max_x = xs[-1]
                    verts.append(zip(xs,ys))
                    verts[-1].append((xs[-1],0))#adds a point to the polygon directly below the last point to draw the baseline correctly
            zs = range(len(verts))
            fig = plt.figure()
            ax = fig.gca(projection='3d')
            ax.set_title(rad1)
            facecolors = [colorConverter.to_rgba('g', alpha=.6) for _ in range(len(verts))]
            poly = PolyCollection(verts,
                              facecolors = facecolors )
            poly.set_alpha(0.7)
            ax.add_collection3d(poly, zs=zs, zdir='y')
            ax.set_xlabel("Fluoro time")
            ax.set_xlim3d(0,10)
            ax.set_zlabel("% of Procedures This Fluoro Time or Below")
            ax.set_ylabel("Time")
            ax.set_ylim3d(0,len(verts))
            plt.show()
            figs.append(fig)
        return figs

    def get_figures2(self):
        all_xs = []
        all_ys = []
        all_zs = []
        ys = [(1.0/self.PROCS_PER_WINDOW.value)*(i+1) for i in range(self.PROCS_PER_WINDOW.value)]
        for rad1, procs in self.rad1_to_procs.iteritems():
            for i in range(0, len(procs), self.STEP_SIZE.value):
                if i+self.PROCS_PER_WINDOW.value < len(procs):
                    xs = sorted([proc.fluoro for proc in procs[i:i+self.PROCS_PER_WINDOW.value]])
                    all_xs += xs
                    all_ys += ys
                    all_zs += [i]*len(xs)
            fig = plt.figure()
            ax = plt.gca(projection='3d')
            surf = ax.plot_surface(np.array(all_xs), np.array(all_ys), np.array(all_zs))
            plt.show()

    def get_figures(self):
        from matplotlib.collections import LineCollection
        ys = [(1.0/self.PROCS_PER_WINDOW.value)*(i+1) for i in range(self.PROCS_PER_WINDOW.value)]
        all_xs = []
        for rad1, procs in self.rad1_to_procs.iteritems():
            for i in range(0, len(procs), self.STEP_SIZE.value):<commit_msg>deleted old get_figures methods from operator_improvement_surface.py<commit_after>from mirqi.core import inquiry
from mirqi.inquiries.operator_improvement import get_procedures_helper, sort_by_rads_helper
import collections
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
import matplotlib.pyplot as plt
import numpy as np

class Operator_Improvement_Surface(inquiry.Inquiry):
    MIN_REPS = inquiry.Inquiry_Parameter(50, "Minimum procedure count",
                                         "The minimum number of times a procedure with the same CPT codes must occur to be considered to have a reasonable distribution")
    PROCS_PER_WINDOW = inquiry.Inquiry_Parameter(100, "Procedures Per Window",
                                                 "Number of procedures that should be considered in the sliding window calculation of the operators performance metric.")
    STEP_SIZE = inquiry.Inquiry_Parameter(50, "Step size",
                                          "Number of procedures between the beginnings of each window. ")
    
    def run(self, procs, context, extra_procs):
        cpt_to_procs = get_procedures_helper(procs, extra_procs, self.MIN_REPS.value)
        self.rad1_to_procs = sort_by_rads_helper(sum(cpt_to_procs.values(),[]), self.PROCS_PER_WINDOW.value)

    def get_figures(self):
        from matplotlib.collections import LineCollection
        ys = [(1.0/self.PROCS_PER_WINDOW.value)*(i+1) for i in range(self.PROCS_PER_WINDOW.value)]
        all_xs = []
        for rad1, procs in self.rad1_to_procs.iteritems():
            for i in range(0, len(procs), self.STEP_SIZE.value):
{'fraction_non_alphanumeric': 0.09027529495888452, 'fraction_numerical': 0.011619592420450483, 'mean_word_length': 2.3603603603603602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '239443', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1666, 'n_words': 403}