<commit_before>import random
from collections import defaultdict

from ipysankeywidget import SankeyWidget
import networkx as nx

from .utils import pairwise
from .sankey_view import sankey_view
from .augment_view_graph import augment, elsewhere_bundles
from .view_graph import view_graph
from .graph_to_sankey import graph_to_sankey
from .view_definition import ViewDefinition
from IPython.display import display
import graphviz


def show_sankey(view_definition, dataset, palette=None, width=700, height=500,
                align_materials=False):
    G, order, groups = sankey_view(view_definition, dataset)
    value = graph_to_sankey(G, order, groups, palette=palette)
    if align_materials:
        value['alignMaterials'] = True
    return SankeyWidget(value=value, width=width, height=height,
                        margins={'top': 15, 'bottom': 10, 'left': 90, 'right': 100})


def show_view_definition(view_definition, filename=None,
                       directory=None, xlabels=None, labels=None):
    if xlabels is None:
        xlabels = {}<commit_msg>update for SankeyWidget width/height as str<commit_after>import random
from collections import defaultdict

from ipysankeywidget import SankeyWidget
import networkx as nx

from .utils import pairwise
from .sankey_view import sankey_view
from .augment_view_graph import augment, elsewhere_bundles
from .view_graph import view_graph
from .graph_to_sankey import graph_to_sankey
from .view_definition import ViewDefinition
from IPython.display import display
import graphviz


def show_sankey(view_definition, dataset, palette=None, width=700, height=500,
                align_materials=False):
    G, order, groups = sankey_view(view_definition, dataset)
    value = graph_to_sankey(G, order, groups, palette=palette)
    if align_materials:
        value['alignMaterials'] = True
    return SankeyWidget(value=value, width=str(width), height=str(height),
                        margins={'top': 15, 'bottom': 10, 'left': 90, 'right': 100})


def show_view_definition(view_definition, filename=None,
                       directory=None, xlabels=None, labels=None):
    if xlabels is None:
        xlabels = {}
{'fraction_non_alphanumeric': 0.07844036697247707, 'fraction_numerical': 0.013761467889908258, 'mean_word_length': 4.23021582733813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2719750', 'n_tokens_mistral': 660, 'n_tokens_neox': 615, 'n_words': 183}