From 993c115e287b04769ecba13b392b64e8c25c5656 Mon Sep 17 00:00:00 2001
From: Stefano Borini <sborini@enthought.com>
Date: Tue, 8 Aug 2017 14:42:27 +0100
Subject: [PATCH] Allow for empty names to be used and discard the associated
 information

---
 force_bdss/core_evaluation_driver.py              | 4 +++-
 force_bdss/data_sources/base_data_source_model.py | 8 ++++++--
 force_bdss/kpi/base_kpi_calculator_model.py       | 8 ++++++--
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/force_bdss/core_evaluation_driver.py b/force_bdss/core_evaluation_driver.py
index e6457ca..a9779ea 100644
--- a/force_bdss/core_evaluation_driver.py
+++ b/force_bdss/core_evaluation_driver.py
@@ -137,7 +137,9 @@ class CoreEvaluationDriver(BaseCoreDriver):
             for dv, output_slot_name in zip(res, model.output_slot_names):
                 dv.name = output_slot_name
 
-            results.extend(res)
+            # If the name was not specified, simply discard the value,
+            # because apparently the user is not interested in it.
+            results.extend([r for r in res if r.name != ""])
 
         # Finally, return all the computed data values from all evaluators,
         # properly named.
diff --git a/force_bdss/data_sources/base_data_source_model.py b/force_bdss/data_sources/base_data_source_model.py
index ad1bd41..08add56 100644
--- a/force_bdss/data_sources/base_data_source_model.py
+++ b/force_bdss/data_sources/base_data_source_model.py
@@ -1,6 +1,7 @@
-from traits.api import ABCHasStrictTraits, Instance, List, String
+from traits.api import ABCHasStrictTraits, Instance, List
 
 from force_bdss.core.input_slot_map import InputSlotMap
+from force_bdss.local_traits import Identifier
 from .i_data_source_factory import IDataSourceFactory
 
 
@@ -23,7 +24,10 @@ class BaseDataSourceModel(ABCHasStrictTraits):
 
     #: Allows to assign names to the output slots, so that they can be
     #: referenced somewhere else (e.g. the KPICalculators).
-    output_slot_names = List(String(), visible=False)
+    #: If the name is the empty string, it means that the user is not
+    #: interested in preserving the information, and should therefore be
+    #: discarded and not propagated further.
+    output_slot_names = List(Identifier(), visible=False)
 
     def __init__(self, factory, *args, **kwargs):
         self.factory = factory
diff --git a/force_bdss/kpi/base_kpi_calculator_model.py b/force_bdss/kpi/base_kpi_calculator_model.py
index bebf589..afbbbeb 100644
--- a/force_bdss/kpi/base_kpi_calculator_model.py
+++ b/force_bdss/kpi/base_kpi_calculator_model.py
@@ -1,5 +1,6 @@
-from traits.api import ABCHasStrictTraits, Instance, List, String
+from traits.api import ABCHasStrictTraits, Instance, List
 
+from force_bdss.local_traits import Identifier
 from ..core.input_slot_map import InputSlotMap
 from .i_kpi_calculator_factory import IKPICalculatorFactory
 
@@ -23,7 +24,10 @@ class BaseKPICalculatorModel(ABCHasStrictTraits):
 
     #: Allows to assign names to the output slots, so that they can be
     #: referenced somewhere else (e.g. the KPICalculators).
-    output_slot_names = List(String(), visible=False)
+    #: If the name is the empty string, it means that the user is not
+    #: interested in preserving the information, and should therefore be
+    #: discarded and not propagated further.
+    output_slot_names = List(Identifier(), visible=False)
 
     def __init__(self, factory, *args, **kwargs):
         self.factory = factory
-- 
GitLab