Skip to content
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

Broken call to Rectangle constructor #1079

Closed
QuLogic opened this issue Aug 23, 2023 · 2 comments · Fixed by #1082
Closed

Broken call to Rectangle constructor #1079

QuLogic opened this issue Aug 23, 2023 · 2 comments · Fixed by #1082

Comments

@QuLogic
Copy link

QuLogic commented Aug 23, 2023

In Matplotlib 3.6, most arguments to patches were made keyword-only with a deprecation. Starting with Matplotlib 3.8.0rc1, this test fails as the deprecations have been removed:

___________________________ test_tree_diameter_real ____________________________

get_fig_2d = (<Figure size 640x480 with 1 Axes>, <Axes: >)

    def test_tree_diameter_real(get_fig_2d):
        m = load_morphology(SWC_PATH / 'simple-different-section-types.swc')
        fig, ax = get_fig_2d
        tree = m.neurites[0]
        for input_color, expected_colors in tree_colors.items():
>           matplotlib_impl.plot_tree(tree, ax, color=input_color, alpha=1., linewidth=1.2, realistic_diameters=True)

tests/view/test_matplotlib_impl.py:65: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-neurom-3.2.2-4.fc40.x86_64/usr/lib/python3.12/site-packages/neurom/view/matplotlib_impl.py:73: in wrapper
    res = plot_func(*args, **kwargs)
../../BUILDROOT/python-neurom-3.2.2-4.fc40.x86_64/usr/lib/python3.12/site-packages/neurom/view/matplotlib_impl.py:151: in plot_tree
    segs = [_get_rectangle((seg[0][plane0], seg[0][plane1]),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x = array([0., 0.]), y = array([0., 5.]), linewidth = 2.0

    def _get_rectangle(x, y, linewidth):
        """Draw  a rectangle to represent a secgment."""
        x, y = np.array(x), np.array(y)
        diff = y - x
        angle = np.arctan2(diff[1], diff[0]) % (2 * np.pi)
>       return Rectangle(x - linewidth / 2. * np.array([-np.sin(angle), np.cos(angle)]),
                         np.linalg.norm(diff),
                         linewidth,
                         np.rad2deg(angle))
E       TypeError: Rectangle.__init__() takes 4 positional arguments but 5 were given

../../BUILDROOT/python-neurom-3.2.2-4.fc40.x86_64/usr/lib/python3.12/site-packages/neurom/view/matplotlib_impl.py:146: TypeError
@mgeplf
Copy link
Collaborator

mgeplf commented Aug 24, 2023

Wow, thanks for the heads up.
We will have to look into the best way of handling this.

@QuLogic
Copy link
Author

QuLogic commented Aug 24, 2023

I believe passing it as angle=np.rad2deg(angle) should be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants