pytoolz / pytoolz/toolz

strange bug using jupyter notebook

Open
#360 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
280
Avg merge
6d 17h
Merged PRs (30d)
4

Description

hey - no idea if this is a bug in toolz or in jupyter notebook, figured I would post here to help try to diagnose a pretty strange bug.

I'm using memoize as a decorator on a function that takes no arguments. I have used this approach many times in many contexts as a convenient local memory cache. The strange thing is, this raises an exception when I call the code from a jupyter notebook, but not from an ipython console and not in a stand-alone python script.

The exception I'm getting:

/home/jstrong/src/envs/vc/local/lib/python2.7/site-packages/toolz/functoolz.pyc in memof(*args, **kwargs)
    402             return cache[k]
    403         except TypeError:
--> 404             raise TypeError("Arguments to memoized function must be hashable")
    405         except KeyError:
    406             cache[k] = result = func(*args, **kwargs)

TypeError: Arguments to memoized function must be hashable

Does anything come to mind to explain how this bug could only arise when the code is called from a jupyter notebook?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

First reproduce the zero-argument memoize call in a Jupyter notebook, an IPython console, and a standalone Python script. Then inspect toolz/functoolz.pyc around the memoized-function path at line 404 and determine why the notebook context produces an unhashable key; done means the cause is identified and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.