You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support passing a list of file names as input #2723
The main reason is that the data_kind function incorrectly returns a matrix type:
>>> from pygmt.helpers import data_kind
>>> data_kind(data=["@hotspots.txt", "@Table_5_11.txt"])
'matrix'
then we call the virtualfile_from_vectors to pass the data to the GMT API, which is expected to fail.
Then, the question is, if a list is passed to data, how do we know if it's a list of files or a valid record (e.g., data=[0, 1]).
To answer the question, we need to have a strict definition for "table files". As defined (based on my personal understanding) in #2722,
A table is a 2D array of data, with M rows and N columns. Each column
represents a different variable (e.g., x, y and z) and each row
represents a different record.
Under this definition, a table should always be a 2D array/list, even if it has only one row. Thus, data=[[0, 1]] is a valid table, and data=[0, 1] is not).
If we agree with the strict definition, then the solution is to check if data is 1-D or 2-D array. If 1-D, then it's a list of file names, otherwise, it's a 2-D table.
With this solution, it also means the issue report #1132 is no longer valid.
changed the title [-]Support passing a list of file names as input[/-][+]Support passing a list of file names as input via positional arguments[/+]on Oct 15, 2023
changed the title [-]Support passing a list of file names as input via positional arguments[/-][+]Support passing a list of file names as input[/+]on Oct 15, 2023
We already have some tests that pass a list of files to pygmt.which and Figure.text, so it should be find to say that passing a list of file names is supported.
Activity
[-]Support passing a list of file names as input[/-][+]Support passing a list of file names as input via positional arguments[/+][-]Support passing a list of file names as input via positional arguments[/-][+]Support passing a list of file names as input[/+]seisman commentedon Apr 9, 2024
I think the feature will be implemented in PR #3132. We need to:
seisman commentedon Apr 19, 2024
We already have some tests that pass a list of files to
pygmt.whichandFigure.text, so it should be find to say that passing a list of file names is supported.So we only need to improve the documentation.