当前位置: 首页>>代码示例>>Python>>正文


Python utils.compute_checksum函数代码示例

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


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


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