Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Adding PowerScale for PowerNorm #20355 #20532

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
Loading
from

Conversation

yacth
Copy link

@yacth yacth commented Jun 27, 2021

PR Summary

As per the issue #20355 requirements, I added the PowerScale and PowerTransform and InvertedPowerTransform in the scale.py file following the architecture of the log norm.
I am willing to discuss the sef_default_locators_and_formatters function to set the right Locator and Formatter of the scale.

I am waiting for a review on my code and improve it if needed.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@dmatos2012
Copy link
Contributor

Hi @yacth. Thanks for contributing. As you can see, some of your tests are failing. To begin with, the test is complaining about formatting - clik on Linting/flake8 (pull_request) for more details. From the contributing documents it recommends to do the following to your code:

python -m pip install flake8
flake8 /path/to/module.py

which ensures formatting is done correctly. Secondly, its also complaining about needing tests for the added features, as per the website linked above:

Changes (both new features and bugfixes) should have good test coverage. See Testing for more details.
So what you have added needs to be covered by tests.

Its also important to make sure you run some tests before to make sure your changes are not breaking other features, see testing. For the implementation details, you will have to wait for some of the other developers to review it. But it greatly helps to make sure the previous tests passed, so the conversation can focus on implementation itself.

@yacth
Copy link
Author

yacth commented Jul 1, 2021

Hi @yacth. Thanks for contributing. As you can see, some of your tests are failing. To begin with, the test is complaining about formatting - clik on Linting/flake8 (pull_request) for more details. From the contributing documents it recommends to do the following to your code:

python -m pip install flake8
flake8 /path/to/module.py

which ensures formatting is done correctly. Secondly, its also complaining about needing tests for the added features, as per the website linked above:

Changes (both new features and bugfixes) should have good test coverage. See Testing for more details.
So what you have added needs to be covered by tests.

Its also important to make sure you run some tests before to make sure your changes are not breaking other features, see testing. For the implementation details, you will have to wait for some of the other developers to review it. But it greatly helps to make sure the previous tests passed, so the conversation can focus on implementation itself.

Thank you for your review.

Actually since it is rewritting the original feature in another way I thought that letting the old tests should be good enough.
What do you think about it ?

@jklymak
Copy link
Member

jklymak commented Jul 1, 2021

@yacth if the old tests fail then you changed the behaviour with your changes and the new code needs to be fixed, or you need to argue that the changes you made are an improvement and rewrite the tests.

@yacth
Copy link
Author

yacth commented Jul 6, 2021

I am working on the code, but I am stuck.
If someone can review what I have done and help me getting unblocked.

I am trying some testings using a simple code :

import matplotlib.scale as scale
scale.PowerScale(10, 0.5) 

I get the following error :

TypeError: __init__() takes 2 positional arguments but 3 were given

Which I don't understand.

lib/matplotlib/scale.py Outdated Show resolved Hide resolved
Copy link
Author

@yacth yacth left a comment

Choose a reason for hiding this comment

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

I did the changes to solve the errors related to the PowerNorm calculations even if there is still the set_default_locators_and_formatters in the PowerScale class is still to be determined.

I had this error:
lib/matplotlib/tests/test_axes.py::test_pcolor_regression

But by running what is inside line by line on my local environment I don't have a failure, I don't get it:

    from pandas.plotting import (
        register_matplotlib_converters,
        deregister_matplotlib_converters,
    )

    fig = plt.figure()
    ax = fig.add_subplot(111)

    times = [datetime.datetime(2021, 1, 1)]
    while len(times) < 7:
        times.append(times[-1] + datetime.timedelta(seconds=120))

    y_vals = np.arange(5)

    time_axis, y_axis = np.meshgrid(times, y_vals)
    shape = (len(y_vals) - 1, len(times) - 1)
    z_data = np.arange(shape[0] * shape[1])

    z_data.shape = shape
    try:
        register_matplotlib_converters()

        im = ax.pcolormesh(time_axis, y_axis, z_data)
        # make sure this does not raise!
        fig.canvas.draw()
    finally:
        deregister_matplotlib_converters()

@story645
Copy link
Member

But by running what is inside line by line on my local environment I don't have a failure, I don't get it:

this might be silly, but can you double check which version of matplotlib and which branch you're testing against?

@jklymak
Copy link
Member

jklymak commented Jul 20, 2021

@yacth, this is looking close. Suggest you rebase on master, that should fix your build error.

This does need tests and documentation as well if you are up for it. It is hard to tell if it is working without those.

@yacth
Copy link
Author

yacth commented Jul 21, 2021

@yacth, this is looking close. Suggest you rebase on master, that should fix your build error.

This does need tests and documentation as well if you are up for it. It is hard to tell if it is working without those.

I did a rebase, hope this will solve the failing tests.

Sure I will investigate the tests.

But first I have some questions about the locators and formatters for here I still have something to change, because I used "default" values .

@jklymak
Copy link
Member

jklymak commented Jul 21, 2021

@yacth I've not been following this PR closely. Did you spell out the locator/formatter issues? I can imagine they are a bit thorny as there is not a natural locator for the Power Scale. Perhaps best so see how it has been used in other contexts and copy.

@melissawm
Copy link
Member

Hi @yacth - are you interested in continuing this work? If so, please mark the PR as ready for review and let us know if you need help with the rebase, we have instructions for that here. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.