-
Notifications
You must be signed in to change notification settings - Fork 219
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.meca: Fix the bug when passing a dict of scalar values to the spec parameter #2174
Conversation
170600d
to
efde646
Compare
Ping @GenericMappingTools/pygmt-maintainers for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
pygmt/tests/test_meca.py
Outdated
# Right lateral strike slip focal mechanism | ||
fig.meca( | ||
spec=dict( | ||
strike=0, dip=90, rake=0, magnitude=5, longitude=0, latitude=5, depth=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested passing in the event_name
name as a string too? Want to see if np.at_least1d
handles it properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works, because np.atleast_1d("abc")
returns array(['abc'], dtype='<U3')
.
I've revised the test to also pass a scalar event_name
argument.
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
…rameter (GenericMappingTools#2174) Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Description of proposed changes
Minimal example:
Running the example above produces the following error messages:
The error is raised when we try to convert a dict with scalar values to pandas.DataFrame. So, here is the real minimal example to reproduce the issue:
The solution here is to convert dict's values to ndarray before the converison.
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version