From 8eae98df6b66e243b4aeea211b84d70a967cda37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=20van=20Merri=C3=ABnboer?= Date: Mon, 31 Jul 2017 14:24:32 -0400 Subject: [PATCH] Special case sequence space without elements to make tests pass --- autograd/container_types.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autograd/container_types.py b/autograd/container_types.py index 77ad5cc0..ab313286 100644 --- a/autograd/container_types.py +++ b/autograd/container_types.py @@ -66,7 +66,11 @@ def __init__(self, value): self.shape = [vspace(x) for x in value] self.size = sum(s.size for s in self.shape) self.sequence_type = type(value) - self.lib = vspace(value[0]).lib + if value: + # If this a list without elements, we'll just not set the + # library; there's a chance this space is nested and that + # this won't be needed. Otherwise it'll crash later + self.lib = vspace(value[0]).lib assert self.sequence_type in (tuple, list) def zeros(self):