Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for default value generates a KeyError if none is set #96

Open
vlsd opened this issue Feb 24, 2017 · 1 comment
Open

Checking for default value generates a KeyError if none is set #96

vlsd opened this issue Feb 24, 2017 · 1 comment

Comments

@vlsd
Copy link
Contributor

vlsd commented Feb 24, 2017

Consider the following:

ts = TimeSeries()
hasattr(ts, 'default')

it results in a KeyError. First, this is a bad behavior (bug) and should be fixed. Secondly, how should one properly check if a default is set or not? Maybe a has_default() method would be useful for this?

@stringertheory
Copy link
Owner

I think throwing the KeyError: "can't get value of empty TimeSeries with no default value" might be OK here. If you want to avoid the error, I'd recommend:

ts = TimeSeries()
if not ts.is_floating():
    print(ts.default)

is_floating is similar to something like has_no_default in that it only returns True if it's an empty TimeSeries with no default value specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants