Skip to content

Commit 5a47933

Browse files
committed
test fixes
1 parent b785a0f commit 5a47933

File tree

7 files changed

+56
-38
lines changed

7 files changed

+56
-38
lines changed

lib/bald/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ def load_netcdf(afilepath, uri=None):
623623
rattrs['bald__childBroadcast'] = tuple(reshape)
624624
rattrs['bald__array'] = set((file_variables.get(dim),))
625625
ref_node = Subject(identity, rattrs, prefixes=prefixes, aliases=aliases)
626+
root_container.attrs['bald__contains'].append(ref_node)
627+
file_variables[name] = ref_node
626628
refset.add(ref_node)
627629
var.attrs['bald__references'] = refset
628630

lib/bald/tests/integration/HTML/multi_array_reference.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@
180180
var pdim1 = instance('pdim1:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>, <a xlink:href="http://binary-array-ld.net/latest/Reference" xlink:show=new text-decoration="underline">bald__Reference</a>', ['<a xlink:href="http://binary-array-ld.net/latest/array" xlink:show=new text-decoration="underline">bald__array</a>: |', '<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 17'], '#878800');
181181
var root = instance('root:<a xlink:href="http://binary-array-ld.net/latest/Container" xlink:show=new text-decoration="underline">bald__Container</a>', ['<a xlink:href="http://binary-array-ld.net/latest/contains" xlink:show=new text-decoration="underline">bald__contains</a>: |'], '#878800');
182182
var variable1 = instance('variable1:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |', 'long_name: Gerald', 'obtype: <a xlink:href="http://codes.wmo.int/common/observation-type/METCE/2013/SamplingObservation" xlink:show=new text-decoration="underline">metce__SamplingObservation</a>', '<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 11, 17'], '#878800');
183+
var variable1_pdim0_ref = instance('variable1_pdim0_ref:<a xlink:href="http://binary-array-ld.net/latest/Reference" xlink:show=new text-decoration="underline">bald__Reference</a>, <a xlink:href="http://binary-array-ld.net/latest/Subject" xlink:show=new text-decoration="underline">bald__Subject</a>', ['<a xlink:href="http://binary-array-ld.net/latest/childBroadcast" xlink:show=new text-decoration="underline">bald__childBroadcast</a>: 1, 11', '<a xlink:href="http://binary-array-ld.net/latest/array" xlink:show=new text-decoration="underline">bald__array</a>: |'], '#878800');
183184
var variable2 = instance('variable2:<a xlink:href="http://binary-array-ld.net/latest/Array" xlink:show=new text-decoration="underline">bald__Array</a>', ['<a xlink:href="http://binary-array-ld.net/latest/references" xlink:show=new text-decoration="underline">bald__references</a>: |', 'long_name: Imelda', 'obtype: <a xlink:href="http://codes.wmo.int/common/observation-type/METCE/2013/SamplingObservation" xlink:show=new text-decoration="underline">metce__SamplingObservation</a>', '<a xlink:href="http://binary-array-ld.net/latest/shape" xlink:show=new text-decoration="underline">bald__shape</a>: 11, 17'], '#878800');
185+
var variable2_pdim0_ref = instance('variable2_pdim0_ref:<a xlink:href="http://binary-array-ld.net/latest/Reference" xlink:show=new text-decoration="underline">bald__Reference</a>, <a xlink:href="http://binary-array-ld.net/latest/Subject" xlink:show=new text-decoration="underline">bald__Subject</a>', ['<a xlink:href="http://binary-array-ld.net/latest/childBroadcast" xlink:show=new text-decoration="underline">bald__childBroadcast</a>: 1, 11', '<a xlink:href="http://binary-array-ld.net/latest/array" xlink:show=new text-decoration="underline">bald__array</a>: |'], '#878800');
184186
link(location_variable, location_reference_system, 'bald__references');
185187
link(location_variable, location_variable, 'bald__array', 'bottom');
186188
link(pdim0, pdim0, 'bald__array', 'bottom');
@@ -190,13 +192,15 @@
190192
link(root, pdim0, 'bald__contains', 'top', true);
191193
link(root, pdim1, 'bald__contains', 'top', true);
192194
link(root, variable1, 'bald__contains', 'top', true);
195+
link(root, variable1_pdim0_ref, 'bald__contains', 'top', true);
193196
link(root, variable2, 'bald__contains', 'top', true);
197+
link(root, variable2_pdim0_ref, 'bald__contains', 'top', true);
194198
link(variable1, location_variable, 'bald__references');
195-
link(variable1, pdim0, 'bald__references');
196199
link(variable1, pdim1, 'bald__references');
200+
link(variable1, variable1_pdim0_ref, 'bald__references');
197201
link(variable2, location_variable, 'bald__references');
198-
link(variable2, pdim0, 'bald__references');
199202
link(variable2, pdim1, 'bald__references');
203+
link(variable2, variable2_pdim0_ref, 'bald__references');
200204
joint.layout.DirectedGraph.layout(graph, { setLinkVertices: false,
201205
nodeSep: 150, rankSep: 100,
202206
marginX: 100, marginY: 100,

lib/bald/tests/integration/TTL/multi_array_reference.ttl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,37 @@
1010
<pdim0>,
1111
<pdim1>,
1212
<variable1>,
13-
<variable2> ;
13+
<variable1_pdim0_ref>,
14+
<variable2>,
15+
<variable2_pdim0_ref> ;
1416
bald:isPrefixedBy "prefix_list" .
1517

1618
<variable1> a bald:Array ;
1719
bald:references <location_variable>,
18-
<pdim0>,
19-
<pdim1> ;
20+
<pdim1>,
21+
<variable1_pdim0_ref> ;
2022
bald:shape "(11, 17)" ;
2123
<long_name> "Gerald" ;
2224
<obtype> <http://codes.wmo.int/common/observation-type/METCE/2013/SamplingObservation> .
2325

2426
<variable2> a bald:Array ;
2527
bald:references <location_variable>,
26-
<pdim0>,
27-
<pdim1> ;
28+
<pdim1>,
29+
<variable2_pdim0_ref> ;
2830
bald:shape "(11, 17)" ;
2931
<long_name> "Imelda" ;
3032
<obtype> <http://codes.wmo.int/common/observation-type/METCE/2013/SamplingObservation> .
3133

34+
<variable1_pdim0_ref> a bald:Reference,
35+
bald:Subject ;
36+
bald:array <pdim0> ;
37+
bald:childBroadcast "(11, 1)" .
38+
39+
<variable2_pdim0_ref> a bald:Reference,
40+
bald:Subject ;
41+
bald:array <pdim0> ;
42+
bald:childBroadcast "(11, 1)" .
43+
3244
<location_reference_system> a bald:Subject ;
3345
bald:array <location_reference_system> ;
3446
<pcode> "4897" .

lib/bald/tests/integration/test_netcdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_mismatch_zeroth(self):
7676
f.close()
7777
validation = bald.validate_netcdf(tfile)
7878
exns = validation.exceptions()
79-
expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules']
79+
expected = ['parent_variable declares a child of child_variable but the arrays do not conform to the bald array reference rules']
8080
self.assertTrue((not validation.is_valid()) and exns == expected,
8181
msg='{} != {}'.format(exns, expected))
8282

lib/bald/tests/integration/test_netcdf4_classic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_mismatch_zeroth(self):
7575
f.close()
7676
validation = bald.validate_netcdf(tfile)
7777
exns = validation.exceptions()
78-
expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules']
78+
expected = ['parent_variable declares a child of child_variable but the arrays do not conform to the bald array reference rules']
7979
self.assertTrue((not validation.is_valid()) and exns == expected,
8080
msg='{} != {}'.format(exns, expected))
8181

lib/bald/tests/integration/test_validation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_mismatch_zeroth(self):
7070
f.close()
7171
validation = bald.validate_hdf5(tfile)
7272
exns = validation.exceptions()
73-
expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules']
73+
expected = ['parent_dataset declares a child of child_dataset but the arrays do not conform to the bald array reference rules']
7474
self.assertTrue((not validation.is_valid()) and exns == expected,
7575
msg='{} != {}'.format(exns, expected))
7676

@@ -82,7 +82,7 @@ def test_mismatch_oneth(self):
8282
f.close()
8383
validation = bald.validate_hdf5(tfile)
8484
exns = validation.exceptions()
85-
expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules']
85+
expected = ['parent_dataset declares a child of child_dataset but the arrays do not conform to the bald array reference rules']
8686
self.assertTrue((not validation.is_valid()) and exns == expected,
8787
msg='{} != {}'.format(exns, expected))
8888

@@ -118,7 +118,7 @@ def test_mismatch_pdisjc_lead_dim(self):
118118
f.close()
119119
validation = bald.validate_hdf5(tfile)
120120
exns = validation.exceptions()
121-
expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules']
121+
expected = ['parent_dataset declares a child of child_dataset but the arrays do not conform to the bald array reference rules']
122122
self.assertTrue((not validation.is_valid()) and exns == expected,
123123
msg='{} != {}'.format(exns, expected))
124124

@@ -131,7 +131,7 @@ def test_mismatch_pdisjc_trail_dim(self):
131131
f.close()
132132
validation = bald.validate_hdf5(tfile)
133133
exns = validation.exceptions()
134-
expected = ['p declares a child of c but the arrays do not conform to the bald array reference rules']
134+
expected = ['parent_dataset declares a child of child_dataset but the arrays do not conform to the bald array reference rules']
135135
self.assertTrue((not validation.is_valid()) and exns == expected,
136136
msg='{} != {}'.format(exns, expected))
137137

lib/bald/validation.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,31 @@ def _check_uri(uri, exceptions):
110110
def check_attr_domain_range(self, exceptions):
111111
for attr, value in self.subject.attrs.items():
112112
uri = self.subject.unpack_uri(attr)
113-
if self.cache.is_http_uri(uri) and self.cache.check_uri(uri):
114-
# thus we have a payload
115-
# go rdf
116-
g = rdflib.Graph()
117-
data=self.cache[uri].text
118-
try:
119-
g.parse(data=self.cache[uri].text, format="n3")
120-
except Exception:
121-
g.parse(data=self.cache[uri].text, format="xml")
122-
query = ('SELECT ?s \n'
123-
'(GROUP_CONCAT(?domain; SEPARATOR=" | ") AS ?domains)'
124-
' \n'
125-
'(GROUP_CONCAT(?type; SEPARATOR=" | ") AS ?types) \n'
126-
'WHERE {{ \n'
127-
'?s a ?type . \n'
128-
'OPTIONAL{{ ?s rdfs:domain ?domain . }} \n'
129-
'FILTER(?s = <{uria}> || ?s = <{urib}>) \n'
130-
'}} \n'
131-
'GROUP BY ?s \n'.format(uria=uri,
132-
urib=uri.rstrip('/')))
133-
qres = list(g.query(query))
134-
if len(qres) != 1:
135-
raise ValueError('{} does not define one and only one \n'
136-
'rdfs:domain'.format(uri))
137-
qres, = qres
113+
# if self.cache.is_http_uri(uri) and self.cache.check_uri(uri):
114+
# # thus we have a payload
115+
# # go rdf
116+
# g = rdflib.Graph()
117+
# data=self.cache[uri].text
118+
# try:
119+
# g.parse(data=self.cache[uri].text, format="n3")
120+
# except Exception:
121+
# g.parse(data=self.cache[uri].text, format="xml")
122+
# query = ('SELECT ?s \n'
123+
# '(GROUP_CONCAT(?domain; SEPARATOR=" | ") AS ?domains)'
124+
# ' \n'
125+
# '(GROUP_CONCAT(?type; SEPARATOR=" | ") AS ?types) \n'
126+
# 'WHERE {{ \n'
127+
# '?s a ?type . \n'
128+
# 'OPTIONAL{{ ?s rdfs:domain ?domain . }} \n'
129+
# 'FILTER(?s = <{uria}> || ?s = <{urib}>) \n'
130+
# '}} \n'
131+
# 'GROUP BY ?s \n'.format(uria=uri,
132+
# urib=uri.rstrip('/')))
133+
# qres = list(g.query(query))
134+
# if len(qres) != 1:
135+
# exceptions.append(ValueError('{} does not define one and only one \n'
136+
# 'rdfs:domain'.format(uri)))
137+
# qres, = qres
138138
# implement recursive inheritance check
139139
# we need to check if the value that the attr points to
140140
# has an rdf:type which is the same as the one required by

0 commit comments

Comments
 (0)