diff --git a/gmt/modules.py b/gmt/modules.py index 7f48a50528f..a57525ecff8 100644 --- a/gmt/modules.py +++ b/gmt/modules.py @@ -10,12 +10,32 @@ def info(fname, **kwargs): """ Get information about data tables. + Reads from files and finds the extreme values in each of the columns. + It recognizes NaNs and will print warnings if the number of columns vary + from record to record. As an option, it will find the extent of the first + n columns rounded up and down to the nearest multiple of the supplied + increments. By default, this output will be in the form *-Rw/e/s/n*, + or the output will be in column form for as many columns as there are + increments provided. The *T* option will provide a *-Tzmin/zmax/dz* string + for makecpt. + {gmt_module_docs} Parameters ---------- fname : str The file name of the input data table file. + C : bool + Report the min/max values per column in separate columns. + I : str + ``'[b|p|f|s]dx[/dy[/dz...]]'``. + Report the min/max of the first n columns to the nearest multiple of + the provided increments and output results in the form *-Rw/e/s/n* + (unless *C* is set). + T : str + ``'dz[+ccol]'`` + Report the min/max of the first (0'th) column to the nearest multiple + of dz and output this as the string *-Tzmin/zmax/dz*. """ assert isinstance(fname, str), 'Only accepts file names.' diff --git a/gmt/tests/test_gmtinfo.py b/gmt/tests/test_gmtinfo.py deleted file mode 100644 index 276cf2d3a93..00000000000 --- a/gmt/tests/test_gmtinfo.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Tests for gmtinfo -""" -import os - -from .. import info - -TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') - - -def test_gmtinfo(): - "Test gmtinfo" - data_fname = os.path.join(TEST_DATA_DIR, 'points.txt') - output = info(fname=data_fname, C=True) - assert output == '11.5309 61.7074 -2.9289 7.8648 0.1412 0.9338\n' diff --git a/gmt/tests/test_info.py b/gmt/tests/test_info.py new file mode 100644 index 00000000000..3139250197a --- /dev/null +++ b/gmt/tests/test_info.py @@ -0,0 +1,44 @@ +""" +Tests for gmtinfo +""" +import os + +from .. import info + +TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') +POINTS_DATA = os.path.join(TEST_DATA_DIR, 'points.txt') + + +def test_info(): + "Make sure info works" + output = info(fname=POINTS_DATA) + expected_output = ('{}: N = 20 ' + '<11.5309/61.7074> ' + '<-2.9289/7.8648> ' + '<0.1412/0.9338>\n').format(POINTS_DATA) + + assert output == expected_output + + +def test_info_c(): + "Make sure the C option works" + output = info(fname=POINTS_DATA, C=True) + assert output == '11.5309 61.7074 -2.9289 7.8648 0.1412 0.9338\n' + + +def test_info_i(): + "Make sure the I option works" + output = info(fname=POINTS_DATA, I=0.1) + assert output == '-R11.5/61.8/-3/7.9\n' + + +def test_info_c_i(): + "Make sure the C and I options work together" + output = info(fname=POINTS_DATA, C=True, I=0.1) + assert output == '11.5 61.8 -3 7.9 0.1412 0.9338\n' + + +def test_info_t(): + "Make sure the T option works" + output = info(fname=POINTS_DATA, T=0.1) + assert output == '-T11.5/61.8/0.1\n'