

def test_arrayformat():
    ml = flopy.modflow.Modflow(model_ws=out_dir)
    u2d = Util2d(ml, (15, 2), np.float32, np.ones((15, 2)), 'test')
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())
    u2d.format.npl = 1
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())
    u2d.format.npl = 2
    u2d.format.width = 8
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())
    u2d.format.free = True
    u2d.format.width = 8
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())
    u2d.format.free = False
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())
    u2d.fmtin = '(10G15.6)'
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())
    u2d.format.binary = True
    fmt_fort = u2d.format.fortran
    cr = u2d.get_internal_cr()
    parsed = Util2d.parse_control_record(cr)
    print(fmt_fort, parsed['fmtin'])
    assert (fmt_fort.upper() == parsed['fmtin'].upper())

dataset/ETHPy150Open modflowpy/flopy/autotest/t004_test.py test_arrayformat/original