Thanks to visit codestin.com
Credit goes to github.com

Skip to content

examples/misc/longshort.py is outdated #6866

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

Closed
anntzer opened this issue Jul 31, 2016 · 4 comments
Closed

examples/misc/longshort.py is outdated #6866

anntzer opened this issue Jul 31, 2016 · 4 comments
Assignees
Labels
Documentation MEP: MEP12 gallery and examples improvements
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Jul 31, 2016

As of master / numpy 1.11:

$ python2 examples/misc/longshort.py
Traceback (most recent call last):
  File "examples/misc/longshort.py", line 24, in <module>
    r1 = mlab.rec_append_fields(r1, 'gains', gains1)
  File "/home/antony/src/extern/matplotlib/lib/matplotlib/mlab.py", line 2389, in rec_append_fields
    newdtype = np.dtype(rec.dtype.descr + list(zip(names, dtypes)))
TypeError: data type not understood

$ python3 examples/misc/longshort.py
Traceback (most recent call last):
  File "examples/misc/longshort.py", line 12, in <module>
    u1 = urllib.urlretrieve('http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv')
AttributeError: module 'urllib' has no attribute 'urlretrieve'

Basically mlab.rec_append_fields has some unicode/bytes issues on Py2 and the imports need to be renamed on Py3 (I guess).

@jenshnielsen
Copy link
Member

I think that example should probably just be deleted? In most cases I would use Pandas for this today.

The other issue is that the misc examples are not executed as part of the docs build. That should probably be changed so we ensure that they remain functional

@jenshnielsen jenshnielsen added Documentation MEP: MEP12 gallery and examples improvements labels Jul 31, 2016
@jenshnielsen
Copy link
Member

I started working on this in https://github.com/jenshnielsen/matplotlib/tree/buildmiscexamples

It looks like both the join example and this one is broken for more or less the same reason

@jenshnielsen
Copy link
Member

The Python2 issue is caused by numpy.dtype not liking unicode strings

 np.dtype([(u'open', '<f8')])
TypeError: data type not understood

@jenshnielsen
Copy link
Member

Closed by #6868

@QuLogic QuLogic added this to the 2.0 (style change major release) milestone Aug 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation MEP: MEP12 gallery and examples improvements
Projects
None yet
Development

No branches or pull requests

3 participants