-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Labels
bugSomething isn't workingSomething isn't workingupstreamBug or missing feature of upstream core GMTBug or missing feature of upstream core GMT
Milestone
Description
Description of the problem
PR #480 mention that, x and y of the text()
function can accept int, float or str. It's true for PyGMT v0.1.2, but since PyGMT v0.2.0, it's no longer possible to pass string-type x or y.
I haven't looked into the codes to check why it works for v0.1.2. The question is, do we want to accept string-type x and y coordinates?
Full code that generated the error
import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 10], frame=True, projection='X10c')
fig.text(x='5.0', y=5, text='TEXT')
fig.show()
Full error message
Traceback (most recent call last):
File "/Users/seisman/Gits/gmt/pygmt/pygmt/clib/session.py", line 727, in _check_dtype_and_dim
array = np.asarray(array, dtype=np.datetime64)
File "/Users/seisman/.anaconda/lib/python3.8/site-packages/numpy/core/_asarray.py", line 85, in asarray
return array(a, dtype, copy=False, order=order)
ValueError: Error parsing datetime string "5.0" at position 1
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "test.py", line 6, in <module>
fig.text(x='5.0', y=5, text='TEXT')
File "/Users/seisman/Gits/gmt/pygmt/pygmt/helpers/decorators.py", line 270, in new_module
return module_func(*args, **kwargs)
File "/Users/seisman/Gits/gmt/pygmt/pygmt/helpers/decorators.py", line 407, in new_module
return module_func(*args, **kwargs)
File "/Users/seisman/Gits/gmt/pygmt/pygmt/base_plotting.py", line 1213, in text
with file_context as fname:
File "/Users/seisman/.anaconda/lib/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
File "/Users/seisman/Gits/gmt/pygmt/pygmt/clib/session.py", line 1173, in virtualfile_from_vectors
self.put_vector(dataset, column=col, vector=array)
File "/Users/seisman/Gits/gmt/pygmt/pygmt/clib/session.py", line 777, in put_vector
gmt_type = self._check_dtype_and_dim(vector, ndim=1)
File "/Users/seisman/Gits/gmt/pygmt/pygmt/clib/session.py", line 729, in _check_dtype_and_dim
raise GMTInvalidInput(
pygmt.exceptions.GMTInvalidInput: Unsupported numpy data type '<class 'numpy.str_'>'.
System information
Please paste the output of python -c "import pygmt; pygmt.show_versions()"
:
PyGMT information:
version: v0.2.0+16.g7bedf487
System information:
python: 3.8.3 (default, Jul 2 2020, 11:26:31) [Clang 10.0.0 ]
executable: /Users/seisman/.anaconda/bin/python
machine: macOS-10.15.6-x86_64-i386-64bit
Dependency information:
numpy: 1.18.5
pandas: 1.0.5
xarray: 0.16.1
netCDF4: 1.5.3
packaging: 20.4
ghostscript: 9.53.1
gmt: 6.2.0_3f85983_2020.09.26
GMT library information:
binary dir: /Users/seisman/.anaconda/bin
cores: 8
grid layout: rows
library path: /Users/seisman/local/GMT/lib/libgmt.dylib
padding: 2
plugin dir: /Users/seisman/local/GMT/lib/gmt/plugins
share dir: /Users/seisman/local/GMT/share
version: 6.2.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingupstreamBug or missing feature of upstream core GMTBug or missing feature of upstream core GMT