def test_mutex_key(self):
        asc_file = StringIO(
            """
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
            """
        )
        header = read_asc_header(asc_file)
        self.assertEqual(header["xllcenter"], 1.0)
        with self.assertRaises(KeyError):
            header["xllcorner"]

        asc_file = StringIO(
            """
ncols         3
nrows         4
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
            """
        )
        header = read_asc_header(asc_file)
        self.assertEqual(header["xllcorner"], 1.0)
        with self.assertRaises(KeyError):
            header["xllcenter"]
    def test_mutex_key(self):
        asc_file = StringIO("""
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
            """)
        header = read_asc_header(asc_file)
        self.assertEqual(header['xllcenter'], 1.)
        with self.assertRaises(KeyError):
            header['xllcorner']

        asc_file = StringIO("""
ncols         3
nrows         4
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
            """)
        header = read_asc_header(asc_file)
        self.assertEqual(header['xllcorner'], 1.)
        with self.assertRaises(KeyError):
            header['xllcenter']
Beispiel #3
0
def test_header_mutex_key():
    asc_file = StringIO("""
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert header['xllcenter'] == 1.
    with pytest.raises(KeyError):
        header['xllcorner']

    asc_file = StringIO("""
ncols         3
nrows         4
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert header['xllcorner'] == 1.
    with pytest.raises(KeyError):
        header['xllcenter']
def test_header_mutex_key():
    asc_file = StringIO(
        """
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert header['xllcenter'] == 1.
    with pytest.raises(KeyError):
        header['xllcorner']

    asc_file = StringIO(
        """
ncols         3
nrows         4
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert header['xllcorner'] == 1.
    with pytest.raises(KeyError):
        header['xllcenter']
def test_header_mutex_key():
    asc_file = StringIO(
        """
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert_equal(header['xllcenter'], 1.)
    #with assert_raises(KeyError):
    #    header['xllcorner']
    assert_raises(KeyError, lambda k: header[k], 'xllcorner')

    asc_file = StringIO(
        """
ncols         3
nrows         4
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert_equal(header['xllcorner'], 1.)
    assert_raises(KeyError, lambda k: header[k], 'xllcenter')
def test_header_mutex_key():
    asc_file = StringIO("""
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert_equal(header['xllcenter'], 1.)
    #with assert_raises(KeyError):
    #    header['xllcorner']
    assert_raises(KeyError, lambda k: header[k], 'xllcorner')

    asc_file = StringIO("""
ncols         3
nrows         4
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    header = read_asc_header(asc_file)
    assert_equal(header['xllcorner'], 1.)
    assert_raises(KeyError, lambda k: header[k], 'xllcenter')
Beispiel #7
0
def test_header_missing_mutex_key():
    asc_file = StringIO("""
ncols         3
nrows         4
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    with pytest.raises(MissingRequiredKeyError):
        read_asc_header(asc_file)
Beispiel #8
0
def test_header_wrong_type():
    asc_file = StringIO("""
nCoLs         3.5
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
        """)
    with pytest.raises(KeyTypeError):
        read_asc_header(asc_file)
Beispiel #9
0
def test_header_bad_values():
    asc_file = StringIO("""
nrows         -4
ncols         3
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    with pytest.raises(KeyValueError):
        read_asc_header(asc_file)
def test_header_missing_mutex_key():
    asc_file = StringIO(
        """
ncols         3
nrows         4
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    with pytest.raises(MissingRequiredKeyError):
        read_asc_header(asc_file)
Beispiel #11
0
def test_header_missing_value():
    asc_file = StringIO("""
nrows         4
ncols         3
xllcorner     1.
yllcorner     2.
cellsize
NODATA_value  -9999
invalid_key   1
        """)
    with pytest.raises(BadHeaderLineError):
        read_asc_header(asc_file)
def test_header_wrong_type():
    asc_file = StringIO(
        """
nCoLs         3.5
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
        """)
    with pytest.raises(KeyTypeError):
        read_asc_header(asc_file)
def test_header_bad_values():
    asc_file = StringIO(
        """
nrows         -4
ncols         3
xllcorner     1.
yllcorner     2.
cellsize      10.
NODATA_value  -9999
        """)
    with pytest.raises(KeyValueError):
        read_asc_header(asc_file)
def test_header_missing_value():
    asc_file = StringIO(
        """
nrows         4
ncols         3
xllcorner     1.
yllcorner     2.
cellsize
NODATA_value  -9999
invalid_key   1
        """)
    with pytest.raises(BadHeaderLineError):
        read_asc_header(asc_file)
def test_header_missing_optional():
    asc_file = StringIO("""
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
        """)
    header = read_asc_header(asc_file)
    assert_raises(KeyError, lambda k: header[k], 'nodata_value')
    def test_missing_mutex_key(self):
        asc_file = StringIO("""
ncols         3
nrows         4
yllcorner     2.
cellsize      10.
NODATA_value  -9999
            """)
        with self.assertRaises(MissingRequiredKeyError):
            header = read_asc_header(asc_file)
def test_header_missing_optional():
    asc_file = StringIO(
        """
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
        """)
    header = read_asc_header(asc_file)
    assert_raises(KeyError, lambda k: header[k], 'nodata_value')
    def test_wrong_type(self):
        asc_file = StringIO("""
nCoLs         3.5
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
            """)
        with self.assertRaises(KeyTypeError):
            header = read_asc_header(asc_file)
    def test_missing_optional(self):
        asc_file = StringIO("""
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
            """)
        header = read_asc_header(asc_file)
        with self.assertRaises(KeyError):
            header['nodata_value']
Beispiel #20
0
def test_header_missing_optional():
    asc_file = StringIO("""
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
        """)
    header = read_asc_header(asc_file)
    with pytest.raises(KeyError):
        header["nodata_value"]
    def test_missing_mutex_key(self):
        asc_file = StringIO(
            """
ncols         3
nrows         4
yllcorner     2.
cellsize      10.
NODATA_value  -9999
            """
        )
        with self.assertRaises(MissingRequiredKeyError):
            header = read_asc_header(asc_file)
def test_header_missing_optional():
    asc_file = StringIO(
        """
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
        """)
    header = read_asc_header(asc_file)
    with pytest.raises(KeyError):
        header['nodata_value']
    def test_missing_optional(self):
        asc_file = StringIO(
            """
ncols         3
nrows         4
xllcenter     1.
yllcorner     2.
cellsize      10.
            """
        )
        header = read_asc_header(asc_file)
        with self.assertRaises(KeyError):
            header["nodata_value"]
    def test_wrong_type(self):
        asc_file = StringIO(
            """
nCoLs         3.5
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
            """
        )
        with self.assertRaises(KeyTypeError):
            header = read_asc_header(asc_file)
def test_header_case_insensitive():
    asc_file = StringIO(
        """
nCoLs         3
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
        """)
    header = read_asc_header(asc_file)
    for key in ['ncols', 'nrows', 'xllcenter', 'yllcorner', 'cellsize',
                'nodata_value']:
        assert_true(key in header)
def test_header_case_insensitive():
    asc_file = StringIO(
        """
nCoLs         3
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
        """
    )
    header = read_asc_header(asc_file)
    for key in ["ncols", "nrows", "xllcenter", "yllcorner", "cellsize", "nodata_value"]:
        assert key in header
def test_header_case_insensitive():
    asc_file = StringIO(
        """
nCoLs         3
nrows         4
Xllcenter     1.
YLLCORNER     2.
CELLSIZE      10.
NODATA_value  -999
        """)
    header = read_asc_header(asc_file)
    for key in ['ncols', 'nrows', 'xllcenter', 'yllcorner', 'cellsize',
                'nodata_value']:
        assert_true(key in header)