Skip to content

wrapper for gmt info - #106

Merged
leouieda merged 4 commits into
GenericMappingTools:masterfrom
gmt-china:gmtinfo
Feb 13, 2018
Merged

wrapper for gmt info#106
leouieda merged 4 commits into
GenericMappingTools:masterfrom
gmt-china:gmtinfo

Conversation

@seisman

Copy link
Copy Markdown
Member

Fix#43. Still work in progress. Any suggestions?

Comment threadgmt/__init__.py Outdated
# 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 *

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

F403 'from .modules import *' used; unable to detect undefined names

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please don't import *. It's better to explicitly import the functions that should be public.

Comment threadgmt/modules.py
from .utils import build_arg_string
from .decorators import fmt_docstring, use_alias, kwargs_to_strings

@fmt_docstring

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

@leouieda

Copy link
Copy Markdown
Member

@seisman mostly looks good to me. I have some minor comments that I'll leave inline.

Comment threadgmt/modules.py Outdated
Parameters
----------
data: str
A data file name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep it only for data files for now. We can think about adding pandas.Dataframe later but I don't know if it will be helpful.

In this case, fname is a better name for the argument. I'll probably refactor plot to use fname for files as well.

Comment threadgmt/modules.py Outdated
arg_str = ' '.join([data, build_arg_string(kwargs),
"->" + tmpfile.name])
with LibGMT() as lib:
lib.call_module('gmtinfo', arg_str)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think you need the "gmt" in the name.

Comment threadgmt/modules.py Outdated
"""
assert isinstance(fname, str), 'Only accepts file names.'

with GMTTempfile() as tmpfile:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

F821 undefined name 'GMTTempfile'

Comment threadgmt/modules.py
"""
assert isinstance(fname, str), 'Only accepts file names.'

with GMTTempFile() as tmpfile:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

F821 undefined name 'GMTTempFile'

@seisman

Copy link
Copy Markdown
MemberAuthor

Maybe I need to add more tests?


TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')

def test_gmtinfo():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

@leouieda

Copy link
Copy Markdown
Member

Maybe I need to add more tests?

@seisman yes please! I try to have as many configurations as possible tested. The one you have now looks good for the basic functionality.

Would you mind adding some more information to the docstring? You can copy some of the basic descriptions from the GMT docs. Not all options need to be included, just the most common ones. We can think of some aliases for them as well.

Do you think we should print the output instead of returning it? There could be a flag to trigger a return instead of printing. Either way, if the returned string is just a list of numbers, it would be better to return an array/list of the number instead.

@leouieda

Copy link
Copy Markdown
Member

@seisman I'm updating the branch and merging this as is. I'm working on #92 and I'll make the changes mentioned above.

Thanks for putting in all the work!

@leouieda
leouieda merged commit 95cd123 into GenericMappingTools:masterFeb 13, 2018
@seisman
seisman deleted the gmtinfo branch March 17, 2018 02:02
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@seisman@leouieda@stickler-ci