Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensured Dimensioned.range respects one-sided Dimension.range #940

Merged
merged 1 commit into from
Oct 18, 2016
Merged
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: 1 addition & 2 deletions holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ def range(self, dim, data_range=True):
dim = self.get_dimension(dim)
if None not in dim.range:
return dim.range
elif dim in self.dimensions():
elif dim in self.dimensions() and data_range:
if len(self):
drange = self.interface.range(self, dim)
else:
drange = (np.NaN, np.NaN)
if data_range:
soft_range = [r for r in dim.soft_range if r is not None]
if soft_range:
drange = util.max_range([drange, soft_range])
Expand Down
37 changes: 23 additions & 14 deletions holoviews/core/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,21 +858,30 @@ def range(self, dimension, data_range=True):
dimension = self.get_dimension(dimension)
if dimension is None:
return (None, None)
if dimension.range != (None, None):
if None not in dimension.range:
return dimension.range
elif not data_range:
return (None, None)
soft_range = [r for r in dimension.soft_range
if r is not None]
if dimension in self.kdims or dimension in self.vdims:
dim_vals = self.dimension_values(dimension.name)
return find_range(dim_vals, soft_range)
dname = dimension.name
match_fn = lambda x: dname in x.dimensions(['key', 'value'], True)
range_fn = lambda x: x.range(dname)
ranges = self.traverse(range_fn, [match_fn])
drange = max_range(ranges)
return drange
elif data_range:
if dimension in self.kdims or dimension in self.vdims:
dim_vals = self.dimension_values(dimension.name)
drange = find_range(dim_vals)
else:
dname = dimension.name
match_fn = lambda x: dname in x.dimensions(['key', 'value'], True)
range_fn = lambda x: x.range(dname)
ranges = self.traverse(range_fn, [match_fn])
drange = max_range(ranges)
soft_range = [r for r in dimension.soft_range if r is not None]
if soft_range:
drange = util.max_range([drange, soft_range])
else:
drange = dim.soft_range
if dimension.range[0] is not None:
return (dimension.range[0], drange[1])
elif dimension.range[1] is not None:
return (drange[0], dimension.range[1])
else:
return drange


def __repr__(self):
reprval = PrettyPrinter.pprint(self)
Expand Down