コード例 #1
0
def process_oeis_entry(oeis_entry):

    (oeis_id, main_content, bfile_content) = oeis_entry

    parsed_entry = parse_oeis_entry(oeis_id, main_content, bfile_content)

    result = (
        parsed_entry.oeis_id,
        parsed_entry.identification,
        ",".join(str(value) for value in parsed_entry.values),
        parsed_entry.name,
        parsed_entry.comments,
        parsed_entry.detailed_references,
        parsed_entry.links,
        parsed_entry.formulas,
        parsed_entry.examples,
        parsed_entry.maple_programs,
        parsed_entry.mathematica_programs,
        parsed_entry.other_programs,
        parsed_entry.cross_references,
        ",".join(str(keyword) for keyword in parsed_entry.keywords),
        parsed_entry.offset_a,
        parsed_entry.offset_b,
        parsed_entry.author,
        parsed_entry.extensions_and_errors
    )

    return result
コード例 #2
0
def process_oeis_entry(work):

    (oeis_id, main_content, bfile_content, terms) = work

    parsed_entry = parse_oeis_entry(oeis_id, main_content, bfile_content)

    if parsed_entry.offset_a is None:
        logger.warning("A{:06d} Skipping sequence without declared first index.".format(parsed_entry.oeis_id))
        solution = None
    else:
        max_value =  max(abs(v) for v in parsed_entry.values)
        max_value_digit_count = len(str(max_value))

        if max_value_digit_count >= 10000:
            logger.info("[A{:06d}] Skipping sequence with very large values ({} digits).".format(parsed_entry.oeis_id, max_value_digit_count))
            solution = None
        else:
            first_index = parsed_entry.offset_a
            # Turn the sequence data in a lookup dictionary.
            lookup = OrderedDict((first_index + i, value) for (i, value) in enumerate(parsed_entry.values))
            solution = solve_lineair_equation(parsed_entry.oeis_id, lookup, terms)

    return (parsed_entry, solution)