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
Check load_trace argument #3534
Conversation
@ColCarroll One piece of advice I could use is what |
74f0cce
to
783c4a7
Compare
I suppose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good -- one nitpick, plus I agree that ValueError
or a custom error (that inherits from ValueError
) is a better idea.
pymc3/backends/ndarray.py
Outdated
for subdir in glob.glob(os.path.join(directory, '*')): | ||
if os.path.isdir(subdir): | ||
straces.append(SerializeNDArray(subdir).load(model)) | ||
if straces == []: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be if len(straces) == 0
(or if not straces
), since testing list equality is dangerous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Everything should be in place now. ISTR getting a pylint complaint about checking length as a way to check for an empty list, so I went for if not straces
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I hate that warning!
Add new exception class. While doing this, added type annotations to ndarray.py
783c4a7
to
bf05b41
Compare
@@ -7,3 +7,7 @@ class SamplingError(RuntimeError): | |||
|
|||
class IncorrectArgumentsError(ValueError): | |||
pass | |||
|
|||
class TraceDirectoryError(ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. i did not know this file existed!
I'll merge once tests pass -- thanks! |
pymc3/backends/ndarray.py
Outdated
@@ -204,7 +215,7 @@ def setup(self, draws, chain, sampler_vars=None): | |||
if self._stats is None: | |||
self._stats = [] | |||
for sampler in sampler_vars: | |||
data = dict() | |||
data: Dict[str, np.ndarray] = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this line is too current for python 3.5...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, crumbs. I keep forgetting. I'll replace that with the corresponding type comment. My bad.
This commit should be squashed before merging...
Still needs a test. But comments welcome.