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
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.
The text was updated successfully, but these errors were encountered:
weiji14
changed the title
Support passing a list of file names as input
Support passing a list of file names as input via positional arguments
Oct 15, 2023
weiji14
changed the title
Support passing a list of file names as input via positional arguments
Support passing a list of file names as input
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.
When working on #2722, I realized most PyGMT functions/methods don't allow a list of file names as input. For example,
The main reason is that the
data_kind
function incorrectly returns amatrix
type: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,
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, anddata=[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.
The text was updated successfully, but these errors were encountered: