def main():
    parser = create_parser()
    # Parse command line options

    options, args = parser.parse_args()

    if not len(args) == 1:
        parser.print_help()
        sys.exit(1)

    filename = args[0]

    if filename[-4:] == ".csv":
        outFilenameBase = filename[:-4]
    else:
        outFilenameBase = filename

    outFilename = outFilenameBase + "_complexPlaces.csv"

    print "output to", outFilename

    censusTable = readCensusTable(filename, convertData=False)

    fieldnames = censusTable.header
    if not "NumberOfComplexPlaces" in fieldnames:
        fieldnames = fieldnames + ["NumberOfComplexPlaces"]

    csv_writer = csv.DictWriter(open(outFilename, "w"), fieldnames=fieldnames)

    csv_writer.writerow(dict(zip(fieldnames, fieldnames)))

    for row in censusTable.listOfDicts:
        if row.has_key("InvariantTraceField"):
            if row["InvariantTraceField"] and not row["InvariantTraceField"] == "-":

                pariStr = "nfinit(%s).r2" % row["InvariantTraceField"]

                row["NumberOfComplexPlaces"] = pari.pari_eval(pariStr)

        csv_writer.writerow(row)
Ejemplo n.º 2
0
from csvUtilities.readCensusTable import readCensusTable
import globalsettings
import mpmath
from linearCombinations import binarySearch, filterRepresentativeMfds, twoTerms
from linearCombinations.formatLinearCombination import formatLinearCombination

mpmath.mp.dps = 70
globalsettings.setSetting("maximalError", mpmath.mpf("0.1") ** 50)
globalsettings.setSetting("maximalErrorDigits", 50)

testCensusTablePath = globalsettings.getSetting("testCensusTablePath")
censusTableFile = testCensusTablePath + "/exampleCensusTable.csv"
censusTable = readCensusTable(censusTableFile, sortKey="Volume")

representatives = filterRepresentativeMfds.filterRepresentativeMfds(censusTable.listOfDicts)


def checkBinarySearchResult(vol, resultNames):

    if isinstance(vol, str):
        vol = mpmath.mpf(vol)

    rows = binarySearch.matchingRows(censusTable.listOfDicts, "Volume", vol)
    names = [row["Name"] for row in rows]

    assert set(resultNames) == set(names), Exception("Expected: %s\nGot %s" % (resultNames, names))


def testBinarySearch():

    checkBinarySearchResult(