schrodinger.models.diffy module

Need a diff in a jiffy? Use diffy!

schrodinger.models.diffy.get_diff(new_state, old_state)
schrodinger.models.diffy.get_diff(new_state: list, old_state)
schrodinger.models.diffy.get_diff(new_state: set, old_state)
schrodinger.models.diffy.get_diff(new_state: dict, old_state)

Given two states of an object, calculate what changed between them.

schrodinger.models.diffy.get_removed(new_state, old_state)
schrodinger.models.diffy.get_removed(new_state: set, old_state)
schrodinger.models.diffy.get_removed(new_state: list, old_state)
schrodinger.models.diffy.get_removed(new_state: dict, old_state)
schrodinger.models.diffy.get_added(new_state, old_state)
schrodinger.models.diffy.get_added(new_state: list, old_state)
schrodinger.models.diffy.get_added(new_state: set, old_state)
schrodinger.models.diffy.get_added(new_state: dict, old_state)
schrodinger.models.diffy.get_updated(new_state, old_state)
schrodinger.models.diffy.get_updated(new_state: dict, old_state)
schrodinger.models.diffy.get_moved(new_state, old_state)
schrodinger.models.diffy.get_moved(new_state: list, old_state)
class schrodinger.models.diffy.ListDiff(added, removed, moved)

Bases: tuple

__contains__(key, /)

Return key in self.

__len__()

Return len(self).

added

Alias for field number 0

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

moved

Alias for field number 2

removed

Alias for field number 1

schrodinger.models.diffy.get_diff_list(new_state, old_state)

Calculate what was added, removed, and moved between two states of a list.

Note that items are compared by identity not equality (ie is rather than ==).

Returns

A namedtuple describing what was added, removed, and moved between two lists. See get_added, get_removed, and get_moved more details.

Return type

ListDiff(set, set, set)

class schrodinger.models.diffy.SetDiff(added, removed)

Bases: tuple

__contains__(key, /)

Return key in self.

__len__()

Return len(self).

added

Alias for field number 0

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

removed

Alias for field number 1

schrodinger.models.diffy.get_diff_set(new_state, old_state)

Calculate what was added and removed between two states of a set.

Returns

A namedtuple describing what was added and removed.

Return type

SetDiff(set, set)

schrodinger.models.diffy.get_removed_set(new_state, old_state)

Calculate what was removed between two states of a set.

Return type

set

schrodinger.models.diffy.get_removed_list(new_state, old_state)
Returns

A set of tuples, each describing an item that was removed and and its index in old_state

Return type

set((object, int))

schrodinger.models.diffy.get_added_list(new_state, old_state)
Returns

A set of tuples, each describing an item that was added and and its index in new_state.

Return type

set((object, int))

schrodinger.models.diffy.get_added_set(new_state, old_state)

Calculate what was removed between two states of a set.

Return type

set

class schrodinger.models.diffy.DictDiff(added, removed, updated)

Bases: tuple

__contains__(key, /)

Return key in self.

__len__()

Return len(self).

added

Alias for field number 0

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

removed

Alias for field number 1

updated

Alias for field number 2

schrodinger.models.diffy.get_diff_dict(new_state, old_state)

Return dictionary items that have been added, removed, and updated.

Returns

A namedtuple describing what was added, removed, and moved between two dicts. See get_added, get_removed, and get_updated more details.

Return type

DictDiff(dict, dict, dict)

schrodinger.models.diffy.get_added_dict(new_state, old_state)
Returns

A dictionary with items in new_state but not in old_state.

schrodinger.models.diffy.get_removed_dict(new_state, old_state)
Returns

A dictionary with items in old_state but not in new_state.

schrodinger.models.diffy.get_updated_dict(new_state, old_state)
Returns

A dictionary with values that have changed from old_state to new_state. The values in the returned dictionary will be those from new_state.

schrodinger.models.diffy.get_moved_list(new_state, old_state)
Returns

A set of tuples, each describing an item that was moved and and its index in new_state

Return type

set((object, int))