Skip to content

Api bar signature #9110

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

Merged
merged 7 commits into from
Aug 31, 2017
Merged

Api bar signature #9110

merged 7 commits into from
Aug 31, 2017

Conversation

tacaswell
Copy link
Member

@tacaswell tacaswell commented Aug 27, 2017

PR Summary

Adjusts the signature of bar and barh

closes #7954
closes #8327
closes #8527
closes #8882

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • Documentation is sphinx and numpydoc compliant
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

I'll add specific tests later tonight, but the existing test do a pretty good job of covering these changes.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Aug 27, 2017
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 27, 2017
"""
kwargs = cbook.normalize_kwargs(kwargs, mpatches._patch_alias_map)

matchers = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just

matchers = [
    lambda x, height, width=0.8, bottom=None, **kwargs:
        (False, x, height, width, bottom, kwargs),
    lambda left, height, width=0.8, bottom=None, **kwargs:
        (False, left, height, width, bottom, kwargs),
]

?

or did I miss a case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that is better 🐑


Make a bar plot with rectangles bounded by:

`left`, `left` + `width`, `bottom`, `bottom` + `height`
`x` - width/2, `x` + `width`/2, `bottom`, `bottom` + `height`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be changed to use double backquotes around each complete expression.


if "label" not in error_kw:
error_kw["label"] = '_nolegend_'

errorbar = self.errorbar(x, y,
errorbar = self.errorbar(ex, ey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just above (line 2183) can be switched to use setdefault.

barh(bottom, width, *, align='center', **kwargs)

despite behaving as the center in both cases. The methods now take ``*args, **kwargs``
is input and are documented to have the primary signatures of ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space before ::

else:
break
else:
raise TypeError("Missing two required positional arguments: 'x'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you save the first exception and just reraise it here? this will make the message correct in more cases (e.g. the user passes height as a kwarg but not x).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first one won't be right, it is the 4th one we want, but if you put the 4th one first it will hit and then we would have to handle the kwargs for the two optional ones seperatly (which might be better).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm

@tacaswell
Copy link
Member Author

I think I addressed all of @anntzer 's comments, tests are in-progress.

"color", "edgecolor", "linewidth",
"tick_label", "xerr", "yerr",
"ecolor"],
label_namer=None)
label_namer=None,
positional_parameter_names=['x',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? (I'ml not too familiar with the exact semantics of _preprocess_data, but at least y looks a bit fishy in the argument list here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 'y' is junk from a second rename that I ended up walking back. The purpose of this list is to tell the pre-processor the name of input hidden in the '*args' so it know which entries to try and look up in data, however in this case we want to do all of them so there is a simpler way.

# size width and bottom according to length of left
if _bottom is None:
# size width and y according to length of x
if _y is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just default bottom to 0 instead of None? (looks so, except possibly for log scale?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would have to keep this logic anyway as users can be passing None in explicitly. Inclined to let that stay as-is for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we at least make the change go before the call to np.broadcast_arrays, so that you don't have to call zeros_like below?
(I would also deprecate allowing passing None yada yada)

Change the documented first position argument to x and y for
bar and barh respectively but still support passing in left and bottom
as keyword arguments.

closes matplotlib#7954
closes matplotlib#8327
closes matplotlib#8527
closes matplotlib#8882
@anntzer
Copy link
Contributor

anntzer commented Aug 28, 2017

CI failing with some docstring markup.

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things, but otherwise it's a 👍 from me.


patches = self.bar(left=left, height=height, width=width,
bottom=bottom, orientation='horizontal', **kwargs)
matchers = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment explaining what the lambdas are for wouldn't hurt.

@efiring efiring merged commit 6c69f3e into matplotlib:master Aug 31, 2017
@tacaswell tacaswell deleted the api_bar_signature branch August 31, 2017 02:14
@anntzer anntzer mentioned this pull request Sep 10, 2017
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
4 participants