Skip to content
Snippets Groups Projects
Commit 804ba4fa authored by Benedikt's avatar Benedikt
Browse files

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
...@@ -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
......
...@@ -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)
......
...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment