Skip to content

Pass in NULL pointer to GMT_Get_Enum #224

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 14 commits into from
Aug 17, 2018

Conversation

akshmakov
Copy link
Contributor

Updated gmt.clib.Session.__getitem__ to reflect update GMT 6.0.0 API for for GMT_Get_Enum.
This update breaks compatability with trunk revisions prior to r20437. However,
a rudimentary check is done to try to indicate to the user. It can be removed
once GMT 6.0.0 is released.

Additionally, session handling has been added to __getitem__ to use the
session pointer if there is an open session.

Warning added to API documentation

Fixes #222

leouieda added 2 commits July 23, 2018 18:49
Black is Python 3.6 only so installing it through the requirements.txt
file was causing a silent upgrade of Python.
@welcome
Copy link

welcome bot commented Aug 7, 2018

💖 Thanks for opening this pull request! 💖

Please make sure you read our contributing guidelines and abide by our code of conduct.

A few things to keep in mind:

  • Remember to run make format to make sure your code follows our style guide.
  • If you need help writing tests, take a look at the existing ones for inspiration. If you don't know where to start, let us know and we'll walk you through it.
  • All new features should be documented. It helps to write the docstrings for your functions/classes before writing the code. This will help you think about your code design and results in better code.
  • No matter what, we are really grateful that you put in the effort to do this! 🎉

@@ -196,6 +196,11 @@ def __getitem__(self, name):

Used to set configuration values for other API calls. Wraps ``GMT_Get_Enum``.

.. warning::

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

@@ -196,6 +196,11 @@ def __getitem__(self, name):

Used to set configuration values for other API calls. Wraps ``GMT_Get_Enum``.

.. warning::

This call will fail with GMT 6.0.0 trunk revisions prior to r20437

Choose a reason for hiding this comment

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

W291 trailing whitespace

value = c_get_enum(name.encode())
# None type is valid for API purposes, so this is safe always
# Constants can be queried before session is created (chicken-or-egg)
# so we are not guaranteed a valid session pointer

Choose a reason for hiding this comment

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

W291 trailing whitespace

session = self.session_pointer
except GMTCLibNoSessionError:
session = None

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

padding = self["GMT_PAD_DEFAULT"]
session_type = self["GMT_SESSION_EXTERNAL"]
# While GMT 6.0.0 is in development, this check is necessary to
# prevent confusion with older development builds

Choose a reason for hiding this comment

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

W291 trailing whitespace

session_type = self["GMT_SESSION_EXTERNAL"]
except GMTCLibError as e:
raise GMTCLibError("Ensure GMT 6.0.0 is r20437 or later ") from e

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

session = c_create_session(name.encode(), padding, session_type, print_func)

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

@akshmakov
Copy link
Contributor Author

@leouieda I will resolve the White space issues, but please review this approach vs the dead simple one in c539b62

session = c_create_session(name.encode(), padding, session_type, print_func)

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

for `GMT_Get_Enum`. Resolves GenericMappingTools#222

This update breaks compatability with trunk revisions prior to r20437. However,
a rudimentary check is done to try to indicate to the user. It can be removed
once GMT 6.0.0 is released.

Additionally, session handling has been added to `__getitem__` to use the
session pointer if there is an open session.

Warning added to API documentation
@akshmakov akshmakov force-pushed the pr/get-enum-api#222 branch from 6f107b8 to f208f2e Compare August 7, 2018 06:55
@akshmakov akshmakov changed the title GMT_Get_Enum API Update in gmt.clib.Session.__getitem GMT_Get_Enum API Update in gmt.clib.Session.__getitem__ Aug 8, 2018
@akshmakov akshmakov mentioned this pull request Aug 9, 2018
We don't really need those. GMT6 is not released yet and we assume that
people have the latest version. We'll end up forgetting to remove these
checks later so it's best to not have them.
@leouieda leouieda changed the title GMT_Get_Enum API Update in gmt.clib.Session.__getitem__ Pass in NULL pointer to GMT_Get_Enum Aug 13, 2018
@leouieda
Copy link
Member

Hi @akshmakov, sorry for the huge delay in responding. I was busy trying to get GMT building on conda again so that we could run the CI.

This is great! Thanks for doing it! I went ahead and made a few changes to remove the try/except checks. We don't need those because GMT6 isn't out yet and we'll endup forgetting to remove them. As soon as the CI passes I'll merge this.

Thanks, I really appreciate it!

@leouieda
Copy link
Member

Closes #216 as well

@leouieda
Copy link
Member

OK, this seems to be a problem with the OSX conda package for GMT (again). I'm merging this the way it is so that we can move on. This has been a very frustrating month on conda-forge.

@leouieda leouieda merged commit 13bac6c into GenericMappingTools:master Aug 17, 2018
@welcome
Copy link

welcome bot commented Aug 17, 2018

🎉🎉🎉 Congrats on merging your first pull request and welcome to the team! 🎉🎉🎉

Please open a new pull request to add yourself to the AUTHORS.md file. We hope that this was a good experience for you. Let us know if there is any way that the contributing process could be improved.

Sign up for free to 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