Ejemplo n.º 1
0
def test_rjb_S14():
    cmd = "bin/run_ps2ff -w rjb tests/config/test_S14.ini"
    rc, so, se = get_command_output(cmd)
    r1 = pd.read_csv("tests/data/test_Rjb_S14_mechA_ar1p7_seis0_20_Ratios.csv",
                     header=6)
    v1 = pd.read_csv("tests/data/test_Rjb_S14_mechA_ar1p7_seis0_20_Var.csv",
                     header=6)
    r2 = pd.read_csv("TestData/Rjb_S14_mechA_ar1p7_seis0_20_Ratios.csv",
                     header=6)
    v2 = pd.read_csv("TestData/Rjb_S14_mechA_ar1p7_seis0_20_Var.csv", header=6)

    pd.util.testing.assert_frame_equal(r1, r2)
    pd.util.testing.assert_frame_equal(v1, v2)

    # Clean up
    shutil.rmtree('TestData')
Ejemplo n.º 2
0
def test_rjb_WC94_R_T():
    conf = 'fast_WC94_R_T.ini'
    cmd = "bin/run_ps2ff -w rjb tests/config/%s" % conf
    rc, so, se = get_command_output(cmd)
    r1 = pd.read_csv("tests/data/test_Rjb_WC94_mechR_LW_seis0_15_Ratios.csv",
                     header=6)
    v1 = pd.read_csv("tests/data/test_Rjb_WC94_mechR_LW_seis0_15_Var.csv",
                     header=6)
    r2 = pd.read_csv("TestData/Rjb_WC94_mechR_LW_seis0_15_Ratios.csv",
                     header=6)
    v2 = pd.read_csv("TestData/Rjb_WC94_mechR_LW_seis0_15_Var.csv", header=6)

    pd.util.testing.assert_frame_equal(r1, r2)
    pd.util.testing.assert_frame_equal(v1, v2)

    # Clean up
    shutil.rmtree('TestData')
Ejemplo n.º 3
0
def test_rrup_WC94():
    cmd = "bin/run_ps2ff -w rrup tests/config/test_2_WC94.ini"
    rc, so, se = get_command_output(cmd)
    r1 = pd.read_csv(
        "tests/data/test_Rrup_WC94_mechA_ar2p0_seis0_15_Ratios.csv", header=6)
    v1 = pd.read_csv("tests/data/test_Rrup_WC94_mechA_ar2p0_seis0_15_Var.csv",
                     header=6)
    r2 = pd.read_csv("TestData/Rrup_WC94_mechA_ar2p0_seis0_15_Ratios.csv",
                     header=6)
    v2 = pd.read_csv("TestData/Rrup_WC94_mechA_ar2p0_seis0_15_Var.csv",
                     header=6)

    pd.util.testing.assert_frame_equal(r1, r2)
    pd.util.testing.assert_frame_equal(v1, v2)

    # Clean up
    shutil.rmtree('TestData')
Ejemplo n.º 4
0
def test_rrup_Sea10_slab():
    conf = 'fast_Sea10_slab.ini'
    cmd = "bin/run_ps2ff -w rrup tests/config/%s" % conf
    rc, so, se = get_command_output(cmd)
    r1 = pd.read_csv(
        "tests/data/Rrup_Sea10_slab_mechA_ar1p0_seis0_15_Ratios.csv", header=6)
    v1 = pd.read_csv("tests/data/Rrup_Sea10_slab_mechA_ar1p0_seis0_15_Var.csv",
                     header=6)
    r2 = pd.read_csv(
        "TestData/Rrup_Sea10_slab_mechA_ar1p0_seis0_15_Ratios.csv", header=6)
    v2 = pd.read_csv("TestData/Rrup_Sea10_slab_mechA_ar1p0_seis0_15_Var.csv",
                     header=6)

    pd.util.testing.assert_frame_equal(r1, r2)
    pd.util.testing.assert_frame_equal(v1, v2)

    # Clean up
    shutil.rmtree('TestData')
Ejemplo n.º 5
0
def test_single_N1():
    cmd = "bin/run_ps2ff_single_event tests/config/test_single_N1.ini"
    rc, so, se = get_command_output(cmd)

    rjb1 = pd.read_csv("tests/data/Rjb_bytheta_Ratios_N1.csv", header=6)
    vjb1 = pd.read_csv("tests/data/Rjb_bytheta_Var_N1.csv", header=6)
    rjb2 = pd.read_csv("DataSingle/Rjb_bytheta_Ratios.csv", header=6)
    vjb2 = pd.read_csv("DataSingle/Rjb_bytheta_Var.csv", header=6)

    rrup1 = pd.read_csv("tests/data/Rrup_bytheta_Ratios_N1.csv", header=6)
    vrup1 = pd.read_csv("tests/data/Rrup_bytheta_Var_N1.csv", header=6)
    rrup2 = pd.read_csv("DataSingle/Rrup_bytheta_Ratios.csv", header=6)
    vrup2 = pd.read_csv("DataSingle/Rrup_bytheta_Var.csv", header=6)

    pd.util.testing.assert_frame_equal(rjb1, rjb2)
    pd.util.testing.assert_frame_equal(vjb1, vjb2)
    pd.util.testing.assert_frame_equal(rrup1, rrup2)
    pd.util.testing.assert_frame_equal(vrup1, vrup2)

    # Clean up
    shutil.rmtree('DataSingle')
Ejemplo n.º 6
0
def main(args):
    """
    Generate API docs.

    Args:
        args: Output of argparse. Currently only holds the verbose flag.

    Returns:
        Nothing. Function will exit upon success or failure.

    """
    # -------------------------------------------------------------
    # Some useful directories
    # -------------------------------------------------------------
    REPO_DIR = os.path.dirname(os.path.abspath(__file__))
    DOCS_DIR = os.path.join(REPO_DIR, 'docs')
    API_DIR = os.path.join(REPO_DIR, 'doc_source')
    PACKAGE_DIR = os.path.join(REPO_DIR, 'ps2ff')

    # -------------------------------------------------------------
    # what is the package called and who are the authors
    # -------------------------------------------------------------
    PACKAGE = "ps2ff"
    AUTHORS = 'Eric Thompson, Bruce Worden'
    verstr = '1.1'

    # -------------------------------------------------------------
    # run the api doc command; this creates the .rst files
    # -------------------------------------------------------------
    sys.stderr.write('Building ps2ff API documentation (REST)...\n')
    sphinx_cmd = 'sphinx-apidoc -o %s -f -e -l -M -d 12 -H %s -A "%s"'\
                 ' -V %s %s' % (API_DIR, PACKAGE, AUTHORS, verstr,
                                PACKAGE_DIR)
    res, stdout, stderr = get_command_output(sphinx_cmd)

    if not res:
        raise Exception('Could not build ps2ff API documentation'
                        ' - error "%s".' % stderr)

    if args.verbose:
        print(stdout.decode('utf-8'))
        print(stderr.decode('utf-8'))

    # --------------------------------------------
    # try to clean up some of the excess labeling
    # --------------------------------------------
    clean_cmd = "sed -i '' -e 's/ module//g' `find %s/*.rst -type f "\
                "-maxdepth 0 -print`" % API_DIR
    res, stdout, stderr = get_command_output(clean_cmd)
    clean_cmd = "sed -i '' -e 's/ package//g' `find %s/*.rst -type f "\
                "-maxdepth 0 -print`" % API_DIR
    res, stdout, stderr = get_command_output(clean_cmd)
    clean_cmd = "sed -i '' -e '/Subpackages/d' `find %s/*.rst -type f "\
                "-maxdepth 0 -print`" % API_DIR
    res, stdout, stderr = get_command_output(clean_cmd)
    clean_cmd = "sed -i '' -e '/-.*-/d' `find %s/*.rst -type f "\
                "-maxdepth 0 -print`" % API_DIR
    res, stdout, stderr = get_command_output(clean_cmd)

    # -------------------------------------------------------------
    # Build the html
    # -------------------------------------------------------------
    sys.stderr.write('Building ps2ff pages (HTML)...\n')
    res, stdout, stderr = get_command_output(
        'sphinx-build -a -E doc_source docs')
    if not res:
        raise Exception('Could not build HTML for API documentation. - '
                        'error "%s"' % stderr.decode())
    if args.verbose:
        print(stdout.decode('utf-8'))
        print(stderr.decode('utf-8'))

    pathlib.Path(os.path.join(DOCS_DIR, '.nojekyll')).touch(exist_ok=True)