Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lvcnrpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
waveforms
lvcnrpy
Commits
0a4f4f36
Commit
0a4f4f36
authored
8 years ago
by
Edward Fauchon-Jones
Browse files
Options
Downloads
Patches
Plain Diff
Add `GroupSpec` and improve doc on `DatasetSpec`
parent
acc4e36f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lvcnrpy/format/specs.py
+56
-39
56 additions, 39 deletions
lvcnrpy/format/specs.py
with
56 additions
and
39 deletions
lvcnrpy/format/specs.py
+
56
−
39
View file @
0a4f4f36
...
...
@@ -87,6 +87,61 @@ class Spec(object):
return
3
class
GroupSpec
(
Spec
):
"""
Specification for `h5.Group` fields
"""
dtype
=
h5
.
Group
@classmethod
def
valid
(
self
,
sim
):
try
:
value
=
sim
[
self
.
name
]
except
:
value
=
None
if
value
is
not
None
:
if
isinstance
(
value
,
self
.
dtype
):
return
0
else
:
return
2
else
:
return
3
class
DatasetSpec
(
Spec
):
"""
Specification for `h5.Dataset` fields
Attributes
----------
componentCount: int
Required number of components for each dataset element in the dataset.
"""
dtype
=
h5
.
Dataset
componentCount
=
1
@classmethod
def
valid
(
self
,
sim
):
"""
Validate represented field against format specification.
This will validate that the type of the represented field agrees with
the format specifictaion and that the number of components in the
dataset agrees with `self.componentCount`.
"""
try
:
value
=
sim
[
self
.
name
]
except
:
value
=
None
if
value
is
not
None
:
if
isinstance
(
value
,
self
.
dtype
):
if
len
(
value
[
0
])
==
self
.
componentCount
:
return
0
else
:
return
1
else
:
return
2
else
:
return
3
# General Fields
class
Type
(
Spec
):
"""
Specification for the `type` field
"""
...
...
@@ -158,24 +213,9 @@ class License(Spec):
values
=
[
'
LSC-internal
'
,
'
public
'
]
class
AuxiliaryInfo
(
Spec
):
class
AuxiliaryInfo
(
Group
Spec
):
"""
Specification for the `Format` field
"""
name
=
'
auxiliary-info
'
dtype
=
h5
.
Group
@classmethod
def
valid
(
self
,
sim
):
try
:
value
=
sim
[
self
.
name
]
except
:
value
=
None
if
value
is
not
None
:
if
isinstance
(
value
,
self
.
dtype
):
return
0
else
:
return
2
else
:
return
3
class
NRTechniques
(
Spec
):
...
...
@@ -334,29 +374,6 @@ class MeanAnomaly(Spec):
# Format 2
class
DatasetSpec
(
Spec
):
dtype
=
h5
.
Dataset
componentCount
=
1
@classmethod
def
valid
(
self
,
sim
):
try
:
value
=
sim
[
name
]
except
:
value
=
None
if
value
is
not
None
:
if
isinstance
(
value
,
self
.
dtype
):
if
len
(
value
[
0
])
==
self
.
componentCount
:
return
0
else
:
return
1
else
:
return
2
else
:
return
3
class
Mass1VsTime
(
DatasetSpec
):
"""
Specification for the `mass1-vs-time` field
"""
name
=
'
mass1-vs-time
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment