rossant / ipycache

Defines a %%cache cell magic in the IPython notebook to cache results of long-lasting computations in a persistent pickle file
BSD 3-Clause "New" or "Revised" License
138 stars 35 forks source link

Unbreak the tests on Python 3.3/3.4 #25

Closed ckald closed 9 years ago

ckald commented 9 years ago

Haven't tested in the wild so far

ihrke commented 9 years ago

Thanks! Could you rebase your PR to the current master branch rossant/ipycache?

ckald commented 9 years ago

Strange, I forked from master half an hour before submitting the PR

ihrke commented 9 years ago

Ok, I will take care of it

ckald commented 9 years ago

I'm going to test this soon on ipython3 with python 3 and 2 kernels

ihrke commented 9 years ago

unfortunately, some changes I made to enable instantaneous printing breaks python3 compatibility (something to do with StringIO). Don't have time to fix this so I'm going to remove the python3 builds again... sorry

ckald commented 9 years ago

Please be more specific. What's the problem with StringIO?

rossant commented 9 years ago

of any interest? https://pythonhosted.org/six/#six.StringIO

ihrke commented 9 years ago

It's ok, it was straightforward, after all. They renamed the buf argument in the StringIO constructor so just initializing with StringIO(self, buf) works fine. I fixed that along with the ipynb_runner.py script in a PR (rossant/ipycache#26) which I will soon merge.

One problem I see is that we will need to be careful with python3 compatibility even in the example notebooks (i.e., no careless using of print variable any longer :-( because the notebooks are also tested for each python version...

The six module looks fine but so far we don't really need it and should probably wait using it as a dependency?

rossant commented 9 years ago

What is typically done is that this six.py module is copied as is in the repository, so we don't have an extra dependency. In my experience it is quite convenient because you don't have to deal with py2/py3 compat issues yourself. Just use the functions and objects from this namespace and you're good.

print() should always be used instead of print because this works in both py2 and py3.

Ideally the notebooks should be tested in both py2 and py3. When IPython 3.0 is released in a few weeks, the nbformat will change and the notebooks may need to be updated. Also the new nbformat will include py2 or py3 in the notebook metadata. Maybe it would be worth having py2_notebooks and py3_notebooks folders or something.

ihrke commented 9 years ago

sounds good. Let's wait for IPython 3.0, then.

ckald commented 9 years ago

Additionally, "%"-formatting should be replaced by ".format()". I can't think of any other major adjustment

rossant commented 9 years ago

also dictionary iteration has changed https://pythonhosted.org/six/#six.iterkeys