Skip to content

examples/misc/longshort.py is outdated #6866

Closed

Description

@anntzer

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).

Activity

  1. jenshnielsen commented on Jul 31, 2016

    @jenshnielsen
    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

  2. jenshnielsen commented on Jul 31, 2016

    @jenshnielsen
    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

  3. jenshnielsen commented on Jul 31, 2016

    @jenshnielsen
    Member

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

     np.dtype([(u'open', '<f8')])
    TypeError: data type not understood
    
  4. self-assigned this
    on Jul 31, 2016
  5. jenshnielsen commented on Aug 7, 2016

    @jenshnielsen
    Member

    Closed by #6868

  6. added this to the milestone on Aug 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions