Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dccQuantities
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
DigitalDynamicMeasurement
dccQuantities
Commits
804ba4fa
Commit
804ba4fa
authored
3 months ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
added getIDS from refTypes to tables as well as units property
parent
9492d0e2
No related branches found
No related tags found
No related merge requests found
Pipeline
#53171
passed
3 months ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
setup.cfg
+1
-1
1 addition, 1 deletion
setup.cfg
src/DccQuantityTable.py
+26
-0
26 additions, 0 deletions
src/DccQuantityTable.py
tests/test_tables.py
+14
-0
14 additions, 0 deletions
tests/test_tables.py
with
41 additions
and
1 deletion
setup.cfg
+
1
−
1
View file @
804ba4fa
...
@@ -18,7 +18,7 @@ install_requires =
...
@@ -18,7 +18,7 @@ install_requires =
odfpy
odfpy
openpyxl
openpyxl
pandas
pandas
dsiUnits
dsiUnits
>=2.4.1
dccXMLJSONConv
=
=3.0.0.dev6
dccXMLJSONConv
=
=3.0.0.dev6
metas_unclib
metas_unclib
pythonnet
pythonnet
...
...
This diff is collapsed.
Click to expand it.
src/DccQuantityTable.py
+
26
−
0
View file @
804ba4fa
...
@@ -102,6 +102,18 @@ class DccQuantityTable:
...
@@ -102,6 +102,18 @@ class DccQuantityTable:
dims
.
append
(
len
(
self
.
idxQuantities
[
key
]))
dims
.
append
(
len
(
self
.
idxQuantities
[
key
]))
return
tuple
(
dims
)
return
tuple
(
dims
)
@property
def
units
(
self
):
units
=
[]
for
qunat
in
self
.
allQuantities
:
try
:
unitList
=
qunat
.
data
.
unit
for
unit
in
unitList
:
units
.
append
(
unit
)
except
AttributeError
:
pass
return
set
(
units
)
def
__getitem__
(
self
,
index
):
def
__getitem__
(
self
,
index
):
raise
NotImplementedError
(
"
Subclasses must implement __getitem__.
"
)
raise
NotImplementedError
(
"
Subclasses must implement __getitem__.
"
)
...
@@ -132,6 +144,20 @@ class DccQuantityTable:
...
@@ -132,6 +144,20 @@ class DccQuantityTable:
warnings
.
warn
(
"
More Than one Quantity found matching
"
+
str
(
name
))
warnings
.
warn
(
"
More Than one Quantity found matching
"
+
str
(
name
))
return
qunatites
return
qunatites
def
getQunatitysIDsByrefType
(
self
,
refType
):
qunatites
=
[]
for
quant
in
self
.
allQuantities
:
# Check if the given refType is in the quantity's refType list.
if
refType
in
quant
.
refType
:
qunatites
.
append
(
quant
.
id
)
if
not
qunatites
:
return
None
if
len
(
qunatites
)
==
1
:
return
qunatites
[
0
]
if
len
(
qunatites
)
>
1
:
warnings
.
warn
(
"
More than one Quantity found matching
"
+
str
(
refType
))
return
qunatites
class
DccLongTable
(
DccQuantityTable
):
class
DccLongTable
(
DccQuantityTable
):
def
__init__
(
self
,
dccDict
):
def
__init__
(
self
,
dccDict
):
super
().
__init__
(
dccDict
)
super
().
__init__
(
dccDict
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_tables.py
+
14
−
0
View file @
804ba4fa
...
@@ -57,7 +57,21 @@ def test_getQunatityByName(simple_sine_table):
...
@@ -57,7 +57,21 @@ def test_getQunatityByName(simple_sine_table):
wrongQunat
=
simple_sine_table
.
getQunatitysIDsByName
(
'
Acceleration Amplidsad dysafdsa fas fatude
'
)
wrongQunat
=
simple_sine_table
.
getQunatitysIDsByName
(
'
Acceleration Amplidsad dysafdsa fas fatude
'
)
assert
wrongQunat
is
None
assert
wrongQunat
is
None
def
test_getQunatityByrefType
(
simple_sine_table
):
# Test that the simple sine table is properly parsed.
frequencyQunatFromName
=
simple_sine_table
.
getQunatitysIDsByName
(
'
Frequenz
'
)
frequencyQunatFromeRefType1
=
simple_sine_table
.
getQunatitysIDsByrefType
(
'
vib_frequency
'
)
frequencyQunatFromeRefType2
=
simple_sine_table
.
getQunatitysIDsByrefType
(
'
vib_nominalFrequency
'
)
frequencyQunatFromeRefType3
=
simple_sine_table
.
getQunatitysIDsByrefType
(
'
basic_TableIndex0
'
)
assert
frequencyQunatFromName
==
frequencyQunatFromeRefType1
==
frequencyQunatFromeRefType2
==
frequencyQunatFromeRefType3
pahses
=
simple_sine_table
.
getQunatitysIDsByrefType
(
'
vib_phase
'
)
assert
len
(
pahses
)
==
2
wrongQunat
=
simple_sine_table
.
getQunatitysIDsByrefType
(
'
foo
'
)
assert
wrongQunat
is
None
def
test_tableUnits
(
simple_sine_table
):
units
=
simple_sine_table
.
units
print
(
"
DEBUG
"
)
def
test_flatTableShort
():
def
test_flatTableShort
():
test_file
=
get_test_file
(
"
tests
"
,
"
data
"
,
"
5DFlatTableParsingTest.xml
"
,
asDict
=
True
)
test_file
=
get_test_file
(
"
tests
"
,
"
data
"
,
"
5DFlatTableParsingTest.xml
"
,
asDict
=
True
)
...
...
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