-
Notifications
You must be signed in to change notification settings - Fork 229
Figure.meca: Fix beachball offsetting with dict/pandas inputs #2202
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,11 +189,11 @@ def meca( | |
Depth(s) of event location in kilometers. Must be the same length as | ||
the number of events. Will override the ``depth`` values in ``spec`` | ||
if ``spec`` is a dict or pd.DataFrame. | ||
plot_longitude: int, float, list, or 1d numpy array | ||
plot_longitude: int, float, str, list, or 1d numpy array | ||
Longitude(s) at which to place beachball. Must be the same length as | ||
the number of events. Will override the ``plot_longitude`` values in | ||
``spec`` if ``spec`` is a dict or pd.DataFrame. | ||
plot_latitude: int, float, list, or 1d numpy array | ||
plot_latitude: int, float, str, list, or 1d numpy array | ||
Latitude(s) at which to place beachball. List must be the same length | ||
as the number of events. Will override the ``plot_latitude`` values in | ||
``spec`` if ``spec`` is a dict or pd.DataFrame. | ||
|
@@ -272,10 +272,10 @@ def meca( | |
spec["latitude"] = np.atleast_1d(latitude) | ||
if depth is not None: | ||
spec["depth"] = np.atleast_1d(depth) | ||
if plot_longitude is not None: # must be in string type | ||
spec["plot_longitude"] = np.atleast_1d(plot_longitude).astype(str) | ||
if plot_latitude is not None: # must be in string type | ||
spec["plot_latitude"] = np.atleast_1d(plot_latitude).astype(str) | ||
if plot_longitude is not None: | ||
spec["plot_longitude"] = np.atleast_1d(plot_longitude) | ||
if plot_latitude is not None: | ||
spec["plot_latitude"] = np.atleast_1d(plot_latitude) | ||
if event_name is not None: | ||
spec["event_name"] = np.atleast_1d(event_name).astype(str) | ||
|
||
|
@@ -293,9 +293,13 @@ def meca( | |
newcols = ["longitude", "latitude", "depth"] + param_conventions[convention] | ||
if "plot_longitude" in spec.columns and "plot_latitude" in spec.columns: | ||
newcols += ["plot_longitude", "plot_latitude"] | ||
spec[["plot_longitude", "plot_latitude"]] = spec[ | ||
["plot_longitude", "plot_latitude"] | ||
].astype(str) | ||
kwargs["A"] = True | ||
if "event_name" in spec.columns: | ||
newcols += ["event_name"] | ||
spec["event_name"] = spec["event_name"].astype(str) | ||
# reorder columns in DataFrame | ||
spec = spec.reindex(newcols, axis=1) | ||
elif isinstance(spec, np.ndarray) and spec.ndim == 1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I was re-reading #1129 again and was gonna say, it's a little surprising that a 2D numpy array passed in with Nothing to do here, just a random comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a good point. I think it shouldn't work. The I'll find some time and see if offsetting using a 2D numpy array works, and if not, will try to find a fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, so we should probably update the test to use a non-zero offset. I actually wanted to parse all the user inputs into a If this ends up getting too complicated, we can merge in this PR first to fix offsets for dict/pandas inputs, and have a separate one to handle offsets for 2D numpy array inputs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I prefer to work on it in a separate PR. |
||
|
Uh oh!
There was an error while loading. Please reload this page.