Skip to content
Permalink
Browse files

Merge pull request #992 from ioam/interface_nonzero

Dataset types use __nonzero/bool__ method for truthiness
  • Loading branch information...
jlstevens committed Nov 29, 2016
2 parents 3ba0b42 + 90d9050 commit 8c03983685044b88338865235333856a8dc79c55
@@ -426,6 +426,10 @@ def __len__(self):
"""
return self.interface.length(self)

def __nonzero__(self):
return self.interface.nonzero(self)

__bool__ = __nonzero__

@property
def shape(self):
@@ -229,12 +229,8 @@ def dframe(cls, columns, dimensions):
return columns.data.compute()

@classmethod
def length(cls, dataset):
"""
Length of dask dataframe is unknown, always return 1
for performance, use shape to compute dataframe shape.
"""
return 1
def nonzero(cls, dataset):
return True



@@ -207,6 +207,10 @@ def shape(cls, dataset):
def length(cls, dataset):
return len(dataset.data)

@classmethod
def nonzero(cls, dataset):
return bool(cls.length(dataset))

@classmethod
def redim(cls, dataset, dimensions):
return dataset.data
@@ -629,7 +629,7 @@ def _valid_dimensions(self, dimensions):
@property
def ddims(self):
"The list of deep dimensions"
if self._deep_indexable and len(self):
if self._deep_indexable and self:
return self.values()[0].dimensions()
else:
return []
@@ -309,12 +309,6 @@ class Points(Chart):

_min_dims = 2 # Minimum number of columns

def __iter__(self):
i = 0
while i < len(self):
yield tuple(self.data[i, ...])
i += 1



class VectorField(Points):

0 comments on commit 8c03983

Please sign in to comment.
You can’t perform that action at this time.