Skip to content

Commit

Permalink
switched to unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbauerma committed Nov 23, 2018
1 parent 2d6ad80 commit a336478
Show file tree
Hide file tree
Showing 2 changed files with 364 additions and 355 deletions.
56 changes: 29 additions & 27 deletions tests/test_copernicusgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,40 @@

'''
Tests for the CopernicusGrid class.
'''
import unittest

from equi7grid.copernicusgrid import CopernicusGrid

import numpy.testing as nptest


def test_ij2xy():
"""
Test xy to lonlat projection using double numbers.
"""
cg = CopernicusGrid(1.0 / 112)
lon_should = -150.2411
lat_should = 50.3214
globaltile = cg.GLOBAL.tilesys.create_tile()
lon, lat = globaltile.ij2xy(3333, 4444)
nptest.assert_allclose(lon_should, lon)
nptest.assert_allclose(lat_should, lat)


def test_xy2ij():
"""
Test xy to lonlat projection using double numbers.
"""
cg = CopernicusGrid(1.0 / 112)
column_should = 3333
row_should = 4444
globaltile = cg.GLOBAL.tilesys.create_tile()
column, row = globaltile.xy2ij(-150.2411, 50.3214)
nptest.assert_allclose(column_should, column)
nptest.assert_allclose(row_should, row)
class TestCopernicusGrid(unittest.TestCase):

def test_ij2xy(self):
"""
Test xy to lonlat projection using double numbers.
"""
cg = CopernicusGrid(1.0 / 112)
lon_should = -150.2411
lat_should = 50.3214
globaltile = cg.GLOBAL.tilesys.create_tile()
lon, lat = globaltile.ij2xy(3333, 4444)
nptest.assert_allclose(lon_should, lon)
nptest.assert_allclose(lat_should, lat)


def test_xy2ij(self):
"""
Test xy to lonlat projection using double numbers.
"""
cg = CopernicusGrid(1.0 / 112)
column_should = 3333
row_should = 4444
globaltile = cg.GLOBAL.tilesys.create_tile()
column, row = globaltile.xy2ij(-150.2411, 50.3214)
nptest.assert_allclose(column_should, column)
nptest.assert_allclose(row_should, row)

if __name__ == '__main__':
test_ij2xy()
test_xy2ij()
unittest.main()
Loading

0 comments on commit a336478

Please sign in to comment.