'Internal implementation to handle special-casing patch events
on ``ColumnDataSource`` columns.
Normally any changes to the ``.data`` dict attribute on a
``ColumnDataSource`` triggers a notification, causing all of the data
to be synchronized between server and clients.
The ``.patch`` method on column data sources exists to provide a
more efficient way to perform patching (i.e. random access) updates
to a data source, without having to perform a full synchronization,
which would needlessly re-send all the data.
To accomplish this, this function bypasses the wrapped methods on
``PropertyValueDict`` and uses the unwrapped versions on the dict
superclass directly. It then explicitly makes a notification, adding
a special ``ColumnsPatchedEvent`` hint to the message containing
only the small patched data that BokehJS needs in order to efficiently
synchronize.
.. warning::
This function assumes the integrity of ``patches`` has already
been verified.'

def _patch(self, doc, source, patches, setter=None):

    import numpy as np
    old = self._saved_copy()
    for (name, patch) in patches.items():
        for (ind, value) in patch:
            if isinstance(ind, (int, slice)):
                self[name][ind] = value
            else:
                shape = self[name][ind[0]][ind[1:]].shape
                self[name][ind[0]][ind[1:]] = np.array(value, copy=False).reshape(shape)
    from ...server.events import ColumnsPatchedEvent
    self._notify_owners(old, hint=ColumnsPatchedEvent(doc, source, patches, setter))
