Repository: biolab/orange3

Issue:
PCA's components output contains variables of type TimeVariable
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.5.0.dev0+e7e0a70

##### Expected behavior
On the _Components_ output of the PCA widget all variables should be of type ContinuousVariable.


##### Actual behavior
Variables can be of type TimeVariable when normalization is turned off. 

##### Steps to reproduce the behavior
Load a data set with a TimeVariable (e.g. philadeplhia-crime) and pass it to PCA. Then turn off data normalization and observe the type of the output variables for example in DataTable or Distributions.


##### Additional info (worksheets, data, screenshots, ...)
<img width="1130" alt="screen shot 2017-05-19 at 23 14 05" src="https://cloud.githubusercontent.com/assets/713026/26267261/75ffcf9c-3ce9-11e7-9f55-cda5fd1e832f.png">




Discussion:

Resolving patch:
diff --git a/Orange/widgets/unsupervised/owpca.py b/Orange/widgets/unsupervised/owpca.py
--- a/Orange/widgets/unsupervised/owpca.py
+++ b/Orange/widgets/unsupervised/owpca.py
@@ -7,7 +7,7 @@
 import numpy
 import pyqtgraph as pg
 
-from Orange.data import Table, Domain, StringVariable
+from Orange.data import Table, Domain, StringVariable, ContinuousVariable
 from Orange.data.sql.table import SqlTable, AUTO_DL_LIMIT
 from Orange.preprocess import Normalize
 from Orange.projection import PCA
@@ -419,7 +419,8 @@ def commit(self):
                 self.data.domain.metas
             )
             transformed = transformed.from_table(domain, transformed)
-            dom = Domain(self._pca.orig_domain.attributes,
+            dom = Domain([ContinuousVariable(a.name)
+                          for a in self._pca.orig_domain.attributes],
                          metas=[StringVariable(name='component')])
             metas = numpy.array([['PC{}'.format(i + 1)
                                   for i in range(self.ncomponents)]],


Test patch:
diff --git a/Orange/widgets/unsupervised/tests/test_owpca.py b/Orange/widgets/unsupervised/tests/test_owpca.py
--- a/Orange/widgets/unsupervised/tests/test_owpca.py
+++ b/Orange/widgets/unsupervised/tests/test_owpca.py
@@ -3,7 +3,7 @@
 import numpy as np
 import scipy.sparse as sp
 
-from Orange.data import Table, Domain
+from Orange.data import Table, Domain, ContinuousVariable, TimeVariable
 from Orange.widgets.tests.base import WidgetTest
 from Orange.widgets.unsupervised.owpca import OWPCA
 
@@ -76,3 +76,18 @@ def test_error_on_sparse_data(self):
         data.X = sp.csr_matrix(data.X)
         self.widget.set_data(data)
         self.assertTrue(self.widget.Error.sparse_data.is_shown())
+
+    def test_all_components_continuous(self):
+        data = Table("banking-crises.tab")
+        # GH-2329 only occurred on TimeVariables when normalize=False
+        self.assertTrue(any(isinstance(a, TimeVariable)
+                            for a in data.domain.attributes))
+
+        self.widget.normalize = False
+        self.widget._update_normalize()     # pylint: disable=protected-access
+        self.widget.set_data(data)
+
+        components = self.get_output("Components")
+        self.assertTrue(all(type(a) is ContinuousVariable   # pylint: disable=unidiomatic-typecheck
+                            for a in components.domain.attributes),
+                        "Some variables aren't of type ContinuousVariable")