CoolFace
Datasetpublic

23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct

Dataset Card for LLMcoder-GitHub-Python-Mix-Direct Python target autocomplete suggestions in the format of conversations for OpenAI's fine-tuning. Dataset Details Dataset Description Curated by: [More Information Needed] Funded by [optional]: [More Information Needed] Shared by [optional]: [More Information Needed] Language(s) (NLP): [More Information Needed] License: [More Information Needed] Dataset Sources [optional] The data… See the full description on the dataset page: https://huggingface.co/datasets/23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct.

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes216downloads
input.txt407 linesDownload Raw Back to pair_23
1.2 3        other: a number4 5        returns: new Pmf6        """7        pmf = Pmf()8        for v1, p1 in self.Items():9            pmf.Set(v1 + other, p1)10        return pmf11 12    def __sub__(self, other):13        """Computes the Pmf of the diff of values drawn from self and other.14 15        other: another Pmf16 17        returns: new Pmf18        """19        try:20            return self.SubPmf(other)21        except AttributeError:22            return self.AddConstant(-other)23 24    def SubPmf(self, other):25        """Computes the Pmf of the diff of values drawn from self and other.26 27        other: another Pmf28 29        returns: new Pmf30        """31        pmf = Pmf()32        for v1, p1 in self.Items():33            for v2, p2 in other.Items():34                pmf.Incr(v1 - v2, p1 * p2)35        return pmf36 37    def __mul__(self, other):38        """Computes the Pmf of the product of values drawn from self and other.39 40        other: another Pmf41 42        returns: new Pmf43        """44        try:45            return self.MulPmf(other)46        except AttributeError:47            return self.MulConstant(other)48 49    def MulPmf(self, other):50        """Computes the Pmf of the diff of values drawn from self and other.51 52        other: another Pmf53 54        returns: new Pmf55        """56        pmf = Pmf()57        for v1, p1 in self.Items():58            for v2, p2 in other.Items():59                pmf.Incr(v1 * v2, p1 * p2)60        return pmf61 62    def MulConstant(self, other):63        """Computes the Pmf of the product of a constant and values from self.64 65        other: a number66 67        returns: new Pmf68        """69        pmf = Pmf()70        for v1, p1 in self.Items():71            pmf.Set(v1 * other, p1)72        return pmf73 74    def __div__(self, other):75        """Computes the Pmf of the ratio of values drawn from self and other.76 77        other: another Pmf78 79        returns: new Pmf80        """81        try:82            return self.DivPmf(other)83        except AttributeError:84            return self.MulConstant(1/other)85 86    __truediv__ = __div__87 88    def DivPmf(self, other):89        """Computes the Pmf of the ratio of values drawn from self and other.90 91        other: another Pmf92 93        returns: new Pmf94        """95        pmf = Pmf()96        for v1, p1 in self.Items():97            for v2, p2 in other.Items():98                pmf.Incr(v1 / v2, p1 * p2)99        return pmf100 101    def Max(self, k):102        """Computes the CDF of the maximum of k selections from this dist.103 104        k: int105 106        returns: new Cdf107        """108        cdf = self.MakeCdf()109        return cdf.Max(k)110 111 112class Joint(Pmf):113    """Represents a joint distribution.114 115    The values are sequences (usually tuples)116    """117 118    def Marginal(self, i, label=None):119        """Gets the marginal distribution of the indicated variable.120 121        i: index of the variable we want122 123        Returns: Pmf124        """125        pmf = Pmf(label=label)126        for vs, prob in self.Items():127            pmf.Incr(vs[i], prob)128        return pmf129 130    def Conditional(self, i, j, val, label=None):131        """Gets the conditional distribution of the indicated variable.132 133        Distribution of vs[i], conditioned on vs[j] = val.134 135        i: index of the variable we want136        j: which variable is conditioned on137        val: the value the jth variable has to have138 139        Returns: Pmf140        """141        pmf = Pmf(label=label)142        for vs, prob in self.Items():143            if vs[j] != val:144                continue145            pmf.Incr(vs[i], prob)146 147        pmf.Normalize()148        return pmf149 150    def MaxLikeInterval(self, percentage=90):151        """Returns the maximum-likelihood credible interval.152 153        If percentage=90, computes a 90% CI containing the values154        with the highest likelihoods.155 156        percentage: float between 0 and 100157 158        Returns: list of values from the suite159        """160        interval = []161        total = 0162 163        t = [(prob, val) for val, prob in self.Items()]164        t.sort(reverse=True)165 166        for prob, val in t:167            interval.append(val)168            total += prob169            if total >= percentage / 100.0:170                break171 172        return interval173 174 175def MakeJoint(pmf1, pmf2):176    """Joint distribution of values from pmf1 and pmf2.177 178    Assumes that the PMFs represent independent random variables.179 180    Args:181        pmf1: Pmf object182        pmf2: Pmf object183 184    Returns:185        Joint pmf of value pairs186    """187    joint = Joint()188    for v1, p1 in pmf1.Items():189        for v2, p2 in pmf2.Items():190            joint.Set((v1, v2), p1 * p2)191    return joint192 193 194def MakeHistFromList(t, label=None):195    """Makes a histogram from an unsorted sequence of values.196 197    Args:198        t: sequence of numbers199        label: string label for this histogram200 201    Returns:202        Hist object203    """204    return Hist(t, label=label)205 206 207def MakeHistFromDict(d, label=None):208    """Makes a histogram from a map from values to frequencies.209 210    Args:211        d: dictionary that maps values to frequencies212        label: string label for this histogram213 214    Returns:215        Hist object216    """217    return Hist(d, label)218 219 220def MakePmfFromList(t, label=None):221    """Makes a PMF from an unsorted sequence of values.222 223    Args:224        t: sequence of numbers225        label: string label for this PMF226 227    Returns:228        Pmf object229    """230    return Pmf(t, label=label)231 232 233def MakePmfFromDict(d, label=None):234    """Makes a PMF from a map from values to probabilities.235 236    Args:237        d: dictionary that maps values to probabilities238        label: string label for this PMF239 240    Returns:241        Pmf object242    """243    return Pmf(d, label=label)244 245 246def MakePmfFromItems(t, label=None):247    """Makes a PMF from a sequence of value-probability pairs248 249    Args:250        t: sequence of value-probability pairs251        label: string label for this PMF252 253    Returns:254        Pmf object255    """256    return Pmf(dict(t), label=label)257 258 259def MakePmfFromHist(hist, label=None):260    """Makes a normalized PMF from a Hist object.261 262    Args:263        hist: Hist object264        label: string label265 266    Returns:267        Pmf object268    """269    if label is None:270        label = hist.label271 272    return Pmf(hist, label=label)273 274 275def MakeMixture(metapmf, label='mix'):276    """Make a mixture distribution.277 278    Args:279      metapmf: Pmf that maps from Pmfs to probs.280      label: string label for the new Pmf.281 282    Returns: Pmf object.283    """284    mix = Pmf(label=label)285    for pmf, p1 in metapmf.Items():286        for x, p2 in pmf.Items():287            mix.Incr(x, p1 * p2)288    return mix289 290 291def MakeUniformPmf(low, high, n):292    """Make a uniform Pmf.293 294    low: lowest value (inclusive)295    high: highest value (inclusize)296    n: number of values297    """298    pmf = Pmf()299    for x in np.linspace(low, high, n):300        pmf.Set(x, 1)301    pmf.Normalize()302    return pmf303 304 305class Cdf(object):306    """Represents a cumulative distribution function.307 308    Attributes:309        xs: sequence of values310        ps: sequence of probabilities311        label: string used as a graph label.312    """313    def __init__(self, obj=None, ps=None, label=None):314        """Initializes.315        316        If ps is provided, obj must be the corresponding list of values.317 318        obj: Hist, Pmf, Cdf, Pdf, dict, pandas Series, list of pairs319        ps: list of cumulative probabilities320        label: string label321        """322        self.label = label if label is not None else '_nolegend_'323 324        if isinstance(obj, (_DictWrapper, Cdf, Pdf)):325            if not label:326                self.label = label if label is not None else obj.label327 328        if obj is None:329            # caller does not provide obj, make an empty Cdf330            self.xs = np.asarray([])331            self.ps = np.asarray([])332            if ps is not None:333                logging.warning("Cdf: can't pass ps without also passing xs.")334            return335        else:336            # if the caller provides xs and ps, just store them          337            if ps is not None:338                if isinstance(ps, str):339                    logging.warning("Cdf: ps can't be a string")340 341                self.xs = np.asarray(obj)342                self.ps = np.asarray(ps)343                return344 345        # caller has provided just obj, not ps346        if isinstance(obj, Cdf):347            self.xs = copy.copy(obj.xs)348            self.ps = copy.copy(obj.ps)349            return350 351        if isinstance(obj, _DictWrapper):352            dw = obj353        else:354            dw = Hist(obj)355 356        if len(dw) == 0:357            self.xs = np.asarray([])358            self.ps = np.asarray([])359            return360 361        xs, freqs = zip(*sorted(dw.Items()))362        self.xs = np.asarray(xs)363        self.ps = np.cumsum(freqs, dtype=np.float)364        self.ps /= self.ps[-1]365 366    def __str__(self):367        return 'Cdf(%s, %s)' % (str(self.xs), str(self.ps))368 369    __repr__ = __str__370 371    def __len__(self):372        return len(self.xs)373 374    def __getitem__(self, x):375        return self.Prob(x)376 377    def __setitem__(self):378        raise UnimplementedMethodException()379 380    def __delitem__(self):381        raise UnimplementedMethodException()382 383    def __eq__(self, other):384        return np.all(self.xs == other.xs) and np.all(self.ps == other.ps)385 386    def Copy(self, label=None):387        """Returns a copy of this Cdf.388 389        label: string label for the new Cdf390        """391        if label is None:392            label = self.label393        return Cdf(list(self.xs), list(self.ps), label=label)394 395    def MakePmf(self, label=None):396        """Makes a Pmf."""397        if label is None:398            label = self.label399        return Pmf(self, label=label)400 401    def Values(self):402        """Returns a sorted list of values.403        """404        return self.xs405 406    def Items(self):407        """Returns a sorted sequence o