Skip to content
Snippets Groups Projects
Commit 07896b8a authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed merge conflict.

parent 38eb0706
Branches
Tags
No related merge requests found
...@@ -398,7 +398,8 @@ class ActiveBackend(object): ...@@ -398,7 +398,8 @@ class ActiveBackend(object):
def addValue(self, metaName, value, gIndex = -1): def addValue(self, metaName, value, gIndex = -1):
"""adds a json value corresponding to metaName """adds a json value corresponding to metaName
the value is added to the section the meta info metaName is in the value is added to the section the meta info metaName is in
a gIndex of -1 means the latest section""" a gIndex of -1 means the latest section
"""
dataManager = self.dataManagers[metaName] dataManager = self.dataManagers[metaName]
cachingLevel = dataManager.cachingLevel cachingLevel = dataManager.cachingLevel
if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache: if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache:
...@@ -412,6 +413,7 @@ class ActiveBackend(object): ...@@ -412,6 +413,7 @@ class ActiveBackend(object):
added to the section the meta info metaName is in A gIndex of -1 means added to the section the meta info metaName is in A gIndex of -1 means
the latest section. the latest section.
""" """
if unit is not None:
value = self.convert_unit(metaName, value, unit) value = self.convert_unit(metaName, value, unit)
dataManager = self.dataManagers[metaName] dataManager = self.dataManagers[metaName]
...@@ -419,8 +421,8 @@ class ActiveBackend(object): ...@@ -419,8 +421,8 @@ class ActiveBackend(object):
if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache: if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache:
if self.superBackend: if self.superBackend:
self.superBackend.addRealValue(metaName, value, gIndex) self.superBackend.addRealValue(metaName, value, gIndex)
if cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.Cache or cachingLevel == CachingLevel.PreOpenedCache: if cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.Cache:
dataManager.superSectionManager.addRealValue(dataManager.metaInfo, value, gIndex) dataManager.superSectionManager.addValue(dataManager.metaInfo, value, gIndex)
def addArray(self, metaName, shape, gIndex = -1): def addArray(self, metaName, shape, gIndex = -1):
"""adds a new array value of the given size corresponding to metaName """adds a new array value of the given size corresponding to metaName
...@@ -438,6 +440,7 @@ class ActiveBackend(object): ...@@ -438,6 +440,7 @@ class ActiveBackend(object):
def setArrayValues(self, metaName, values, offset = None, gIndex = -1, unit=None): def setArrayValues(self, metaName, values, offset = None, gIndex = -1, unit=None):
"""Adds values to the last array added, array must be a numpy array """Adds values to the last array added, array must be a numpy array
""" """
if unit is not None:
values = self.convert_unit(metaName, values, unit) values = self.convert_unit(metaName, values, unit)
dataManager = self.dataManagers[metaName] dataManager = self.dataManagers[metaName]
...@@ -452,7 +455,9 @@ class ActiveBackend(object): ...@@ -452,7 +455,9 @@ class ActiveBackend(object):
"""Adds an array value with the given array values. Values must be a """Adds an array value with the given array values. Values must be a
numpy array. numpy array.
""" """
if unit is not None:
values = self.convert_unit(metaName, values, unit) values = self.convert_unit(metaName, values, unit)
dataManager = self.dataManagers[metaName] dataManager = self.dataManagers[metaName]
cachingLevel = dataManager.cachingLevel cachingLevel = dataManager.cachingLevel
if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache: if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache:
...@@ -476,9 +481,6 @@ class ActiveBackend(object): ...@@ -476,9 +481,6 @@ class ActiveBackend(object):
def convert_unit(self, metaName, value, unit): def convert_unit(self, metaName, value, unit):
"""Try to perform a unit conversion. """Try to perform a unit conversion.
""" """
if unit is None:
return value
# If a unit has been specified in the metainfo, check that the # If a unit has been specified in the metainfo, check that the
# conversion can be done # conversion can be done
metaInfo = self.metaInfoEnv().infoKindEl(metaName) metaInfo = self.metaInfoEnv().infoKindEl(metaName)
......
...@@ -5,7 +5,7 @@ logger = logging.getLogger(__name__) ...@@ -5,7 +5,7 @@ logger = logging.getLogger(__name__)
#=============================================================================== #===============================================================================
def iread(filepath, columns, delimiter=r"\s+", comments=r"#", start=None, end=None, n_conf=None): def iread(filepath, columns=None, delimiter=r"\s+", comments=r"#", start=None, end=None, n_conf=None):
"""Used to iterate a CSV-like file. If a separator is provided the file """Used to iterate a CSV-like file. If a separator is provided the file
is iterated one configuration at a time. Only keeps one configuration is iterated one configuration at a time. Only keeps one configuration
of the file in memory. If no separator is given, the whole file will be of the file in memory. If no separator is given, the whole file will be
...@@ -164,6 +164,6 @@ def iread(filepath, columns, delimiter=r"\s+", comments=r"#", start=None, end=No ...@@ -164,6 +164,6 @@ def iread(filepath, columns, delimiter=r"\s+", comments=r"#", start=None, end=No
conf.append(line_values) conf.append(line_values)
i_line += 1 i_line += 1
if i_line == n_conf: if i_line == n_conf:
yield conf yield np.array(conf)
conf = [] conf = []
i_line = 0 i_line = 0
...@@ -103,6 +103,9 @@ class LocalBackend(object): ...@@ -103,6 +103,9 @@ class LocalBackend(object):
dataManager.superSectionManager.addValue(dataManager.metaInfo, value, gIndex) dataManager.superSectionManager.addValue(dataManager.metaInfo, value, gIndex)
def addRealValue(self, metaName, value, gIndex=-1):
self.addValue(metaName, value, gIndex)
def addArrayValues(self, metaName, values, gIndex=-1): def addArrayValues(self, metaName, values, gIndex=-1):
dataManager = self.dataManagers[metaName] dataManager = self.dataManagers[metaName]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment