<commit_before># -*- coding:utf-8 -*-

#-----------------------------------------------------------------------------
#  Author: <NAME> <<EMAIL>> CERN
#-----------------------------------------------------------------------------

################################################################################
# Copyright (C) 1995-2020, <NAME> and <NAME>.                      #
# All rights reserved.                                                         #
#                                                                              #
# For the licensing terms see $ROOTSYS/LICENSE.                                #
# For the list of contributors see $ROOTSYS/README/CREDITS.                    #
################################################################################


from __future__ import print_function

import os
import sys
import select
import tempfile
import pty
import itertools
import re
import fnmatch
import time
from datetime import datetime
from hashlib import sha1
from contextlib import contextmanager
from subprocess import check_output
from IPython import get_ipython
from IPython.display import HTML
from IPython.core.extensions import ExtensionManager
import IPython.display
import ROOT
from JupyROOT.helpers import handlers

# We want iPython to take over the graphics
ROOT.gROOT.SetBatch()


cppMIME = 'text/x-c++src'

_jsMagicHighlight = """
Jupyter.CodeCell.options_default.highlight_modes['magic_{cppMIME}'] = {{'reg':[/^%%cpp/]}};
console.log("JupyROOT - %%cpp magic configured");
"""

_jsNotDrawableClassesPatterns = ["TEve*","TF3","TPolyLine3D"]

_jsCanvasWidth = 800
_jsCanvasHeight = 600
_jsCode = """

<div id="{jsDivId}"
     style="width: {jsCanvasWidth}px; height: {jsCanvasHeight}px">
</div>
<script>

function display_{jsDivId}(Core) {{
   let obj = Core.parse({jsonContent});
   Core.settings.HandleKeys = false;
   Core.draw("{jsDivId}", obj, "{jsDrawOptions}");
}}

function script_load_{jsDivId}(src, on_error) {{
    let script = document.createElement('script');
    script.src = src;
    script.onload = function() {{ display_{jsDivId}(JSROOT); }};
    script.onerror = on_error;
    document.head.appendChild(script);
}}

if (typeof requirejs !== 'undefined') {{

    // We are in jupyter notebooks, use require.js which should be configured already
    requirejs.config({{
       paths: {{ 'JSRootCore' : [ 'scripts/JSRoot.core', 'https://root.cern/js/6.1.0/scripts/JSRoot.core.min', 'https://jsroot.gsi.de/6.1.0/scripts/JSRoot.core.min' ] }}
    }})(['JSRootCore'],  function(Core) {{<commit_msg>[jupyter] do not forget remove failed script element before loading next<commit_after># -*- coding:utf-8 -*-

#-----------------------------------------------------------------------------
#  Author: <NAME> <<EMAIL>> CERN
#-----------------------------------------------------------------------------

################################################################################
# Copyright (C) 1995-2020, <NAME> and <NAME>.                      #
# All rights reserved.                                                         #
#                                                                              #
# For the licensing terms see $ROOTSYS/LICENSE.                                #
# For the list of contributors see $ROOTSYS/README/CREDITS.                    #
################################################################################


from __future__ import print_function

import os
import sys
import select
import tempfile
import pty
import itertools
import re
import fnmatch
import time
from datetime import datetime
from hashlib import sha1
from contextlib import contextmanager
from subprocess import check_output
from IPython import get_ipython
from IPython.display import HTML
from IPython.core.extensions import ExtensionManager
import IPython.display
import ROOT
from JupyROOT.helpers import handlers

# We want iPython to take over the graphics
ROOT.gROOT.SetBatch()


cppMIME = 'text/x-c++src'

_jsMagicHighlight = """
Jupyter.CodeCell.options_default.highlight_modes['magic_{cppMIME}'] = {{'reg':[/^%%cpp/]}};
console.log("JupyROOT - %%cpp magic configured");
"""

_jsNotDrawableClassesPatterns = ["TEve*","TF3","TPolyLine3D"]

_jsCanvasWidth = 800
_jsCanvasHeight = 600
_jsCode = """

<div id="{jsDivId}"
     style="width: {jsCanvasWidth}px; height: {jsCanvasHeight}px">
</div>
<script>

function display_{jsDivId}(Core) {{
   let obj = Core.parse({jsonContent});
   Core.settings.HandleKeys = false;
   Core.draw("{jsDivId}", obj, "{jsDrawOptions}");
}}

function script_load_{jsDivId}(src, on_error) {{
    let script = document.createElement('script');
    script.src = src;
    script.onload = function() {{ display_{jsDivId}(JSROOT); }};
    script.onerror = function() {{ script.remove(); on_error(); }};
    document.head.appendChild(script);
}}

if (typeof requirejs !== 'undefined') {{

    // We are in jupyter notebooks, use require.js which should be configured already
    requirejs.config({{
       paths: {{ 'JSRootCore' : [ 'scripts/JSRoot.core', 'https://root.cern/js/6.1.0/scripts/JSRoot.core.min', 'https://jsroot.gsi.de/6.1.0/scripts/JSRoot.core.min' ] }}
    }})(['JSRootCore'],  function(Core) {{
{'fraction_non_alphanumeric': 0.23638803680981596, 'fraction_numerical': 0.009202453987730062, 'mean_word_length': 2.617891816920943, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2553250', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1409, 'n_words': 346}