Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Orange/data/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def variables(self):
def metas(self):
return self._metas

def filter(self, pred):
return [v for v in chain(self, self.metas) if pred(v)]

def __len__(self):
"""The number of variables (features and class attributes)."""
return len(self._variables)
Expand Down
12 changes: 8 additions & 4 deletions Orange/data/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from Orange.util import Registry, color_to_hex, hex_to_color, Reprable

__all__ = ["Unknown", "MISSING_VALUES", "make_variable", "is_discrete_values",
"Value", "Variable", "ContinuousVariable", "DiscreteVariable",
"Value", "Variable", "PrimitiveVariable", "ContinuousVariable", "DiscreteVariable",
"StringVariable", "TimeVariable"]


Expand Down Expand Up @@ -348,7 +348,7 @@ def is_primitive(cls):
`True` if the variable's values are stored as floats.
Non-primitive variables can appear in the data only as meta attributes.
"""
return issubclass(cls, (DiscreteVariable, ContinuousVariable))
return issubclass(cls, PrimitiveVariable)

@property
def is_discrete(self):
Expand Down Expand Up @@ -439,7 +439,11 @@ def copy(self, compute_value):
return var


class ContinuousVariable(Variable):
class PrimitiveVariable(Variable):
TYPE_HEADERS = ()


class ContinuousVariable(PrimitiveVariable):
"""
Descriptor for continuous variables.

Expand Down Expand Up @@ -536,7 +540,7 @@ def copy(self, compute_value=None):
return var


class DiscreteVariable(Variable):
class DiscreteVariable(PrimitiveVariable):
"""
Descriptor for symbolic, discrete variables. Values of discrete variables
are stored as floats; the numbers corresponds to indices in the list of
Expand Down