From cb8d2b13be4bf60fce2dff906e080a78046e8c67 Mon Sep 17 00:00:00 2001
From: vermeul <swen@ethz.ch>
Date: Tue, 21 Aug 2018 11:55:07 +0200
Subject: [PATCH] sample_type.get_semantic_annotations() now returns an empty
 DataFrame with the correct column headers

---
 pybis/src/python/pybis/pybis.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pybis/src/python/pybis/pybis.py b/pybis/src/python/pybis/pybis.py
index 4bbd440dbf2..360276b069a 100644
--- a/pybis/src/python/pybis/pybis.py
+++ b/pybis/src/python/pybis/pybis.py
@@ -2093,11 +2093,14 @@ class Openbis:
 
         if only_data:
             return objects
+
+        attrs = ['permId', 'entityType', 'propertyType', 'predicateOntologyId', 'predicateOntologyVersion', 'predicateAccessionId', 'descriptorOntologyId', 'descriptorOntologyVersion', 'descriptorAccessionId', 'creationDate']
+        if len(objects) == 0:
+            annotations = DataFrame(columns=attrs)
         else:
-            attrs = ['permId', 'entityType', 'propertyType', 'predicateOntologyId', 'predicateOntologyVersion', 'predicateAccessionId', 'descriptorOntologyId', 'descriptorOntologyVersion', 'descriptorAccessionId', 'creationDate']
             annotations = DataFrame(objects)
-            annotations = annotations if len(objects) == 0 else annotations[attrs]
-            return Things(self, 'semantic_annotation', annotations, 'permId')
+
+        return Things(self, 'semantic_annotation', annotations[attrs], 'permId')
 
     def _search_semantic_annotations(self, criteria):
 
-- 
GitLab