コード例 #1
0
ファイル: test_constructors.py プロジェクト: landlab/landlab
def test_hex_from_dict():
    params = {
        "base_num_rows": 5,
        "base_num_cols": 4,
        "dx": 2.0,
        "xy_of_lower_left": (35, 55),
        "axis_name": ("spam", "eggs"),
        "axis_units": ("smoot", "parsec"),
        "xy_of_reference": (12345, 678910),
    }

    mg = HexModelGrid.from_dict(params)

    # assert things.
    true_x_node = np.array(
        [
            37.0,
            39.0,
            41.0,
            43.0,
            36.0,
            38.0,
            40.0,
            42.0,
            44.0,
            35.0,
            37.0,
            39.0,
            41.0,
            43.0,
            45.0,
            36.0,
            38.0,
            40.0,
            42.0,
            44.0,
            37.0,
            39.0,
            41.0,
            43.0,
        ]
    )
    assert_array_equal(true_x_node, mg.x_of_node)
    assert (mg.x_of_node.min(), mg.y_of_node.min()) == (35, 55)
    assert mg.axis_units == ("smoot", "parsec")
    assert mg.axis_name == ("spam", "eggs")
    assert mg.xy_of_reference == (12345, 678910)
コード例 #2
0
def test_hex_from_dict():
    params = {
        "shape": (5, 4),
        "spacing": 2.0,
        "xy_of_lower_left": (35, 55),
        "xy_axis_name": ("spam", "eggs"),
        "xy_axis_units": ("smoot", "parsec"),
        "xy_of_reference": (12345, 678910),
    }

    mg = HexModelGrid.from_dict(params)

    # assert things.
    true_x_node = np.array(
        [
            37.0,
            39.0,
            41.0,
            43.0,
            36.0,
            38.0,
            40.0,
            42.0,
            44.0,
            35.0,
            37.0,
            39.0,
            41.0,
            43.0,
            45.0,
            36.0,
            38.0,
            40.0,
            42.0,
            44.0,
            37.0,
            39.0,
            41.0,
            43.0,
        ]
    )
    assert_array_equal(true_x_node, mg.x_of_node)
    assert (mg.x_of_node.min(), mg.y_of_node.min()) == (35, 55)
    assert mg.axis_units == ("smoot", "parsec")
    assert mg.axis_name == ("spam", "eggs")
    assert mg.xy_of_reference == (12345, 678910)
コード例 #3
0
ファイル: test_constructors.py プロジェクト: justync/landlab
def test_hex_from_dict():
    params = {
        "base_num_rows": 5,
        "base_num_cols": 4,
        "dx": 2.,
        "xy_of_lower_left": (35, 55),
        "axis_name": ("spam", "eggs"),
        "axis_units": ("smoot", "parsec"),
        "xy_of_reference": (12345, 678910),
    }

    mg = HexModelGrid.from_dict(params)

    # assert things.
    true_x_node = np.array([
        37.,
        39.,
        41.,
        43.,
        36.,
        38.,
        40.,
        42.,
        44.,
        35.,
        37.,
        39.,
        41.,
        43.,
        45.,
        36.,
        38.,
        40.,
        42.,
        44.,
        37.,
        39.,
        41.,
        43.,
    ])
    assert_array_equal(true_x_node, mg.x_of_node)
    assert (mg.x_of_node.min(), mg.y_of_node.min()) == (35, 55)
    assert mg.axis_units == ("smoot", "parsec")
    assert mg.axis_name == ("spam", "eggs")
    assert mg.xy_of_reference == (12345, 678910)