id stringlengths 30 32 | content stringlengths 139 2.8k |
|---|---|
codereview_new_python_data_13071 | def test_add_second_rectangular_region_deactivates_first_selector(self):
self.assertTrue(region_selector._selectors[1].active)
def test_get_region(self):
- x1, x2, x3, x4, y1, y2, y3, y4 = 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0
-
- selector_one = Mock()
- selector_one.extents = [x1... |
codereview_new_python_data_13080 | def validateInputs(self):
elif isinstance(ws, mantid.api.MatrixWorkspace):
hasInstrument = len(ws.componentInfo()) > 0
else:
issues["Workspace"] = "Workspace must be a WorkspaceGroup or MatrixWorkspace."
- return issues
- if not hasInstrument:
... |
codereview_new_python_data_13081 | def _get_shifts(self, calibration_file, zero_angle_corr, n_banks):
except FileNotFoundError:
self.log().warning("Bank calibration file not found or not provided.")
bank_shifts = [zero_angle_corr] * n_banks
- except RuntimeError as e:
self.log().warning(str(e))
... |
codereview_new_python_data_13082 | def _get_shifts(self, calibration_file, zero_angle_corr, n_banks):
except FileNotFoundError:
self.log().warning("Bank calibration file not found or not provided.")
bank_shifts = [zero_angle_corr] * n_banks
- except RuntimeError as e:
self.log().warning(str(e))
... |
codereview_new_python_data_13083 |
resolution, flux = Instrument.calculate(inst='maps', chtyp='a', freq=500, ei=600, etrans=range(0,550,50))
"""
-
-
-def PyChop2(instrument, chopper=None, freq=None):
- import warnings
- warnings.warn("Deprecation Warning: Importing 'PyChop2' from the 'mantidqtinterfaces.PyChop' module is deprecated."
- ... |
codereview_new_python_data_13084 |
"""
-def PyChop2(instrument, chopper=None, freq=None):
import warnings
warnings.warn("Deprecation Warning: Importing 'PyChop2' from the 'mantidqtinterfaces.PyChop' module is deprecated."
"Please import 'Instrument' from the 'pychop.Instruments' module instead.", DeprecationWarning)
... |
codereview_new_python_data_13087 | def get(self, option, second=None, type=None):
return self._get_setting(option, second, type)
except TypeError:
# The 'PyQt_PyObject' (1024) type is sometimes used for settings which have an unknown type.
- value = self._get_setting(option, type=QVariant.typeToName(1024))
... |
codereview_new_python_data_13165 | def _filliben(dist, data):
# [7] Section 8 # 4
return _corr(X, M)
-_filliben.alternative = 'less'
def _cramer_von_mises(dist, data):
```suggestion
_filliben.alternative = 'less' # type: ignore[<code>]
```
def _filliben(dist, data):
# [7] Section 8 # 4
return _corr(X, M)
+_filliben.al... |
codereview_new_python_data_13166 | def _filliben(dist, data):
# [7] Section 8 # 4
return _corr(X, M)
-_filliben.alternative = 'less' # type: ignore[<code>]
def _cramer_von_mises(dist, data):
```suggestion
_filliben.alternative = 'less' # type: ignore[attr-defined]
```
def _filliben(dist, data):
# [7] Section 8 # 4
re... |
codereview_new_python_data_13167 | def test_sf_isf(self, x, c, sfx):
def test_entropy(self, c, ref):
assert_allclose(stats.gompertz.entropy(c), ref, rtol=1e-14)
class TestHalfNorm:
# sfx is sf(x). The values were computed with mpmath:
PEP-8: we need two blank lines before the following `class` definition.
```suggestion
... |
codereview_new_python_data_13168 | def ecdf(sample):
elif sample.num_censored() == sample._right.size:
res = _ecdf_right_censored(sample)
else:
- # Support censoring in follow-up PRs
- message = ("Currently, only uncensored data is supported.")
raise NotImplementedError(message)
return res
Needs to be u... |
codereview_new_python_data_13169 | def add_newdoc(name, doc):
where :math:`p` is the probability of a single success
and :math:`1-p` is the probability of a single failure
- and :math::`k` is the number of trials to get the first success.
>>> import numpy as np
>>> from scipy.special import xlog1py
```suggestion
and :ma... |
codereview_new_python_data_13170 | def add_newdoc(name, doc):
-69.31471805599453
We can confirm that we get a value close to the original pmf value by
- taking the exponetial of the log pmf.
>>> _orig_pmf = np.exp(_log_pmf)
>>> np.isclose(_pmf, _orig_pmf)
```suggestion
taking the exponential of the log pmf.
```
This c... |
codereview_new_python_data_13171 | def _var(x, axis=0, ddof=0, mean=None):
var = _moment(x, 2, axis, mean=mean)
if ddof != 0:
n = x.shape[axis] if axis is not None else x.size
- with np.errstate(divide='ignore', invalid='ignore'):
- var *= np.divide(n, n-ddof) # to avoid error on division by zero
return var
... |
codereview_new_python_data_13172 | class TestMultivariateHypergeom:
# test for `n < 0`
([3, 4], [5, 10], -7, np.nan),
# test for `x.sum() != n`
- ([3, 3], [5, 10], 7, inp.inf)
]
)
def test_logpmf(self, x, m, n, expected):
```suggestion
([3, 3], [5, 10], 7, -np.inf)
```
... |
codereview_new_python_data_13173 | def splprep(x, w=None, u=None, ub=None, ue=None, k=3, task=0, s=None, t=None,
the range ``(m-sqrt(2*m),m+sqrt(2*m))``, where m is the number of
data points in x, y, and w.
t : array, optional
- An array of knots needed for task=-1. There must be at least 2*k+2 knots if task=-1.
full_... |
codereview_new_python_data_13174 | def add_newdoc(name, doc):
A lower loss is usually better as it indicates that the predictions are
similar to the actual labels. In this example since our predicted
- probabilties correspond with the actual labels, we get an overall loss
that is reasonably low and appropriate.
""")
```sugge... |
codereview_new_python_data_13175 | def func(x):
assert_allclose(np.exp(logres.integral), res.integral, rtol=1e-14)
assert np.imag(logres.integral) == (np.pi if np.prod(signs) < 0 else 0)
assert_allclose(np.exp(logres.standard_error),
- res.standard_error, rtol=1e-14, atol=1e-17)
@pytest.mark.para... |
codereview_new_python_data_13176 | def func(x):
assert_allclose(np.exp(logres.integral), res.integral, rtol=1e-14)
assert np.imag(logres.integral) == (np.pi if np.prod(signs) < 0 else 0)
assert_allclose(np.exp(logres.standard_error),
- res.standard_error, rtol=1e-14, atol=2e-17)
@pytest.mark.para... |
codereview_new_python_data_13177 | def tri(N, M=None, k=0, dtype=None):
[1, 1, 0, 0, 0]])
"""
- warnings.warn("'tri'/'tril/'triu' is deprecated as of SciPy 1.11.0 in favour of"
"'numpy.tri' and will be removed in SciPy 1.13.0",
DeprecationWarning, stacklevel=2)
I would change the senten... |
codereview_new_python_data_13178 |
bracket_methods = [zeros.bisect, zeros.ridder, zeros.brentq, zeros.brenth,
zeros.toms748]
gradient_methods = [zeros.newton]
-all_methods = bracket_methods + gradient_methods
# A few test functions used frequently:
# # A simple quadratic, (x-1)^2 - 1
```suggestion
all_methods = bracket_metho... |
codereview_new_python_data_13179 | def test_sf(self, x, ref):
# from mpmath import mp
# mp.dps = 200
# def isf_mpmath(x):
- # x = mp.mpf(x)
- # x = x/mp.mpf(2.)
- # return float(-mp.log(x/(mp.one - x)))
@pytest.mark.parametrize('q, ref', [(7.440151952041672e-44, 100),
(... |
codereview_new_python_data_13180 | def sem(a, axis=0, ddof=1, nan_policy='propagate'):
nan_policy : {'propagate', 'raise', 'omit'}, optional
Defines how to handle when input contains nan.
The following options are available (default is 'propagate'):
* 'propagate': returns nan
* 'raise': throws an error
... |
codereview_new_python_data_13181 | def test_location_scale(
# Test seems to be unstable (see gh-17839 for a bug report on Debian
# i386), so skip it.
if is_linux_32 and case == 'pdf':
- pytest.skip("%s fit known to fail or deprecated" % dist)
data = nolan_loc_scale_sample_data
# We only test aga... |
codereview_new_python_data_13182 | def _random_cd(
if d == 0 or n == 0:
return np.empty((n, d))
- if d == 1:
# discrepancy measures are invariant under permuting factors and runs
return best_sample
best_disc = discrepancy(best_sample)
- if n == 1:
- return best_sample
-
bounds = ([0, d - 1],
... |
codereview_new_python_data_13183 | def _random_cd(
while n_nochange_ < n_nochange and n_iters_ < n_iters:
n_iters_ += 1
- col = rng_integers(rng, *bounds[0], endpoint=True)
- row_1 = rng_integers(rng, *bounds[1], endpoint=True)
- row_2 = rng_integers(rng, *bounds[2], endpoint=True)
disc = _perturb_discrepan... |
codereview_new_python_data_13184 | def asymptotic_formula(half_df):
# 1/(12 * a) - 1/(360 * a**3)
# psi(a) ~ ln(a) - 1/(2 * a) - 1/(3 * a**2) + 1/120 * a**4)
c = np.log(2) + 0.5*(1 + np.log(2*np.pi))
- h = 2/half_df
return (h*(-2/3 + h*(-1/3 + h*(-4/45 + h/7.5))) +
... |
codereview_new_python_data_13185 | def _entropy(self, nu):
C = -0.5 * np.log(nu) - np.log(2)
h = A + B + C
# This is the asymptotic sum of A and B (see gh-17868)
- norm_entropy = stats.norm.entropy()
# Above, this is lost to rounding error for large nu, so use the
# asymptotic sum when the approximati... |
codereview_new_python_data_13186 | def _entropy(self, nu):
norm_entropy = stats.norm._entropy()
# Above, this is lost to rounding error for large nu, so use the
# asymptotic sum when the approximation becomes accurate
- i = nu > 1e7 # roundoff error ~ approximation error
- h[i] = C[i] + norm_entropy
re... |
codereview_new_python_data_13187 | def _entropy(self, nu):
norm_entropy = stats.norm._entropy()
# Above, this is lost to rounding error for large nu, so use the
# asymptotic sum when the approximation becomes accurate
- i = nu > 1e7 # roundoff error ~ approximation error
- h[i] = C[i] + norm_entropy
re... |
codereview_new_python_data_13188 | def _cdf(self, x, a, b):
f2=lambda x_, a_, b_: beta._cdf(x_/(1+x_), a_, b_))
def _ppf(self, p, a, b):
# by default, compute compute the ppf by solving the following:
# p = beta._cdf(x/(1+x), a, b). This implies x = r/(1-r) with
# r = beta._ppf(p, a, b). This can cause num... |
codereview_new_python_data_13189 | def test_frozen(self):
multivariate_normal.logcdf(x, mean, cov))
def test_frozen_multivariate_normal_exposes_attributes(self):
- np.random.seed(1234)
mean = np.ones((2,))
cov = np.eye(2)
norm_frozen = multivariate_normal(mean, cov)
I don't think th... |
codereview_new_python_data_13190 | class multivariate_normal_gen(multi_rv_generic):
entropy()
Compute the differential entropy of the multivariate normal.
- Attributes
- ----------
- mean : ndarray
- Mean of the distribution.
-
- .. versionadded:: 1.10.1
-
- cov : ndarray
- Covariance mat... |
codereview_new_python_data_13191 | def test_frozen(self):
multivariate_normal.logcdf(x, mean, cov))
def test_frozen_multivariate_normal_exposes_attributes(self):
- np.random.seed(1234)
mean = np.ones((2,))
cov = np.eye(2)
norm_frozen = multivariate_normal(mean, cov)
Some reviewers h... |
codereview_new_python_data_13192 | def test_frozen(self):
multivariate_normal.logcdf(x, mean, cov))
def test_frozen_multivariate_normal_exposes_attributes(self):
- np.random.seed(1234)
mean = np.ones((2,))
cov = np.eye(2)
norm_frozen = multivariate_normal(mean, cov)
This can be [par... |
codereview_new_python_data_13193 | def __init__(self, mean=None, cov=1, allow_singular=False, seed=None,
Relative error tolerance for the cumulative distribution function
(default 1e-5)
- Attributes
- ----------
- mean : ndarray
- Mean of the distribution.
-
- cov : ndarray
- Covariance matr... |
codereview_new_python_data_13194 | def __init__(self, mean=None, cov=1, allow_singular=False, seed=None,
Relative error tolerance for the cumulative distribution function
(default 1e-5)
- Attributes
- ----------
- mean : ndarray
- Mean of the distribution.
-
- cov : ndarray
- Covariance matr... |
codereview_new_python_data_13195 | def __init__(self, mean=None, cov=1, allow_singular=False, seed=None,
Relative error tolerance for the cumulative distribution function
(default 1e-5)
- Attributes
- ----------
- mean : ndarray
- Mean of the distribution.
-
- cov : ndarray
- Covariance matr... |
codereview_new_python_data_13196 | def istft(Zxx, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
# Divide out normalization where non-tiny
if np.sum(norm > 1e-10) != len(norm):
- warnings.warn("NOLA condition failed, STFT may not be invertible. " + ("Possibly due to missing boundary" if boundary else ""))
x /= np... |
codereview_new_python_data_13197 | def leastsq(func, x0, args=(), Dfun=None, full_output=0,
A function or method to compute the Jacobian of func with derivatives
across the rows. If this is None, the Jacobian will be estimated.
full_output : bool, optional
- If truthy, return all optional outputs (not just `x` and `ier`).
... |
codereview_new_python_data_13198 |
has_umfpack = True
has_cholmod = True
try:
from sksparse.cholmod import analyze as cholmod_analyze
except ImportError:
has_cholmod = False
try:
- pass # test whether to use factorized
except ImportError:
has_umfpack = False
This appears to change something. I don't want to dig into whether ... |
codereview_new_python_data_13199 | def test_wrightomega_singular():
for p in pts:
res = sc.wrightomega(p)
assert_equal(res, -1.0)
- assert_(np.signbit(res.imag) is False)
@pytest.mark.parametrize('x, desired', [
We can't use `is` here. The return value of `np.signbit(res.imag)` is an instance of `np.bool_`. It is e... |
codereview_new_python_data_13200 |
Result classes used in :mod:`scipy.stats`
-----------------------------------------
-.. warning:: These classes are private. Do not import them.
.. toctree::
:maxdepth: 2
One might wonder why they are documented at all then; perhaps we should explain. Also, rather than issuing a command to the user, consid... |
codereview_new_python_data_13201 | def _logsf(self, x, a, b):
return logsf
def _entropy(self, a, b):
- A = 0.5 * (1 + sc.erf(a / np.sqrt(2)))
- B = 0.5 * (1 + sc.erf(b / np.sqrt(2)))
Z = B - A
- C = (np.log(np.pi) + np.log(2) + 1) / 2
- D = np.log(Z)
- h = (C + D) / (2 * Z)
return h
... |
codereview_new_python_data_13202 | def test_entropy(self, a, b, ref):
# return pdf_standard_norm(x) / Z
#
# return -mp.quad(lambda t: pdf(t) * mp.log(pdf(t)), [a, b])
- assert_allclose(stats.truncnorm._entropy(a, b), ref)
def test_ppf_ticket1131(self):
vals = stats.truncnorm.ppf([-0.5, 0, 1e-4... |
codereview_new_python_data_13203 | def _logsf(self, x, a, b):
return logsf
def _entropy(self, a, b):
- A = sc.ndtr(a)
- B = sc.ndtr(b)
Z = B - A
C = np.log(np.sqrt(2 * np.pi * np.e) * Z)
D = (a * _norm_pdf(a) - b * _norm_pdf(b)) / (2 * Z)
```suggestion
A = _norm_cdf(a)
B = _nor... |
codereview_new_python_data_13204 | def setup_method(self):
(1e-6, 2e-6, -13.815510557964274149359836996664372028297528210772236)])
def test_entropy(self, a, b, ref):
#All reference values were calculated with mpmath:
#def entropy_trun(a, b):
# def cdf(x):
# return 0.5 * (1 + mp.erf(x / mp.sqrt(2))... |
codereview_new_python_data_13205 | def test_entropy(self, a, ref):
# return h
#
# return -mp.quad(lambda t: pdf(t) * mp.log(pdf(t)), [-mp.inf, mp.inf])
- assert_allclose(stats.dgamma._entropy(a), ref)
def test_entropy_overflow(self):
assert np.isfinite(stats.dgamma.entropy(1e100))
```suggestion... |
codereview_new_python_data_13206 | def test_entropy(self, a, ref):
# return h
#
# return -mp.quad(lambda t: pdf(t) * mp.log(pdf(t)), [-mp.inf, mp.inf])
- assert_allclose(stats.dgamma._entropy(a), ref)
def test_entropy_overflow(self):
assert np.isfinite(stats.dgamma.entropy(1e100))
```suggestion... |
codereview_new_python_data_13207 | def _entropy(self, a):
else:
h = np.log(2) + 0.5 * (1 + np.log(a) + np.log(2 * np.pi))
- #norm_entropy = stats.norm.entropy()
- #i = a > 5e4
- #h[i] = norm_entropy - 1 / (12 * a[i])
return h
def _ppf(self, q, a):
All of scipy's distributions support numpy a... |
codereview_new_python_data_13208 | def h2(a):
h2 = np.log(2) + 0.5 * (1 + np.log(a) + np.log(2 * np.pi))
return h2
- h = _lazywhere(a > 1e13, (a), f=h2, f2=h1)
return h
def _ppf(self, q, a):
```suggestion
h = _lazywhere(a > 1e10, (a), f=h2, f2=h1)
```
Turns out problems start way before `... |
codereview_new_python_data_13209 | def test_entropy(self, a, ref):
(1e+100, 117.2413403634669)])
def test_entropy_entreme_values(self, a, ref):
# The reference values were calculated with mpmath:
- # import mpmath as mp
# mp.dps = 50
# def second_dgamma(a):
# if a < 1e15:... |
codereview_new_python_data_13210 | def test_entropy_entreme_values(self, a, ref):
assert_allclose(stats.dgamma.entropy(a), ref, rtol=1e-10)
def test_entropy_array_input(self):
- y = stats.dgamma.entropy([1, 5, 1e20, 1e-5])
- assert y[0] == stats.dgamma.entropy(1)
- assert y[1] == stats.dgamma.entropy(5)
- ass... |
codereview_new_python_data_13211 | def h2(a):
h2 = np.log(2) + 0.5 * (1 + np.log(a) + np.log(2 * np.pi))
return h2
- h = _lazywhere(a > 1e10, (a), f=h2, f2=h1)
return h
def _ppf(self, q, a):
```suggestion
h = _lazywhere(a > 1e8, (a), f=h2, f2=h1)
```
def h2(a):
h2 = np.log(2) ... |
codereview_new_python_data_13212 | def test_entropy(self, m, ref):
# return -mp.quad(lambda t: pdf(t) * mp.log(pdf(t)), [0, mp.inf]
assert_allclose(stats.nakagami._entropy(m), ref)
@pytest.mark.xfail(reason="Fit of nakagami not reliable, see gh-10908.")
@pytest.mark.parametrize('nu', [1.6, 2.5, 3.9])
@pytest.mark.pa... |
codereview_new_python_data_13213 | def linprog(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None,
Note that by default ``lb = 0`` and ``ub = None`` unless specified with
``bounds``. There is, however, no need to manually formulate the linear
programming problem in terms of positive variables, often termed slack
- variables. By setting cor... |
codereview_new_python_data_13214 | def linprog(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None,
Use ``None`` to indicate that there is no bound. For instance, the
default bound ``(0, None)`` means that all decision variables are
non-negative, and the pair ``(None, None)`` means no bounds at all,
- i.e. all variables are ... |
codereview_new_python_data_13215 | def _stats(self, c):
return mu, mu2, g1, g2
def _entropy(self, c):
- return sc.betaln(c, 1) + 1 + sc.psi(c) + 1/c + _EULER
genlogistic = genlogistic_gen(name='genlogistic')
I noted in my earlier comment that the beta function simplifies for the case of `b=1` (and that's why SciPy is a spec... |
codereview_new_python_data_13216 | def curve_fit(f, xdata, ydata, p0=None, sigma=None, absolute_sigma=False,
xdata : array_like
The independent variable where the data is measured.
Should usually be an M-length sequence or an (k,M)-shaped array for
- functions with k predictors, and a (k,M,N)-shaped 3D array is also
- ... |
codereview_new_python_data_13217 |
import math
import numpy as np
from numpy import sqrt, cos, sin, arctan, exp, log, pi, Inf
-from numpy.testing import (assert_, assert_equal,
assert_allclose, assert_array_less, assert_almost_equal)
import pytest
To fix the linter
```suggestion
from numpy.testing import (assert_equal,
```
import ... |
codereview_new_python_data_13218 | def brentq(f, a, b, args=(),
"""
Find a root of a function in a bracketing interval using Brent's method.
- Uses the classic Brent's method to find a roo of the function `f` on
the sign changing interval [a , b]. Generally considered the best of the
rootfinding routines here. It is a safe vers... |
codereview_new_python_data_13219 | def test_logcdf_logsf(self):
# ref = (1/2 * mp.log(2 * mp.pi * mp.e * mu**3)
# - 3/2* mp.exp(2/mu) * mp.e1(2/mu))
@pytest.mark.parametrize("mu, ref", [(1e-2, -5.496279615262233),
- (1e8, 3.3244822568873474)])
(1e100... |
codereview_new_python_data_13220 | def test_logcdf_logsf(self):
# ref = (1/2 * mp.log(2 * mp.pi * mp.e * mu**3)
# - 3/2* mp.exp(2/mu) * mp.e1(2/mu))
@pytest.mark.parametrize("mu, ref", [(1e-2, -5.496279615262233),
- (1e8, 3.3244822568873474)]),
(1e10... |
codereview_new_python_data_13221 | def add_newdoc(name, doc):
Plot the function. For that purpose, we provide a NumPy array as argument.
>>> import matplotlib.pyplot as plt
- >>> x = np.linspace(0, 1, 500)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, ndtri(x))
>>> ax.set_title("Standard normal percentile function")
This is... |
codereview_new_python_data_13222 | def test_isf(self):
330.6557590436547, atol=1e-13)
class TestDgamma:
- def test_logpdf(self):
- x = np.array([1, 0.3, 4])
- a = 1.3
- y = stats.dgamma.pdf(x, a)
- assert_allclose(y, np.exp(stats.dgamma.logpdf(x, a)))
-
def test_pdf(self):
#Refe... |
codereview_new_python_data_13223 | def _wrap_callback(callback, method=None):
return callback # don't wrap
sig = inspect.signature(callback)
- has_one_parameter = len(sig.parameters) == 1
- named_intermediate_result = sig.parameters.get('intermediate_result', 0)
- if has_one_parameter and named_intermediate_result:
... |
codereview_new_python_data_13224 | def _wrap_callback(callback, method=None):
return callback # don't wrap
sig = inspect.signature(callback)
- has_one_parameter = len(sig.parameters) == 1
- named_intermediate_result = sig.parameters.get('intermediate_result', 0)
- if has_one_parameter and named_intermediate_result:
... |
codereview_new_python_data_13225 | def _wrap_callback(callback, method=None):
sig = inspect.signature(callback)
- if set(sig.parameters) != {'intermediate_result'}:
def wrapped_callback(res):
return callback(intermediate_result=res)
elif method == 'trust-constr':
Oh wait it should be the other way around, my bad ... |
codereview_new_python_data_13226 | def levene(*samples, center='median', proportiontocut=0.05):
Examples
--------
- In [4]_, the influence of vitamine C on the tooth growth of guinea pigs
was investigated. In a control study, 60 subjects were divided into
- three groups each respectively recieving a daily doses of 0.5, 1.0 and 2.... |
codereview_new_python_data_13227 | def levene(*samples, center='median', proportiontocut=0.05):
--------
In [4]_, the influence of vitamin C on the tooth growth of guinea pigs
was investigated. In a control study, 60 subjects were divided into
- three groups each respectively receiving daily doses of 0.5, 1.0 and 2.0
- mg of vitami... |
codereview_new_python_data_13228 | def levene(*samples, center='median', proportiontocut=0.05):
--------
In [4]_, the influence of vitamin C on the tooth growth of guinea pigs
was investigated. In a control study, 60 subjects were divided into
- three groups each respectively receiving daily doses of 0.5, 1.0 and 2.0
- mg of vitami... |
codereview_new_python_data_13229 | def bartlett(*samples):
only provide evidence for a "significant" effect, meaning that they are
unlikely to have occurred under the null hypothesis.
- Note that the chi-square distribution provides an asymptotic approximation
- of the null distribution.
- For small samples, it may be more appr... |
codereview_new_python_data_13230 | def bartlett(*samples):
only provide evidence for a "significant" effect, meaning that they are
unlikely to have occurred under the null hypothesis.
- Note that the chi-square distribution provides an asymptotic approximation
- of the null distribution.
- For small samples, it may be more appr... |
codereview_new_python_data_13231 | def test_pmf(self):
vals6 = multinomial.pmf([2, 1, 0], 0, [2/3.0, 1/3.0, 0])
assert vals6 == 0
def test_pmf_broadcasting(self):
vals0 = multinomial.pmf([1, 2], 3, [[.1, .9], [.2, .8]])
assert_allclose(vals0, [.243, .384], rtol=1e-8)
```suggestion
assert vals6 == 0
... |
codereview_new_python_data_13232 | def statistic(data, axis):
np.std(data, axis, ddof=1)])
res = bootstrap((sample,), statistic, method=method, axis=-1,
- n_resamples=9999)
counts = np.sum((res.confidence_interval.low.T < params)
& (res.confidence_interval.high.T > params... |
codereview_new_python_data_13233 | def test_nonscalar_values_linear_2D(self):
v2 = np.expand_dims(vs, axis=0)
assert_allclose(v, v2, atol=1e-14, err_msg=method)
- @pytest.mark.parametrize("dtype",
- [np.float32, np.float64, np.complex64, np.complex128])
@pytest.mark.parametrize("xi_dtype", [np.float32, np.float64]... |
codereview_new_python_data_13234 | def pmean(a, p, *, axis=0, dtype=None, weights=None):
\left( \frac{ 1 }{ n } \sum_{i=1}^n a_i^p \right)^{ 1 / p } \, .
- When p=0, it returns the geometric mean.
This mean is also called generalized mean or Hölder mean, and must not be
confused with the Kolmogorov generalized mean, also ca... |
codereview_new_python_data_13235 | def pointbiserialr(x, y):
.. math::
- r_{pb} = \frac{\overline{Y_{1}} -
- \overline{Y_{0}}}{s_{y}}\sqrt{\frac{N_{1} N_{2}}{N (N - 1))}}
Where :math:`\overline{Y_{0}}` and :math:`\overline{Y_{1}}` are means
of the metric observations coded 0 and 1 respectively; :math:`N_{0}` ... |
codereview_new_python_data_13236 | def pointbiserialr(x, y):
.. math::
- r_{pb} = \frac{\overline{Y_{1}} -
- \overline{Y_{0}}}{s_{y}}\sqrt{\frac{N_{1} N_{2}}{N (N - 1))}}
Where :math:`\overline{Y_{0}}` and :math:`\overline{Y_{1}}` are means
of the metric observations coded 0 and 1 respectively; :math:`N_{0}` ... |
codereview_new_python_data_13237 | def test_bounds_variants(self):
bounds_new = Bounds(lb, ub)
res_old = lsq_linear(A, b, bounds_old)
res_new = lsq_linear(A, b, bounds_new)
assert_allclose(res_old.x, res_new.x)
def test_np_matrix(self):
To emphasize that this is a problem for which `bounds` have an effect on ... |
codereview_new_python_data_13238 | def _minimize_cobyla(fun, x0, args=(), constraints=(),
constraints = (constraints, )
if bounds:
- msg = "An upper bound is less than the corresponding lower bound."
- if np.any(bounds.ub < bounds.lb):
- raise ValueError(msg)
-
- msg = "The number of bounds is not compati... |
codereview_new_python_data_13239 | def f(x):
def test_newton_complex_gh10103():
- # gh-10103 report a problem with `newton` and complex x0. Check that this
- # is resolved.
def f(z):
return z - 1
res = newton(f, 1+1j)
```suggestion
# gh-10103 reported a problem with `newton` and complex x0.
# Check that this is ... |
codereview_new_python_data_13240 | def f(x):
def test_newton_complex_gh10103():
- # gh-10103 reported a problem with `newton` and complex x0.
# Check that this is resolved.
def f(z):
return z - 1
Perhaps expand the description to something like:
```
# gh-10103 reported a problem with `newton` and complex x0, no fprime and ... |
codereview_new_python_data_13241 | def f(x):
res = solver(f, -0.5, -1e-200*1e-200, full_output=True)
res = res if rs_interface else res[1]
assert res.converged
- assert_allclose(res.root, 0, atol=1e-8)
\ No newline at end of file
```suggestion
assert_allclose(res.root, 0, atol=1e-8)
```
def f(x):
res = solver(f, -0.5, ... |
codereview_new_python_data_13242 | def curve_fit(f, xdata, ydata, p0=None, sigma=None, absolute_sigma=False,
>>> def func(x, a, b, c, d):
... return a * d * np.exp(-b * x) + c # a and d are redundant
>>> popt, pcov = curve_fit(func, xdata, ydata)
- >>> np.linalg.cond(pcov) # may vary
- 1.13250718925596e+32
Such a large... |
codereview_new_python_data_13243 | def curve_fit(f, xdata, ydata, p0=None, sigma=None, absolute_sigma=False,
>>> def func(x, a, b, c, d):
... return a * d * np.exp(-b * x) + c # a and d are redundant
>>> popt, pcov = curve_fit(func, xdata, ydata)
- >>> np.linalg.cond(pcov) # may vary
- 1.13250718925596e+32
Such a large... |
codereview_new_python_data_13244 | def curve_fit(f, xdata, ydata, p0=None, sigma=None, absolute_sigma=False,
>>> def func(x, a, b, c, d):
... return a * d * np.exp(-b * x) + c # a and d are redundant
>>> popt, pcov = curve_fit(func, xdata, ydata)
- >>> np.linalg.cond(pcov) # may vary
- 1.13250718925596e+32
Such a large... |
codereview_new_python_data_13245 | def lhs(x):
assert not res.converged
assert res.flag == 'convergence error'
- # This test case doesn't fail to converge for the vectorized version of
- # newton, but this one from `def test_zero_der_nz_dp()` does.
dx = np.finfo(float).eps ** 0.33
p0 = (200.0 - dx) / (2.0 + dx)
with pyt... |
codereview_new_python_data_13246 | def lhs(x):
assert not res.converged
assert res.flag == 'convergence error'
- # This test case doesn't fail to converge for the vectorized version of
- # newton, but this one from `def test_zero_der_nz_dp()` does.
dx = np.finfo(float).eps ** 0.33
p0 = (200.0 - dx) / (2.0 + dx)
with pyt... |
codereview_new_python_data_13247 | def lhs(x):
assert not res.converged
assert res.flag == 'convergence error'
- # This test case doesn't fail to converge for the vectorized version of
- # newton, but this one from `def test_zero_der_nz_dp()` does.
dx = np.finfo(float).eps ** 0.33
p0 = (200.0 - dx) / (2.0 + dx)
with pyt... |
codereview_new_python_data_13248 | def lhs(x):
assert not res.converged
assert res.flag == 'convergence error'
- # In the vectorized version of `newton`, the secant method doesn't
- # encounter zero slope in the problem above. Here's a problem where
- # it does. Check that it reports failure to converge.
- dx = np.finfo(float).... |
codereview_new_python_data_13249 | def odds_ratio(table, *, kind='conditional'):
The 95% confidence interval for the conditional odds ratio is
approximately (0.62, 0.94).
-The fact that the entire 95% confidence interval falls below 1 supports
-the authors' conclusion that the aspirin was associated with a statistically
-significant reducti... |
codereview_new_python_data_13250 |
.. autosummary::
:toctree: generated/
- f_ishigami
- sobol_indices
Plot-tests
----------
This could also go in another section. Open to suggestions.
.. autosummary::
:toctree: generated/
+ f_ishigami
+ sobol_indices
Plot-tests
---------- |
codereview_new_python_data_13251 | def chi2_contingency(observed, correction=True, lambda_=None):
>>> import numpy as np
>>> from scipy.stats import chi2_contingency
>>> table = np.array([[179, 230], [21032, 21018]])
- >>> res = chi2_contingency(obs)
>>> res.statistic
6.084250213339923
>>> res.pvalue
```suggestion
... |
codereview_new_python_data_13252 | def chi2_contingency(observed, correction=True, lambda_=None):
.. [4] Berger, Jeffrey S. et al. "Aspirin for the Primary Prevention of
Cardiovascular Events in Women and Men: A Sex-Specific
Meta-analysis of Randomized Controlled Trials."
- JAMA, 295(3):306–313, :doi:`10.1001/jama... |
codereview_new_python_data_13253 | class LatinHypercube(QMCEngine):
expensive to cover the space. When numerical experiments are costly,
QMC enables analysis that may not be possible if using a grid.
- The six parameters of the model represented the probability of illness,
the probability of withdrawal, and four contact probabiliti... |
codereview_new_python_data_13254 | def pearsonr(x, y, *, alternative='two-sided'):
x = np.asarray(x)
y = np.asarray(y)
- if True in np.iscomplex(x) or True in np.iscomplex(y):
raise ValueError('This function does not support complex data')
# If an input is constant, the correlation coefficient is not defined.
Since we ha... |
codereview_new_python_data_13255 | def test_len1(self):
def test_complex_data(self):
x = [-1j, -2j, -3.0j]
y = [-1j, -2j, -3.0j]
- assert_raises(ValueError, stats.pearsonr, x, y)
class TestFisherExact:
There are many `ValueErrors` out there. This test should only pass if the one we have in mind is raised.
```suggest... |
codereview_new_python_data_13256 | def test_vonmises_fit_all(kappa):
loc = 0.25*np.pi
data = stats.vonmises(loc=loc, kappa=kappa).rvs(100000, random_state=rng)
loc_fit, kappa_fit = stats.vonmises.fit(data)
- loc_vector = np.array([np.cos(loc), np.sin(loc)])
- loc_vector_fit = np.array([np.cos(loc_fit), np.sin(loc_fit)])
- assert... |
codereview_new_python_data_13257 | def _mode_result(mode, count):
count = count.dtype(0) if i else count
else:
count[i] = 0
- return ModeResult(mode, count * (~np.isnan(count)))
@_axis_nan_policy_factory(_mode_result, override={'vectorization': True,
Oops, this can be simplified.
```suggestion
return ModeResult(mo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.