<commit_before>import logging

import sage.all
import sage.calculus.var
from   sage.matrix.matrix_symbolic_dense import Matrix_symbolic_dense
from   sage.misc.parser import Parser
from   sage.symbolic.expression import Expression
from   sage.symbolic.operators import mul_vararg
from   sage.symbolic.ring import SR

log = logging.getLogger('delirium')

_parser = Parser(make_var=sage.calculus.var.var)

def alphabet(ex, x):
    """Return bases of all negative exponents in the `x'-polynomial `ex'.

    >>> ex = new_Expression('a/x + b/x^2 + c/(1+x)^2')
    >>> alphabet(ex, 'x')
    set([x, x + 1])"""
    x = var(x)
    result = set()
    a, n = SR.wild(1), SR.wild(2)
    p_exp = a**n
    pts = singularities(ex, x)
    for pt in pts:
        r = pt.match(p_exp)
        if r:
            result.add(r[a])
        else:
            result.add(pt)
    return result

def is_Expression(obj):
    return type(obj) is Expression

def new_Expression(obj):
    if type(obj) == str:
        try:
            ex = new_Expression_from_string(obj)<commit_msg>Fix a doctest for 'alphabet'<commit_after>import logging

import sage.all
import sage.calculus.var
from   sage.matrix.matrix_symbolic_dense import Matrix_symbolic_dense
from   sage.misc.parser import Parser
from   sage.symbolic.expression import Expression
from   sage.symbolic.operators import mul_vararg
from   sage.symbolic.ring import SR

log = logging.getLogger('delirium')

_parser = Parser(make_var=sage.calculus.var.var)

def alphabet(ex, x):
    """Return bases of all negative exponents in the `x'-polynomial `ex'.

    >>> ex = new_Expression('a/x + b/x^2 + c/(1+x)^2')
    >>> al = alphabet(ex, 'x')
    >>> from pprint import pprint; pprint(al)
    set([x, x + 1])"""
    x = var(x)
    result = set()
    a, n = SR.wild(1), SR.wild(2)
    p_exp = a**n
    pts = singularities(ex, x)
    for pt in pts:
        r = pt.match(p_exp)
        if r:
            result.add(r[a])
        else:
            result.add(pt)
    return result

def is_Expression(obj):
    return type(obj) is Expression

def new_Expression(obj):
    if type(obj) == str:
        try:
            ex = new_Expression_from_string(obj)
{'fraction_non_alphanumeric': 0.12488479262672811, 'fraction_numerical': 0.005529953917050691, 'mean_word_length': 2.883720930232558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '6922121', 'n_tokens_mistral': 779, 'n_tokens_neox': 766, 'n_words': 193}