Skip to content

JsMVA: use latest JSROOT, use /static path to load code #12484

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def __bookDNN(optString):

__BookDNNHelper = __bookDNN
clear_output()
JPyInterface.JsDraw.InsertCSS("NetworkDesigner.min.css")
JPyInterface.JsDraw.InsertCSS("NetworkDesigner.css")
JPyInterface.JsDraw.Draw("", "NetworkDesigner", True)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ def captureObjects(*args):
## Class for creating the output scripts and inserting them to cell output
class JsDraw:
## Base repository
__jsMVARepo = "https://root.cern/js/jsmva/latest"
# __jsMVARepo = "https://root.cern/js/jsmva/latest"
__jsMVARepo = "/static/mva"

## String containing the link to JavaScript files
__jsMVASourceDir = __jsMVARepo + "/js"
Expand Down Expand Up @@ -230,7 +231,10 @@ class JsDraw:
<script type="text/javascript">
require.config({
paths: {
'JsMVA':'$PATH/JsMVA.min'
'JsMVA':'$PATH/JsMVA',
'nn': '$PATH/NeuralNetwork',
'dtree': '$PATH/DecisionTree',
'NetworkDesigner': '$PATH/NetworkDesigner'
}
});
</script>
Expand Down Expand Up @@ -259,13 +263,10 @@ class JsDraw:
## Inserts initialization codes to notebook
@staticmethod
def InitJsMVA():
display(
HTML(
JsDraw.__JsMVAInitCode.substitute(
{"PATH": JsDraw.__jsMVASourceDir, "CSSFile": JsDraw.__jsMVACSSDir + "/TMVAHTMLOutput.min.css"}
)
)
)
display(HTML(JsDraw.__JsMVAInitCode.substitute({
'PATH': JsDraw.__jsMVASourceDir,
'CSSFile': JsDraw.__jsMVACSSDir + '/TMVAHTMLOutput.css'
})))

## Inserts the draw area and drawing JavaScript to output
# @param obj ROOT object (will be converted to JSON) or JSON string containing the data to be drawed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, shell):
@magic_arguments()
@argument("arg", nargs="?", default="on", help="Enable/Disable JavaScript visualisation for TMVA")
def jsmva(self, line):
from JsMVA.JPyInterface import functions
from ROOT.JsMVA.JPyInterface import functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed in master branch (using a relative import):
from .JPyInterface import functions


args = parse_argstring(self.jsmva, line)
if args.arg == "on":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def __transformOneGroup(self, firstLine):
if (Header == None and EmptyHeader == None) or j == 0:
if j != 0:
processed_lines += 1
self.iterLines.next()
next(self.iterLines)
tmp_str += "<tr>"
if DatasetName or NumEvents or VariableMeanHeader:
if DatasetName:
Expand All @@ -256,17 +256,17 @@ def __transformOneGroup(self, firstLine):
fLine = VariableMeanHeader
count, tmp = func(fLine, self.lineIndex + j, len(self.lines) - self.lineIndex - j)
for x in range(count):
lineIter.next()
self.iterLines.next()
next(lineIter)
next(self.iterLines)
tmp_str += self.__processGroupContentLine(tmp)
elif CorrelationMatrixHeader:
self.iterLines.next()
lineIter.next()
next(self.iterLines)
next(lineIter)
ik = 1
matrixLines = []
while True:
self.iterLines.next()
lineIter.next()
next(self.iterLines)
next(lineIter)
ik += 1
if self.__isEmpty(self.lines[self.lineIndex + j + ik]):
break
Expand Down Expand Up @@ -297,8 +297,8 @@ def __transformOneGroup(self, firstLine):
if EndWelcome or re.match(r"[\s_/|]*", nextline) == None:
break
kw += 1
self.iterLines.next()
lineIter.next()
next(self.iterLines)
next(lineIter)
tmp_str += "<td><b>" + WelcomeHeader.group(1) + "</b></td></tr>"
tmp_str += "<tr><td><img src='https://rawgit.com/root-project/root/master/tutorials/tmva/tmva_logo.svg' width='100%' /><br />"
tmp_str += "<center><b>" + EndWelcome.group(1) + "</b></center></td></tr>"
Expand Down Expand Up @@ -376,9 +376,9 @@ def transform(self, output, error):
r"^\s*-*\s*(<\w+>\s*)*\s*(\w+.*\s+)(\s+)(:)\s*(.*)", self.lines[self.lineIndex + kw], re.I
)
if Header:
self.iterLines.next()
next(self.iterLines)
break
self.iterLines.next()
next(self.iterLines)
if self.__isEmpty(nextline):
continue
lre = re.match(r"\s*:\s*(.*)", nextline)
Expand Down
1 change: 0 additions & 1 deletion etc/notebook/JsMVA/css/NetworkDesigner.min.css

This file was deleted.

1 change: 0 additions & 1 deletion etc/notebook/JsMVA/css/TMVAHTMLOutput.min.css

This file was deleted.

23 changes: 0 additions & 23 deletions etc/notebook/JsMVA/js/DecisionTree.min.js

This file was deleted.

Loading
Loading