def fit_v2m(self, distribution):
    '\n        computes the best fit of the bivariate von Mises function in the\n        semi-circle.\n        Return the tuple:\n        (\n            orientation1_preference, orientation1_selectivity, goodness_of_fit1,\n            orientation2_preference, orientation2_selectivity, goodness_of_fit2\n        )\n        See fit_vm() for considerations about selectivity and goodness_of_fit\n        '
    null = (0, 0, 0, 0, 0, 0)
    if unavailable_scipy_optimize:
        if (not VonMisesStatisticFn.user_warned_if_unavailable):
            param.Parameterized().warning('scipy.optimize not available, dummy von Mises fit')
            VonMisesStatisticFn.user_warned_if_unavailable = True
        self.fit_exit_code = 3
        return null
    to_pi = (np.pi / distribution.axis_range)
    x = (to_pi * np.array(distribution.bins()))
    n = len(x)
    if (n < 9):
        param.Parameterized().warning('no bimodal von Mises fit possible with less than 8 bins')
        self.fit_exit_code = (- 1)
        return null
    y = np.array(distribution.values())
    if (y.std() < self.noise_level):
        self.fit_exit_code = 1
        return null
    rn = (self.noise_level * np.random.random_sample(y.shape))
    t0 = distribution.max_value_bin()
    p0 = (1.0, 1.0, t0, 1.0, 1.0, self._orth(t0))
    r = optimize.leastsq(self.von2_mises_res, p0, args=(x, (y + rn)), full_output=True)
    if (not (r[(- 1)] in (1, 2, 3, 4))):
        self.fit_exit_code = (100 + r[(- 1)])
        return null
    residuals = r[2]['fvec']
    jacobian = r[1]
    bandwith_1 = r[0][1]
    tuning_1 = r[0][2]
    bandwith_2 = r[0][4]
    tuning_2 = r[0][5]
    if (jacobian is None):
        self.fit_exit_code = 2
        return null
    if (bandwith_1 < 0):
        self.fit_exit_code = 1
        return null
    if (bandwith_2 < 0):
        self.fit_exit_code = 1
        return null
    error = ((residuals ** 2).sum() / (n - len(p0)))
    covariance = (jacobian * error)
    g1 = covariance[(2, 2)]
    g2 = covariance[(5, 5)]
    p1 = (self._in_pi(tuning_1) / to_pi)
    p2 = (self._in_pi(tuning_2) / to_pi)
    s1 = self.norm_sel(bandwith_1, n)
    s2 = self.norm_sel(bandwith_2, n)
    self.fit_exit_code = 0
    return (p1, s1, g1, p2, s2, g2)
computes the best fit of the bivariate von Mises function in the
semi-circle.
Return the tuple:
(
    orientation1_preference, orientation1_selectivity, goodness_of_fit1,
    orientation2_preference, orientation2_selectivity, goodness_of_fit2
)
See fit_vm() for considerations about selectivity and goodness_of_fit
def fit_v2m(self, distribution):
    '\n        computes the best fit of the bivariate von Mises function in the\n        semi-circle.\n        Return the tuple:\n        (\n            orientation1_preference, orientation1_selectivity, goodness_of_fit1,\n            orientation2_preference, orientation2_selectivity, goodness_of_fit2\n        )\n        See fit_vm() for considerations about selectivity and goodness_of_fit\n        '
    null = (0, 0, 0, 0, 0, 0)
    if unavailable_scipy_optimize:
        if (not VonMisesStatisticFn.user_warned_if_unavailable):
            param.Parameterized().warning('scipy.optimize not available, dummy von Mises fit')
            VonMisesStatisticFn.user_warned_if_unavailable = True
        self.fit_exit_code = 3
        return null
    to_pi = (np.pi / distribution.axis_range)
    x = (to_pi * np.array(distribution.bins()))
    n = len(x)
    if (n < 9):
        param.Parameterized().warning('no bimodal von Mises fit possible with less than 8 bins')
        self.fit_exit_code = (- 1)
        return null
    y = np.array(distribution.values())
    if (y.std() < self.noise_level):
        self.fit_exit_code = 1
        return null
    rn = (self.noise_level * np.random.random_sample(y.shape))
    t0 = distribution.max_value_bin()
    p0 = (1.0, 1.0, t0, 1.0, 1.0, self._orth(t0))
    r = optimize.leastsq(self.von2_mises_res, p0, args=(x, (y + rn)), full_output=True)
    if (not (r[(- 1)] in (1, 2, 3, 4))):
        self.fit_exit_code = (100 + r[(- 1)])
        return null
    residuals = r[2]['fvec']
    jacobian = r[1]
    bandwith_1 = r[0][1]
    tuning_1 = r[0][2]
    bandwith_2 = r[0][4]
    tuning_2 = r[0][5]
    if (jacobian is None):
        self.fit_exit_code = 2
        return null
    if (bandwith_1 < 0):
        self.fit_exit_code = 1
        return null
    if (bandwith_2 < 0):
        self.fit_exit_code = 1
        return null
    error = ((residuals ** 2).sum() / (n - len(p0)))
    covariance = (jacobian * error)
    g1 = covariance[(2, 2)]
    g2 = covariance[(5, 5)]
    p1 = (self._in_pi(tuning_1) / to_pi)
    p2 = (self._in_pi(tuning_2) / to_pi)
    s1 = self.norm_sel(bandwith_1, n)
    s2 = self.norm_sel(bandwith_2, n)
    self.fit_exit_code = 0
    return (p1, s1, g1, p2, s2, g2)