이 할 수있는 해키 방법은 (보통 ~/.jupyter/custom/custom.js
에 위치)를 custom.js 파일을 통해입니다
도구 모음이 here 위치하고 있으며 그것이 내가 오프이 대답을 기반 무엇되어있는 버튼을 만드는 방법의 예. 활성화 버튼을 누르면 모든 셀에 원하는 마법의 문자열 형식이 추가되고 비활성화 버튼은 str.replace
을 사용하여 "해제"합니다.
define([
'base/js/namespace',
'base/js/events'
], function(Jupyter, events) {
events.on('app_initialized.NotebookApp', function(){
Jupyter.toolbar.add_buttons_group([
{
'label' : 'enable timing for all cells',
'icon' : 'fa-clock-o', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
'callback': function() {
var cells = Jupyter.notebook.get_cells();
cells.forEach(function(cell) {
var prev_text = cell.get_text();
if(prev_text.indexOf('%%time\n%%timeit\n') === -1) {
var text = '%%time\n%%timeit\n' + prev_text;
cell.set_text(text);
}
});
}
},
{
'label' : 'disable timing for all cells',
'icon' : 'fa-stop-circle-o', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
'callback': function() {
var cells = Jupyter.notebook.get_cells();
cells.forEach(function(cell) {
var prev_text = cell.get_text();
var text = prev_text.replace('%%time\n%%timeit\n','');
cell.set_text(text);
});
}
}
// add more button here if needed.
]);
});
});
환상적인 답변이지만 회사의 Jupyter 서버에서 실행 중이며 테스트하기 위해 'custom.js'에 대한 액세스 권한이 있는지 확실하지 않습니다. – abeboparebop
마지막으로 다른 시스템에서이를 테스트 할 수있는 기회를 얻었습니다. 서면으로, 대답은별로 의미가 없습니다 - 모든 세포에서'%% time'과'%% timeit'을 모두 사용하는 것은 유용하지 않습니다. 그래서 당신의 대답은'%% time \ n %% timeit \ n'이라고 말하면서 그것을 %% time \ n으로 대체했습니다. 그러나 일반적인 접근 방식은 잘 작동합니다. 감사! – abeboparebop
한편, 'fa-clock-o'아이콘은 작동하지만'fa-stop-circle-o'는 작동하지 않습니다. Jupyter 코어 버전 4.2.0. – abeboparebop