MCPcopy
hub / github.com/jupytext/jupytext / compare

Function compare

src/jupytext/compare.py:31–47  ·  view source on GitHub ↗

Compare two strings, lists or dict-like objects

(actual, expected, actual_name="actual", expected_name="expected", return_diff=False)

Source from the content-addressed store, hash-verified

29
30
31def compare(actual, expected, actual_name="actual", expected_name="expected", return_diff=False):
32 """Compare two strings, lists or dict-like objects"""
33 if actual != expected:
34 diff = difflib.unified_diff(
35 _multilines(expected),
36 _multilines(actual),
37 expected_name,
38 actual_name,
39 lineterm="",
40 )
41 if expected_name == "" and actual_name == "":
42 diff = list(diff)[2:]
43 diff = "\n".join(diff)
44 if return_diff:
45 return diff
46 raise AssertionError("\n" + diff)
47 return "" if return_diff else None
48
49
50def filtered_cell(cell, preserve_outputs, cell_metadata_filter):

Calls 1

_multilinesFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…