def _pivot_row(T, pivcol, phase, tol=<NUM_LIT>):
if phase == <NUM_LIT:1>:<EOL><INDENT>k = <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>k = <NUM_LIT:1><EOL><DEDENT>ma = np.ma.masked_where(T[:-k, pivcol] <= tol, T[:-k, pivcol], copy=False)<EOL>if ma.count() == <NUM_LIT:0>:<EOL><INDENT>return False, np.nan<EOL><DEDENT>mb = np.ma.masked_where(T[:-k, pivcol] <= tol, T[:-k, -<NUM_LIT:1>], copy=False)<EOL>q = mb / ma<EOL>return True, np.ma.where(q == q.min())[<NUM_LIT:0>][<NUM_LIT:0>]<EOL>
Given a linear programming simplex tableau, determine the row for the
pivot operation.

Parameters
----------
T : 2D ndarray
    The simplex tableau.
pivcol : int
    The index of the pivot column.
phase : int
    The phase of the simplex algorithm (1 or 2).
tol : float
    Elements in the pivot column smaller than tol will not be considered
    for pivoting.  Nominally this value is zero, but numerical issues
    cause a tolerance about zero to be necessary.

Returns
-------
status: bool
    True if a suitable pivot row was found, otherwise False.  A return
    of False indicates that the linear programming problem is unbounded.
row: int
    The index of the row of the pivot element.  If status is False, row
    will be returned as nan.