{"action":"created","issue":{"url":"https://api.github.com/repos/nilearn/nilearn/issues/457","labels_url":"https://api.github.com/repos/nilearn/nilearn/issues/457/labels{/name}","comments_url":"https://api.github.com/repos/nilearn/nilearn/issues/457/comments","events_url":"https://api.github.com/repos/nilearn/nilearn/issues/457/events","html_url":"https://github.com/nilearn/nilearn/issues/457","id":58623655,"number":457,"title":"Caching is disabled with default args","user":{"login":"bcipolli","id":4072455,"avatar_url":"https://avatars.githubusercontent.com/u/4072455?v=3","gravatar_id":"","url":"https://api.github.com/users/bcipolli","html_url":"https://github.com/bcipolli","followers_url":"https://api.github.com/users/bcipolli/followers","following_url":"https://api.github.com/users/bcipolli/following{/other_user}","gists_url":"https://api.github.com/users/bcipolli/gists{/gist_id}","starred_url":"https://api.github.com/users/bcipolli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcipolli/subscriptions","organizations_url":"https://api.github.com/users/bcipolli/orgs","repos_url":"https://api.github.com/users/bcipolli/repos","events_url":"https://api.github.com/users/bcipolli/events{/privacy}","received_events_url":"https://api.github.com/users/bcipolli/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-23T18:01:33Z","updated_at":"2015-02-23T22:14:06Z","closed_at":null,"body":"I expect a call to `cache` with default arguments to cache the result.  It does not.\r\n\r\nThe following code to cache does not cache:\r\n```python\r\nfrom nilearn._utils.cache_mixin import cache\r\n\r\ndef my_fun(X, Y)\r\n     return X + Y\r\nZ = cache(my_fun, memory='nilearn_cache')(1, 1)\r\n```\r\n\r\nInstead, the call must be:\r\n```python\r\nZ = cache(my_fun, memory='nilearn_cache', func_memory_level=1, memory_level=1)(1, 1)\r\n```\r\n\r\nI suggest tweaking the semantics of `func_memory_level`, such that if `func_memory_level is None`, everything gets cached.  Put it this way: if you call `cache` without specifying a `func_memory_level`, you always want it cached--rather, than *never* cached.\r\n\r\nAlternately, I would like the function to raise a warning if `func_memory_level is None`.  Since `func_memory_level is None` currently means the result will  *never* be cached, it shouldn't have been wrapped at all.. and so clearly the user's confused about the design, and we can warn them.\r\n\r\nI would be glad to submit a PR on this, but wanted to open things to discussion first."},"comment":{"url":"https://api.github.com/repos/nilearn/nilearn/issues/comments/75648778","html_url":"https://github.com/nilearn/nilearn/issues/457#issuecomment-75648778","issue_url":"https://api.github.com/repos/nilearn/nilearn/issues/457","id":75648778,"user":{"login":"AlexandreAbraham","id":1647301,"avatar_url":"https://avatars.githubusercontent.com/u/1647301?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexandreAbraham","html_url":"https://github.com/AlexandreAbraham","followers_url":"https://api.github.com/users/AlexandreAbraham/followers","following_url":"https://api.github.com/users/AlexandreAbraham/following{/other_user}","gists_url":"https://api.github.com/users/AlexandreAbraham/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexandreAbraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexandreAbraham/subscriptions","organizations_url":"https://api.github.com/users/AlexandreAbraham/orgs","repos_url":"https://api.github.com/users/AlexandreAbraham/repos","events_url":"https://api.github.com/users/AlexandreAbraham/events{/privacy}","received_events_url":"https://api.github.com/users/AlexandreAbraham/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T22:14:06Z","updated_at":"2015-02-23T22:14:06Z","body":"`cache` is hidden in the `_utils` package and thus should not be called directly by the user. But I get your point, you say that `func_memory_level` should not be optional since caching is triggered by `memory` and `memory_level`.\r\nOK, let's do it then ;)."}}