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

Make HeatMap more general #849

merged 22 commits into from Jan 9, 2017
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+36 −6
Diff settings


Just for now

Fixes for categorical_aggregate2d ordering

  • Loading branch information...
Philipp Rudiger Philipp Rudiger
Philipp Rudiger authored and Philipp Rudiger committed Jan 8, 2017
commit dcae11f41dd3331435297178e7091c62604c74a5
@@ -607,7 +607,7 @@ def sort_topologically(graph):
[set([1, 2]), set([3, 4]), set([5, 6])]
[[1, 2], [3, 4], [5, 6]]
levels_by_name = {}
names_by_level = defaultdict(list)
@@ -647,6 +647,37 @@ def walk_depth_first(name):
(names_by_level.get(i, None)
for i in itertools.count())))

def is_cyclic(graph):
"""Return True if the directed graph g has a cycle."""

This comment has been minimized.

Copy link

jlstevens Jan 9, 2017


What is the representation of the graph? A list of edges as tuples? Would be good to mention in the docstring.

This comment has been minimized.

Copy link

jlstevens Jan 9, 2017


I'm guessing the representation is similar as in one_to_one...even so, probably worth mentioning..

This comment has been minimized.

Copy link

philippjfr Jan 9, 2017

Author Contributor

Right, all three methods here (sort_topologically, cyclical and one_to_one) use the same representation, which is mapping between nodes and edges, will add the docstring.

path = set()

def visit(vertex):
for neighbour in graph.get(vertex, ()):
if neighbour in path or visit(neighbour):
return True
return False

return any(visit(v) for v in graph)

def one_to_one(graph):
"""Return True if graph contains only one to one mappings."""
start, end = set(), set()
for s, e in graph.items():
if len(e) == 0:
e = e[0]
if len(e) > 1 or s in start or e in end:
return False
return True

def get_overlay_spec(o, k, v):
Gets the + key spec from an Element in an Overlay.
@@ -5,7 +5,8 @@

from ..core import Dataset, OrderedDict
from ..core.operation import ElementOperation
from ..core.util import pd, is_nan, sort_topologically, cartesian_product
from ..core.util import (pd, is_nan, sort_topologically,
cartesian_product, is_cyclic, one_to_one)

import dask
@@ -107,19 +108,17 @@ def _process(self, obj, key=None):
grouped = obj.groupby(xdim, container_type=OrderedDict,
orderings = OrderedDict()
is_sorted = np.array_equal(np.sort(d1keys), d1keys)
for group in grouped:
vals = group.dimension_values(ydim)
if len(vals) == 1:
orderings[vals[0]] = []
is_sorted &= np.array_equal(np.sort(vals), vals)
for i in range(len(vals)-1):
p1, p2 = vals[i:i+2]
orderings[p1] = [p2]
if is_sorted:
if one_to_one(orderings):
d2keys = np.sort(d2keys)
elif not is_cyclic(orderings):
d2keys = list(itertools.chain(*sort_topologically(orderings)))

# Pad data with NaNs
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.