• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.compute_checksum函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nbgrader.utils.compute_checksum函数的典型用法代码示例。如果您正苦于以下问题:Python compute_checksum函数的具体用法?Python compute_checksum怎么用?Python compute_checksum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了compute_checksum函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_compute_checksum_cell_type

def test_compute_checksum_cell_type():
    # does the cell type make a difference?
    cell1 = create_grade_cell("hello", "code", "foo", 1)
    cell2 = create_grade_cell("hello", "markdown", "foo", 1)
    assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)

    cell1 = create_solution_cell("hello", "code", "foo")
    cell2 = create_solution_cell("hello", "markdown", "foo")
    assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:9,代码来源:test_utils.py


示例2: test_compute_checksum_identical

    def test_compute_checksum_identical(self):
        # is the same for two identical cells?
        cell1 = self._create_grade_cell("hello", "code", "foo", 1)
        cell2 = self._create_grade_cell("hello", "code", "foo", 1)
        assert_equal(utils.compute_checksum(cell1), utils.compute_checksum(cell2))

        cell1 = self._create_solution_cell("hello", "code")
        cell2 = self._create_solution_cell("hello", "code")
        assert_equal(utils.compute_checksum(cell1), utils.compute_checksum(cell2))
开发者ID:redSlug,项目名称:nbgrader,代码行数:9,代码来源:test_utils.py


示例3: test_compute_checksum_identical

def test_compute_checksum_identical():
    # is the same for two identical cells?
    cell1 = create_grade_cell("hello", "code", "foo", 1)
    cell2 = create_grade_cell("hello", "code", "foo", 1)
    assert utils.compute_checksum(cell1) == utils.compute_checksum(cell2)

    cell1 = create_solution_cell("hello", "code", "foo")
    cell2 = create_solution_cell("hello", "code", "foo")
    assert utils.compute_checksum(cell1) == utils.compute_checksum(cell2)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:9,代码来源:test_utils.py


示例4: test_compute_checksum_cell_type

    def test_compute_checksum_cell_type(self):
        # does the cell type make a difference?
        cell1 = self._create_grade_cell("hello", "code", "foo", 1)
        cell2 = self._create_grade_cell("hello", "markdown", "foo", 1)
        assert_not_equal(utils.compute_checksum(cell1), utils.compute_checksum(cell2))

        cell1 = self._create_solution_cell("hello", "code")
        cell2 = self._create_solution_cell("hello", "markdown")
        assert_not_equal(utils.compute_checksum(cell1), utils.compute_checksum(cell2))
开发者ID:redSlug,项目名称:nbgrader,代码行数:9,代码来源:test_utils.py


示例5: test_checksum_solution_source

    def test_checksum_solution_source(self, preprocessor):
        """Test that the checksum is computed for solution cells with different sources"""
        cell1 = create_solution_cell("a", "code")
        cell1 = preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = create_solution_cell("b", "code")
        cell2 = preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert cell1.metadata.nbgrader["checksum"] == compute_checksum(cell1)
        assert cell2.metadata.nbgrader["checksum"] == compute_checksum(cell2)
        assert cell1.metadata.nbgrader["checksum"] != cell2.metadata.nbgrader["checksum"]
开发者ID:haraldschilly,项目名称:nbgrader,代码行数:10,代码来源:test_computechecksums.py


示例6: test_checksum_grade_id

    def test_checksum_grade_id(self, preprocessor):
        """Test that the checksum is computed for grade cells with different ids"""
        cell1 = create_grade_cell("", "code", "foo", 1)
        cell1 = preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = create_grade_cell("", "code", "bar", 1)
        cell2 = preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert cell1.metadata.nbgrader["checksum"] == compute_checksum(cell1)
        assert cell2.metadata.nbgrader["checksum"] == compute_checksum(cell2)
        assert cell1.metadata.nbgrader["checksum"] != cell2.metadata.nbgrader["checksum"]
开发者ID:haraldschilly,项目名称:nbgrader,代码行数:10,代码来源:test_computechecksums.py


示例7: test_checksum_locked_cell_type

    def test_checksum_locked_cell_type(self, preprocessor):
        """Test that the checksum is computed for locked cells"""
        cell1 = create_locked_cell("", "code", "foo")
        cell1 = preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = create_locked_cell("", "markdown", "foo")
        cell2 = preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert cell1.metadata.nbgrader["checksum"] == compute_checksum(cell1)
        assert cell2.metadata.nbgrader["checksum"] == compute_checksum(cell2)
        assert cell1.metadata.nbgrader["checksum"] != cell2.metadata.nbgrader["checksum"]
开发者ID:gustavoasoares,项目名称:nbgrader,代码行数:10,代码来源:test_computechecksums.py


示例8: test_checksum_solution_source

    def test_checksum_solution_source(self):
        """Test that the checksum is computed for solution cells with different sources"""
        cell1 = self._create_solution_cell("a", "code")
        cell1 = self.preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = self._create_solution_cell("b", "code")
        cell2 = self.preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert_equal(cell1.metadata.nbgrader["checksum"], compute_checksum(cell1))
        assert_equal(cell2.metadata.nbgrader["checksum"], compute_checksum(cell2))
        assert_not_equal(cell1.metadata.nbgrader["checksum"], cell2.metadata.nbgrader["checksum"])
开发者ID:redSlug,项目名称:nbgrader,代码行数:10,代码来源:test_computechecksums.py


示例9: test_checksum_grade_id

    def test_checksum_grade_id(self):
        """Test that the checksum is computed for grade cells with different ids"""
        cell1 = self._create_grade_cell("", "code", "foo", 1)
        cell1 = self.preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = self._create_grade_cell("", "code", "bar", 1)
        cell2 = self.preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert_equal(cell1.metadata.nbgrader["checksum"], compute_checksum(cell1))
        assert_equal(cell2.metadata.nbgrader["checksum"], compute_checksum(cell2))
        assert_not_equal(cell1.metadata.nbgrader["checksum"], cell2.metadata.nbgrader["checksum"])
开发者ID:redSlug,项目名称:nbgrader,代码行数:10,代码来源:test_computechecksums.py


示例10: test_compute_checksum_grade_id

    def test_compute_checksum_grade_id(self):
        # does the grade id make a difference (only for grade cells)?
        cell1 = self._create_grade_cell("hello", "code", "foo", 1)
        cell2 = self._create_grade_cell("hello", "code", "bar", 1)
        assert_not_equal(utils.compute_checksum(cell1), utils.compute_checksum(cell2))

        cell1 = self._create_grade_cell("hello", "code", "foo", 1)
        cell2 = self._create_grade_cell("hello", "code", "bar", 1)
        cell1.metadata.nbgrader["grade"] = False
        cell2.metadata.nbgrader["grade"] = False
        assert_equal(utils.compute_checksum(cell1), utils.compute_checksum(cell2))
开发者ID:redSlug,项目名称:nbgrader,代码行数:11,代码来源:test_utils.py


示例11: test_checksum_grade_and_solution

    def test_checksum_grade_and_solution(self, preprocessor):
        """Test that a checksum is created for grade cells that are also solution cells"""
        cell1 = create_grade_cell("", "markdown", "foo", 1)
        cell1 = preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = create_grade_cell("", "markdown", "foo", 1)
        cell2.metadata.nbgrader["solution"] = True
        cell2 = preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert cell1.metadata.nbgrader["checksum"] == compute_checksum(cell1)
        assert cell2.metadata.nbgrader["checksum"] == compute_checksum(cell2)
        assert cell1.metadata.nbgrader["checksum"] != cell2.metadata.nbgrader["checksum"]
开发者ID:haraldschilly,项目名称:nbgrader,代码行数:11,代码来源:test_computechecksums.py


示例12: test_compute_checksum_grade_id

def test_compute_checksum_grade_id():
    # does the grade id make a difference (only for grade cells)?
    cell1 = create_grade_cell("hello", "code", "foo", 1)
    cell2 = create_grade_cell("hello", "code", "bar", 1)
    assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)

    cell1 = create_grade_cell("hello", "code", "foo", 1)
    cell2 = create_grade_cell("hello", "code", "bar", 1)
    cell1.metadata.nbgrader["grade"] = False
    cell2.metadata.nbgrader["grade"] = False
    assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:11,代码来源:test_utils.py


示例13: test_compute_checksum_points

def test_compute_checksum_points():
    # does the number of points make a difference (only for grade cells)?
    cell1 = create_grade_cell("hello", "code", "foo", 2)
    cell2 = create_grade_cell("hello", "code", "foo", 1)
    assert utils.compute_checksum(cell1) != utils.compute_checksum(cell2)

    cell1 = create_grade_cell("hello", "code", "foo", 2)
    cell2 = create_grade_cell("hello", "code", "foo", 1)
    cell1.metadata.nbgrader["grade"] = False
    cell2.metadata.nbgrader["grade"] = False
    assert utils.compute_checksum(cell1) == utils.compute_checksum(cell2)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:11,代码来源:test_utils.py


示例14: test_checksum_grade_and_solution

    def test_checksum_grade_and_solution(self):
        """Test that a checksum is created for grade cells that are also solution cells"""
        cell1 = self._create_grade_cell("", "markdown", "foo", 1)
        cell1 = self.preprocessor.preprocess_cell(cell1, {}, 0)[0]
        cell2 = self._create_grade_cell("", "markdown", "foo", 1)
        cell2.metadata.nbgrader["solution"] = True
        cell2 = self.preprocessor.preprocess_cell(cell2, {}, 0)[0]

        assert_equal(cell1.metadata.nbgrader["checksum"], compute_checksum(cell1))
        assert_equal(cell2.metadata.nbgrader["checksum"], compute_checksum(cell2))
        assert_not_equal(cell1.metadata.nbgrader["checksum"], cell2.metadata.nbgrader["checksum"])
开发者ID:redSlug,项目名称:nbgrader,代码行数:11,代码来源:test_computechecksums.py


示例15: preprocess_cell

    def preprocess_cell(self, cell, resources, cell_index):
        grade_id = cell.metadata.get('nbgrader', {}).get('grade_id', None)
        if grade_id is None:
            return cell, resources

        try:
            source_cell = self.gradebook.find_source_cell(
                grade_id,
                self.notebook_id,
                self.assignment_id)
        except MissingEntry:
            self.log.warning("Cell '{}' does not exist in the database".format(grade_id))
            del cell.metadata.nbgrader['grade_id']
            return cell, resources

        # check that the cell type hasn't changed
        if cell.cell_type != source_cell.cell_type:
            self.report_change(grade_id, "cell_type", source_cell.cell_type, cell.cell_type)
            self.update_cell_type(cell, source_cell.cell_type)

        # check that the locked status hasn't changed
        if utils.is_locked(cell) != source_cell.locked:
            self.report_change(grade_id, "locked", source_cell.locked, utils.is_locked(cell))
            cell.metadata.nbgrader["locked"] = source_cell.locked

        # if it's a grade cell, check that the max score hasn't changed
        if utils.is_grade(cell):
            grade_cell = self.gradebook.find_grade_cell(
                grade_id,
                self.notebook_id,
                self.assignment_id)
            old_points = float(grade_cell.max_score)
            new_points = float(cell.metadata.nbgrader["points"])

            if old_points != new_points:
                self.report_change(grade_id, "points", old_points, new_points)
                cell.metadata.nbgrader["points"] = old_points

        # always update the checksum, just in case
        cell.metadata.nbgrader["checksum"] = source_cell.checksum

        # if it's locked, check that the checksum hasn't changed
        if source_cell.locked:
            old_checksum = source_cell.checksum
            new_checksum = utils.compute_checksum(cell)
            if old_checksum != new_checksum:
                self.report_change(grade_id, "checksum", old_checksum, new_checksum)
                cell.source = source_cell.source
                # double check the the checksum is correct now
                if utils.compute_checksum(cell) != source_cell.checksum:
                    raise RuntimeError("Inconsistent checksums for cell {}".format(source_cell.name))

        return cell, resources
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:53,代码来源:overwritecells.py


示例16: test_overwrite_locked_checksum

    def test_overwrite_locked_checksum(self, preprocessors, resources):
        """Is the checksum overwritten for locked cells?"""
        cell = create_locked_cell("hello", "code", "foo")
        cell.metadata.nbgrader["checksum"] = compute_checksum(cell)
        nb = new_notebook()
        nb.cells.append(cell)
        nb, resources = preprocessors[0].preprocess(nb, resources)

        cell.metadata.nbgrader["checksum"] = "1234"
        nb, resources = preprocessors[1].preprocess(nb, resources)

        assert cell.metadata.nbgrader["checksum"] == compute_checksum(cell)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:12,代码来源:test_overwritecells.py


示例17: preprocess_cell

    def preprocess_cell(self, cell, resources, cell_index):
        if not utils.is_grade(cell):
            return cell, resources

        # if we're ignoring checksums, then remove the checksum from the
        # cell metadata
        if self.ignore_checksums and 'checksum' in cell.metadata.nbgrader:
            del cell.metadata.nbgrader['checksum']

        # verify checksums of cells
        if not utils.is_solution(cell) and 'checksum' in cell.metadata.nbgrader:
            old_checksum = cell.metadata.nbgrader['checksum']
            new_checksum = utils.compute_checksum(cell)
            if old_checksum != new_checksum:
                resources['nbgrader']['checksum_mismatch'].append(cell_index)

        # if it's a grade cell, the add a grade
        score, max_score = utils.determine_grade(cell)

        # it's a markdown cell, so we can't do anything
        if score is None:
            pass
        elif score < max_score:
            resources['nbgrader']['failed_cells'].append(cell_index)
        else:
            resources['nbgrader']['passed_cells'].append(cell_index)

        return cell, resources
开发者ID:redSlug,项目名称:nbgrader,代码行数:28,代码来源:displayautogrades.py


示例18: test_determine_grade_markdown_grade_and_solution

def test_determine_grade_markdown_grade_and_solution():
    cell = create_grade_and_solution_cell('test', "markdown", "foo", 10)
    cell.metadata.nbgrader['checksum'] = utils.compute_checksum(cell)
    assert utils.determine_grade(cell) == (0, 10)

    cell = create_grade_and_solution_cell('test', "markdown", "foo", 10)
    cell.source = 'test!'
    assert utils.determine_grade(cell) == (None, 10)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:8,代码来源:test_utils.py


示例19: test_determine_grade_code_grade_and_solution

def test_determine_grade_code_grade_and_solution():
    cell = create_grade_and_solution_cell('test', "code", "foo", 10)
    cell.metadata.nbgrader['checksum'] = utils.compute_checksum(cell)
    cell.outputs = []
    assert utils.determine_grade(cell) == (0, 10)

    cell.outputs = [new_output('error', ename="NotImplementedError", evalue="", traceback=["error"])]
    cell.source = 'test!'
    assert utils.determine_grade(cell) == (None, 10)
开发者ID:vanceeasleaf,项目名称:nbgrader,代码行数:9,代码来源:test_utils.py


示例20: preprocess_cell

    def preprocess_cell(self, cell, resources, cell_index):
        if utils.is_grade(cell):
            grade_cell = self.gradebook.find_grade_cell(
                cell.metadata.nbgrader["grade_id"],
                self.notebook_id,
                self.assignment_id)

            cell.metadata.nbgrader['points'] = grade_cell.max_score

            # we only want the source and checksum for non-solution cells
            if not utils.is_solution(cell):
                old_checksum = grade_cell.checksum
                new_checksum = utils.compute_checksum(cell)

                if old_checksum != new_checksum:
                    self.log.warning("Checksum for grade cell %s has changed!", grade_cell.name)

                cell.source = grade_cell.source
                cell.metadata.nbgrader['checksum'] = grade_cell.checksum
                self.update_cell_type(cell, grade_cell.cell_type)

            self.log.debug("Overwrote grade cell %s", grade_cell.name)

        if utils.is_solution(cell):
            solution_cell = self.gradebook.find_solution_cell(
                self.comment_index,
                self.notebook_id,
                self.assignment_id)

            old_checksum = solution_cell.checksum
            new_checksum = utils.compute_checksum(cell)

            if cell.cell_type != solution_cell.cell_type:
                self.log.warning("Cell type for solution cell %s has changed!", solution_cell.name)

            cell.metadata.nbgrader['checksum'] = solution_cell.checksum
            self.update_cell_type(cell, solution_cell.cell_type)

            self.log.debug("Overwrote solution cell #%s", self.comment_index)

            self.comment_index += 1

        return cell, resources
开发者ID:haraldschilly,项目名称:nbgrader,代码行数:43,代码来源:overwritecells.py



注:本文中的nbgrader.utils.compute_checksum函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nbt.load函数代码示例发布时间:2022-05-27
下一篇:
Python tests.run_command函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap