Skip to content
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

Figure.ternary: Fix the crash for pd.DataFrame input with GMT 6.3-6.4 #2274

Merged
merged 1 commit into from
Dec 26, 2022
Merged
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
8 changes: 8 additions & 0 deletions pygmt/src/ternary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
ternary - Plot data on ternary diagrams.
"""
import pandas as pd
from packaging.version import Version
from pygmt.clib import Session
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias

Expand Down Expand Up @@ -79,6 +81,12 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs):
kwargs["L"] = "/".join([alabel, blabel, clabel])

with Session() as lib:
# Patch for GMT < 6.5.0.
# See https://github.com/GenericMappingTools/pygmt/pull/2138
if Version(lib.info["version"]) < Version("6.5.0") and isinstance(
data, pd.DataFrame
):
data = data.to_numpy()
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
with file_context as infile:
lib.call_module(
Expand Down