Skip to content

Commit e76e053

Browse files
committed
use get
1 parent 41ba524 commit e76e053

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lib/bald/tests/__init__.pyc

-15 Bytes
Binary file not shown.

lib/bald/validation.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,23 @@ def _check_ref(pdataset, parray, cdataset, carray):
154154
exceptions.append(ValueError(msg))
155155
return exceptions
156156

157-
for attr, value in self.subject.attrs.iteritems():
158-
# should support subtypes
159-
if attr == 'bald__references':
160-
# check if it's this type, otherwise exception)
161-
# if isinstance(value,
162-
child_dset = self.fhandle[value]
157+
# if this Dataset has a bald__references
158+
# not implemented yet: and it's a singleton
159+
if self.subject.attrs.get('bald__references', ''):
160+
# then it must have a bald_dataset
161+
ref_dset = self.fhandle[self.subject.attrs.get('bald__references')]
162+
if not ref_dset.attrs.get('bald__dataset', ''):
163+
exceptions.append(ValueError('A bald__Reference must reference'
164+
' one and only one bald__Dataset')
165+
)
166+
else:
167+
# and we impose bald broadcasting rules on it
168+
child_dset = self.fhandle[ref_dset.attrs.get('bald__dataset')]
163169
parray = np.zeros(self.dataset.shape)
164170
carray = np.zeros(child_dset.shape)
165171

166172
exceptions = _check_ref('p', parray, 'c', carray)
173+
167174
return exceptions
168175

169176

0 commit comments

Comments
 (0)