|佐藤 郁弥||M, 2回目発表||ソフトウェア工学||松本 健一, 飯田 元, 石尾 隆, Raula Gaikovina Kula, 嶋利 一真|
title: Comparing Execution Traces of Jupyter Notebook for Checking Correctness of Refactoring
abstract: Jupyter Notebook is a popular tool for writing data analysis programs. Prior work showed that Jupyter Notebook users often duplicate their python code to try their hypothesis quickly. While such code clones can be removed by Extract Function refactoring later, users have to check that the output of a notebook is unaffected by the refactoring. However, users may not be able to compare execution results of a notebook before and after refactoring because non-textual output in Jupyter Notebook are fragile; for example, each of executions produce non-identical graphical images even though they look the same. To address this issue, we propose a method to automatically compare API calls to execute a Jupyter Notebook in addition to the textual output, while ignoring non-textual output. Our key assumption is that the same API calls with the same parameters produce the same results even if their details are non-identical. To demonstrate the effectiveness of the approach, we implemented an automatic tool for Jupyter Notebook that extracts a function from code clones and automatically checks the correctness. Using the tool, we have extracted functions from 3,995 cells in 520 Jupyter Notebook files. 142 out of 520 Notebook files are executable. Our tool compared API calls to check the correctness for 88 Notebook files, while a simple textual comparison could check 22 Notebook files.