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

Bug Report: #279

Closed
ckalbach opened this issue Oct 20, 2020 · 4 comments
Closed

Bug Report: #279

ckalbach opened this issue Oct 20, 2020 · 4 comments
Labels
bug Something isn't working released code merged into repo AND released to Pypi

Comments

@ckalbach
Copy link

ckalbach commented Oct 20, 2020

Describe the bug
When calling Subplots() method for Mpf_Figure() class, the for loop that sets the axes styles fails.

To Reproduce

fig = mplfinance.figure()
fig.subplots(nrows=2,ncols=1)

Error:
~\site-packages\mplfinance\_mplwraps.py in subplots(self, *args, **kwargs)
    110         self.mpfstyle = style
--> 111         if ax in axlist:
    112             ax.mpfstyle = style
    113         return fig, axlist
NameError: name 'ax' is not defined

Expected behavior
Should return a list of axes with ax.mpfstyle = style attribute

Correction
Change line 111 in _mplwraps.py from
if ax in axlist:
to:
for ax in axlist:

@ckalbach ckalbach added the bug Something isn't working label Oct 20, 2020
@DanielGoldfarb
Copy link
Collaborator

Thanks. Looks correct. Do you want to make the change and submit a PR ?

This is embarassing. Clearly i never tested Mpf_Figure.subplots() even once.

@DanielGoldfarb
Copy link
Collaborator

Hmm. I'm running some tests, and it appears the fix may not be as simple as

Change line 111 in _mplwraps.py from
if ax in axlist:
to:
for ax in axlist:

Definitely the if is wrong; but depending on the other arguments for may or may not fix the issue.
And there appears to be some other issues possibly as well. Will investigate further.
Still the offer stands, if you are interested in fixing this bug and submitting a PR, it will be greatly appreciated.

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Oct 21, 2020

The fix looks more like this:

if isinstance(axlist,mpl_axes.Axes):
    axlist.mpfstyle = style
elif isinstance(axlist,np.ndarray):
    for ax in axlist.flatten():
        ax.mpfstyle = style
else:
    raise TypeError('Unexpected type ('+str(type(axlist))+') '+
                    'returned from "matplotlib.figure.Figure.subplots()"')
return axlist

@DanielGoldfarb DanielGoldfarb added the merged / awaiting release to pypi code merged into repo, but not yet released to Pypi label Oct 21, 2020
@DanielGoldfarb
Copy link
Collaborator

#280

@DanielGoldfarb DanielGoldfarb added released code merged into repo AND released to Pypi and removed merged / awaiting release to pypi code merged into repo, but not yet released to Pypi labels Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released code merged into repo AND released to Pypi
Projects
None yet
Development

No branches or pull requests

2 participants