From 07896b8acb70847adff9fd676ef96b85d215fda6 Mon Sep 17 00:00:00 2001 From: Lauri Himanen <lauri.himanen@aalto.fi> Date: Wed, 27 Jul 2016 18:46:19 +0300 Subject: [PATCH] Fixed merge conflict. --- common/python/nomadcore/caching_backend.py | 20 +++++++++++--------- common/python/nomadcore/csvparsing.py | 4 ++-- common/python/nomadcore/local_backend.py | 3 +++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/common/python/nomadcore/caching_backend.py b/common/python/nomadcore/caching_backend.py index e0f8595..acf7f94 100644 --- a/common/python/nomadcore/caching_backend.py +++ b/common/python/nomadcore/caching_backend.py @@ -398,7 +398,8 @@ class ActiveBackend(object): def addValue(self, metaName, value, gIndex = -1): """adds a json value corresponding to metaName 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] cachingLevel = dataManager.cachingLevel if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache: @@ -412,15 +413,16 @@ class ActiveBackend(object): added to the section the meta info metaName is in A gIndex of -1 means the latest section. """ - value = self.convert_unit(metaName, value, unit) + if unit is not None: + value = self.convert_unit(metaName, value, unit) dataManager = self.dataManagers[metaName] cachingLevel = dataManager.cachingLevel if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache: if self.superBackend: self.superBackend.addRealValue(metaName, value, gIndex) - if cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.Cache or cachingLevel == CachingLevel.PreOpenedCache: - dataManager.superSectionManager.addRealValue(dataManager.metaInfo, value, gIndex) + if cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.Cache: + dataManager.superSectionManager.addValue(dataManager.metaInfo, value, gIndex) def addArray(self, metaName, shape, gIndex = -1): """adds a new array value of the given size corresponding to metaName @@ -438,7 +440,8 @@ class ActiveBackend(object): def setArrayValues(self, metaName, values, offset = None, gIndex = -1, unit=None): """Adds values to the last array added, array must be a numpy array """ - values = self.convert_unit(metaName, values, unit) + if unit is not None: + values = self.convert_unit(metaName, values, unit) dataManager = self.dataManagers[metaName] cachingLevel = dataManager.cachingLevel @@ -452,7 +455,9 @@ class ActiveBackend(object): """Adds an array value with the given array values. Values must be a numpy array. """ - values = self.convert_unit(metaName, values, unit) + if unit is not None: + values = self.convert_unit(metaName, values, unit) + dataManager = self.dataManagers[metaName] cachingLevel = dataManager.cachingLevel if cachingLevel == CachingLevel.Forward or cachingLevel == CachingLevel.ForwardAndCache or cachingLevel == CachingLevel.PreOpenedCache: @@ -476,9 +481,6 @@ class ActiveBackend(object): def convert_unit(self, metaName, value, unit): """Try to perform a unit conversion. """ - if unit is None: - return value - # If a unit has been specified in the metainfo, check that the # conversion can be done metaInfo = self.metaInfoEnv().infoKindEl(metaName) diff --git a/common/python/nomadcore/csvparsing.py b/common/python/nomadcore/csvparsing.py index 4d5e515..ca9e158 100644 --- a/common/python/nomadcore/csvparsing.py +++ b/common/python/nomadcore/csvparsing.py @@ -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 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 @@ -164,6 +164,6 @@ def iread(filepath, columns, delimiter=r"\s+", comments=r"#", start=None, end=No conf.append(line_values) i_line += 1 if i_line == n_conf: - yield conf + yield np.array(conf) conf = [] i_line = 0 diff --git a/common/python/nomadcore/local_backend.py b/common/python/nomadcore/local_backend.py index 17ef6e6..2a7e54e 100644 --- a/common/python/nomadcore/local_backend.py +++ b/common/python/nomadcore/local_backend.py @@ -103,6 +103,9 @@ class LocalBackend(object): 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): dataManager = self.dataManagers[metaName] -- GitLab