dask / dask/cachey

BUG: ZeroDivisionError when returning zero-length series/arrays

Open
#19 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
142
Forks
21
PR merge metrics
No merged PRs in 30d

Description

Cachey produces an unhelpful div/zero error when a cached function returns a zero-length array.

Examples:
```python
from cachey import Cache
import numpy as np
import pandas as pd

cache = Cache(1e5)

@cache.memoize
def myfunc(x):
return x

try:
myfunc(pd.Series())
except ZeroDivisionError as m:
print(m)

try:
myfunc(np.array([]))
except ZeroDivisionError as m:
print(m)

myfunc([]) #lists work fine
```
```console

float division by zero
float division by zero

Out[39]:
[]
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the zero-length pandas Series and NumPy array examples through Cache.memoize, then trace the cache sizing or timing path invoked by those calls. Confirm that zero-length Series and arrays no longer raise ZeroDivisionError while the existing list example continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, pandas, python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.