Skip to content

Commit 17182ef

Browse files
committed
[roottest] Update Python version in reference notebooks in JupyROOT test
We only support Python 3 at this point. By updating the reference notebooks to have the Python 3 kernel in the metainfo, we don't need to do extra steps in the `nbdiff.py` script, mapping injecting the `python3` kernel name manually.
1 parent 8a526e4 commit 17182ef

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

roottest/python/JupyROOT/importROOT.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
],
1515
"metadata": {
1616
"kernelspec": {
17-
"display_name": "Python 2",
17+
"display_name": "Python 3",
1818
"language": "python",
19-
"name": "python2"
19+
"name": "python3"
2020
},
2121
"language_info": {
2222
"codemirror_mode": {
2323
"name": "ipython",
24-
"version": 2
24+
"version": 3
2525
},
2626
"file_extension": ".py",
2727
"mimetype": "text/x-python",
2828
"name": "python",
2929
"nbconvert_exporter": "python",
30-
"pygments_lexer": "ipython2",
31-
"version": "2.7.6"
30+
"pygments_lexer": "ipython3",
31+
"version": "3.11.9"
3232
}
3333
},
3434
"nbformat": 4,

roottest/python/JupyROOT/nbdiff.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88

99
# Replace the criterion according to which a line shall be skipped
10-
def customLineJunkFilter(line):
10+
def should_keep_line(line):
1111
# Skip the banner and empty lines
12-
junkLines = [
12+
skip_patterns = [
1313
"Info in <TUnixSystem::ACLiC",
1414
"Info in <TMacOSXSystem::ACLiC",
1515
"FAILED TO establish the default connection to the WindowServer",
@@ -18,8 +18,8 @@ def customLineJunkFilter(line):
1818
' "execution_count":',
1919
"libclang_rt.asan-",
2020
]
21-
for junkLine in junkLines:
22-
if junkLine in line:
21+
for pattern in skip_patterns:
22+
if pattern in line:
2323
return False
2424
return True
2525

@@ -44,7 +44,7 @@ def removeCellMetadata(lines):
4444

4545
def getFilteredLines(fileName):
4646
with open(fileName) as f:
47-
filteredLines = list(filter(customLineJunkFilter, f.readlines()))
47+
filteredLines = list(filter(should_keep_line, f.readlines()))
4848

4949
# Sometimes the jupyter server adds a new line at the end of the notebook
5050
# and nbconvert does not.
@@ -136,10 +136,7 @@ def addEtcToEnvironment(inNBDirName):
136136
def getKernelName(inNBName):
137137
with open(inNBName) as f:
138138
nbj = json.load(f)
139-
if nbj["metadata"]["kernelspec"]["language"] == "python":
140-
return "python3"
141-
else: # we support only Python and C++
142-
return "root"
139+
return nbj["metadata"]["kernelspec"]["name"]
143140

144141

145142
def canReproduceNotebook(inNBName, needsCompare):

roottest/python/JupyROOT/simpleCppMagic.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,21 @@
9090
],
9191
"metadata": {
9292
"kernelspec": {
93-
"display_name": "Python 2",
93+
"display_name": "Python 3",
9494
"language": "python",
95-
"name": "python2"
95+
"name": "python3"
9696
},
9797
"language_info": {
9898
"codemirror_mode": {
9999
"name": "ipython",
100-
"version": 2
100+
"version": 3
101101
},
102102
"file_extension": ".py",
103103
"mimetype": "text/x-python",
104104
"name": "python",
105105
"nbconvert_exporter": "python",
106-
"pygments_lexer": "ipython2",
107-
"version": "2.7.6"
106+
"pygments_lexer": "ipython3",
107+
"version": "3.11.9"
108108
}
109109
},
110110
"nbformat": 4,

0 commit comments

Comments
 (0)