Skip to content

BUG: ZeroDivisionError when returning zero-length series/arrays #19

@asher-pembroke

Description

@asher-pembroke

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

Examples:

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
float division by zero
float division by zero

Out[39]:
[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions