def _align_series(self, indexer, ser, multiindex_indexer=False):
if isinstance(indexer, (slice, np.ndarray, list, Index)):<EOL><INDENT>indexer = tuple([indexer])<EOL><DEDENT>if isinstance(indexer, tuple):<EOL><INDENT>def ravel(i):<EOL><INDENT>return i.ravel() if isinstance(i, np.ndarray) else i<EOL><DEDENT>indexer = tuple(map(ravel, indexer))<EOL>aligners = [not com.is_null_slice(idx) for idx in indexer]<EOL>sum_aligners = sum(aligners)<EOL>single_aligner = sum_aligners == <NUM_LIT:1><EOL>is_frame = self.obj.ndim == <NUM_LIT:2><EOL>is_panel = self.obj.ndim >= <NUM_LIT:3><EOL>obj = self.obj<EOL>if is_frame:<EOL><INDENT>single_aligner = single_aligner and aligners[<NUM_LIT:0>]<EOL><DEDENT>elif is_panel:<EOL><INDENT>single_aligner = (single_aligner and<EOL>(aligners[<NUM_LIT:1>] or aligners[<NUM_LIT:2>]))<EOL><DEDENT>if (sum_aligners == self.ndim and<EOL>all(is_sequence(_) for _ in indexer)):<EOL><INDENT>ser = ser.reindex(obj.axes[<NUM_LIT:0>][indexer[<NUM_LIT:0>]], copy=True)._values<EOL>if len(indexer) > <NUM_LIT:1> and not multiindex_indexer:<EOL><INDENT>len_indexer = len(indexer[<NUM_LIT:1>])<EOL>ser = np.tile(ser, len_indexer).reshape(len_indexer, -<NUM_LIT:1>).T<EOL><DEDENT>return ser<EOL><DEDENT>for i, idx in enumerate(indexer):<EOL><INDENT>ax = obj.axes[i]<EOL>if is_sequence(idx) or isinstance(idx, slice):<EOL><INDENT>if single_aligner and com.is_null_slice(idx):<EOL><INDENT>continue<EOL><DEDENT>new_ix = ax[idx]<EOL>if not is_list_like_indexer(new_ix):<EOL><INDENT>new_ix = Index([new_ix])<EOL><DEDENT>else:<EOL><INDENT>new_ix = Index(new_ix)<EOL><DEDENT>if ser.index.equals(new_ix) or not len(new_ix):<EOL><INDENT>return ser._values.copy()<EOL><DEDENT>return ser.reindex(new_ix)._values<EOL><DEDENT>elif single_aligner and is_frame:<EOL><INDENT>ax = self.obj.axes[<NUM_LIT:1>]<EOL>if ser.index.equals(ax) or not len(ax):<EOL><INDENT>return ser._values.copy()<EOL><DEDENT>return ser.reindex(ax)._values<EOL><DEDENT>elif single_aligner:<EOL><INDENT>broadcast = []<EOL>for n, labels in enumerate(self.obj._get_plane_axes(i)):<EOL><INDENT>if len(labels & ser.index):<EOL><INDENT>ser = ser.reindex(labels)<EOL><DEDENT>else:<EOL><INDENT>broadcast.append((n, len(labels)))<EOL><DEDENT><DEDENT>ser = ser._values.copy()<EOL>for (axis, l) in broadcast:<EOL><INDENT>shape = [-<NUM_LIT:1>] * (len(broadcast) + <NUM_LIT:1>)<EOL>shape[axis] = l<EOL>ser = np.tile(ser, l).reshape(shape)<EOL><DEDENT>if self.obj.ndim == <NUM_LIT:3>:<EOL><INDENT>ser = ser.T<EOL><DEDENT>return ser<EOL><DEDENT><DEDENT><DEDENT>elif is_scalar(indexer):<EOL><INDENT>ax = self.obj._get_axis(<NUM_LIT:1>)<EOL>if ser.index.equals(ax):<EOL><INDENT>return ser._values.copy()<EOL><DEDENT>return ser.reindex(ax)._values<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL>
Parameters
----------
indexer : tuple, slice, scalar
    The indexer used to get the locations that will be set to
    `ser`

ser : pd.Series
    The values to assign to the locations specified by `indexer`

multiindex_indexer : boolean, optional
    Defaults to False. Should be set to True if `indexer` was from
    a `pd.MultiIndex`, to avoid unnecessary broadcasting.


Returns:
--------
`np.array` of `ser` broadcast to the appropriate shape for assignment
to the locations selected by `indexer`