Skip to content

wrapper for gmt info #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Import modules to make the high-level GMT Python API
from .session_management import begin as _begin, end as _end
from .figure import Figure
from .modules import info


# Get the version number through versioneer
Expand Down
30 changes: 30 additions & 0 deletions gmt/modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Non-plot GMT modules.
"""

from .clib import LibGMT
from .utils import build_arg_string
from .decorators import fmt_docstring
from .utils import GMTTempFile


@fmt_docstring
def info(fname, **kwargs):
"""
Get information about data tables.

{gmt_module_docs}

Parameters
----------
fname : str
The file name of the input data table file.
"""
assert isinstance(fname, str), 'Only accepts file names.'

with GMTTempFile() as tmpfile:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F821 undefined name 'GMTTempFile'

arg_str = ' '.join([fname, build_arg_string(kwargs),
"->" + tmpfile.name])
with LibGMT() as lib:
lib.call_module('info', arg_str)
return tmpfile.read()
15 changes: 15 additions & 0 deletions gmt/tests/test_gmtinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
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'