Skip to content

Commit 9d2f96c

Browse files
committed
fixing refs to alias_group and prefix_group to vars
1 parent 1745701 commit 9d2f96c

File tree

4 files changed

+119
-161
lines changed

4 files changed

+119
-161
lines changed

lib/bald/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,13 @@ def load_netcdf(afilepath, uri=None, baseuri=None):
550550
prefix_var = (fhandle[fhandle.bald__isPrefixedBy] if
551551
hasattr(fhandle, 'bald__isPrefixedBy') else {})
552552
prefixes = {}
553-
if prefix_var != {} :
553+
554+
skipped_variables = []
555+
if prefix_var != {}:
554556
prefixes = (dict([(prefix, getattr(prefix_var, prefix)) for
555557
prefix in prefix_var.ncattrs()]))
558+
if isinstance(prefix_var, netCDF4._netCDF4.Variable):
559+
skipped_variables.append(prefix_var.name)
556560
else:
557561
for k in fhandle.ncattrs():
558562
if k.endswith('__'):
@@ -577,7 +581,8 @@ def load_netcdf(afilepath, uri=None, baseuri=None):
577581
if alias_var != {}:
578582
aliases = (dict([(alias, getattr(alias_var, alias))
579583
for alias in alias_var.ncattrs()]))
580-
#print(aliases)
584+
if isinstance(alias_var, netCDF4._netCDF4.Variable):
585+
skipped_variables.append(alias_var.name)
581586

582587
attrs = {}
583588
for k in fhandle.ncattrs():
@@ -609,13 +614,16 @@ def load_netcdf(afilepath, uri=None, baseuri=None):
609614
#sattrs['bald__array'] = name
610615
sattrs['bald__array'] = identity
611616
sattrs['rdf__type'] = 'bald__Reference'
612-
613617
if fhandle.variables[name].shape:
614618
sattrs['bald__shape'] = fhandle.variables[name].shape
615619
var = Array(identity, sattrs, prefixes=prefixes, aliases=aliases)
616620
else:
617621
var = Subject(identity, sattrs, prefixes=prefixes, aliases=aliases)
618-
root_container.attrs['bald__contains'].append(var)
622+
if name not in skipped_variables:
623+
# Don't include skipped variables, such as prefix or alias
624+
# variables, within the containment relation.
625+
root_container.attrs['bald__contains'].append(var)
626+
619627
file_variables[name] = var
620628

621629

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)