Skip to content

Commit 090fe72

Browse files
committed
test use of variables for prefix and alias
1 parent 6cef8b7 commit 090fe72

File tree

3 files changed

+15
-64
lines changed

3 files changed

+15
-64
lines changed

lib/bald/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ def load_netcdf(afilepath, uri=None):
540540
prefix_group = (fhandle[fhandle.bald__isPrefixedBy] if
541541
hasattr(fhandle, 'bald__isPrefixedBy') else {})
542542
prefixes = {}
543-
if prefix_group:
543+
544+
if prefix_group != {}:
544545
prefixes = (dict([(prefix, getattr(prefix_group, prefix)) for
545546
prefix in prefix_group.ncattrs()]))
546547
else:
@@ -550,7 +551,7 @@ def load_netcdf(afilepath, uri=None):
550551
alias_group = (fhandle[fhandle.bald__isAliasedBy]
551552
if hasattr(fhandle, 'bald__isAliasedBy') else {})
552553
aliases = {}
553-
if alias_group:
554+
if alias_group != {}:
554555
aliases = (dict([(alias, getattr(alias_group, alias))
555556
for alias in alias_group.ncattrs()]))
556557

lib/bald/tests/integration/CDL/array_alias.cdl

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,19 @@ variables:
88
parent_variable:SDN_ParameterDiscoveryCode = "BactTaxaAbundSed" ;
99
parent_variable:submursible_name = "Nautilus" ;
1010

11+
int prefix_list ;
12+
prefix_list:bald__ = "http://binary-array-ld.net/latest/" ;
13+
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
14+
15+
int alias_list ;
16+
alias_list:SDN_ParameterDiscoveryCode = "http://vocab.nerc.ac.uk/isoCodelists/sdnCodelists/cdicsrCodeList.xml#SDN_ParameterDiscoveryCode" ;
17+
alias_list:BactTaxaAbundSed = "http://vocab.nerc.ac.uk/collection/P02/current/BAUC/" ;
18+
19+
1120
// global attributes:
1221
:_NCProperties = "version=1|netcdflibversion=4.4.1|hdf5libversion=1.8.17" ;
1322
:rdf__type = "bald__Container" ;
1423
:bald__isPrefixedBy = "prefix_list" ;
1524
:bald__isAliasedBy = "alias_list" ;
16-
data:
17-
18-
parent_variable =
19-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
20-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
21-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
22-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
23-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
24-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
25-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
26-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
27-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
28-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
29-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ ;
30-
31-
32-
group: prefix_list {
33-
34-
// group attributes:
35-
:bald__ = "http://binary-array-ld.net/latest/" ;
36-
:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
37-
} // group bald__prefix_list
38-
39-
group: alias_list {
4025

41-
// group attributes:
42-
:SDN_ParameterDiscoveryCode = "http://vocab.nerc.ac.uk/isoCodelists/sdnCodelists/cdicsrCodeList.xml#SDN_ParameterDiscoveryCode" ;
43-
:BactTaxaAbundSed = "http://vocab.nerc.ac.uk/collection/P02/current/BAUC/" ;
44-
} // group bald__alias_list
4526
}

lib/bald/tests/integration/CDL/array_reference.cdl

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,12 @@ variables:
99
int child_variable(pdim0, pdim1) ;
1010
child_variable:rdf__type = "bald__Reference" ;
1111
child_variable:bald__array = "child_variable" ;
12+
int prefix_list ;
13+
prefix_list:bald__ = "http://binary-array-ld.net/latest/" ;
14+
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
1215

1316
// global attributes:
1417
:_NCProperties = "version=1|netcdflibversion=4.4.1|hdf5libversion=1.8.17" ;
1518
:rdf__type = "bald__Container" ;
1619
:bald__isPrefixedBy = "prefix_list" ;
17-
data:
18-
19-
parent_variable =
20-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
21-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
22-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
23-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
24-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
25-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
26-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
27-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
28-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
29-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
30-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ ;
31-
32-
child_variable =
33-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
34-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
35-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
36-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
37-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
38-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
39-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
40-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
41-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
42-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
43-
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ ;
44-
45-
group: prefix_list {
46-
47-
// group attributes:
48-
:bald__ = "http://binary-array-ld.net/latest/" ;
49-
:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
50-
} // group bald__prefix_list
5120
}

0 commit comments

Comments
 (0)