id
stringlengths
30
32
content
stringlengths
139
2.8k
codereview_new_python_data_13360
def _entropy(self, kappa): The default limits of integration are endpoints of the interval of width ``2*pi`` centered at `loc` (e.g. ``[-pi, pi]`` when ``loc=0``).\n\n""") - def expect(self, func=None, args=(), loc=0, scale=1, lb=-np.pi, ub=np.pi, conditional=False, **kwds...
codereview_new_python_data_13361
def expect(self, func=None, args=(), loc=0, scale=1, lb=None, ub=None, >>> from scipy.stats import vonmises >>> res = vonmises(loc=2, kappa=1).expect(lambda x: np.exp(1j*x), ... complex_func=True) (-0.18576377217422957+0.40590124735052263j) ...
codereview_new_python_data_13362
PearsonRResult FitResult OddsRatioResult - Ttest_Result """ __all__ = ['BinomTestResult', 'RelativeRiskResult', 'TukeyHSDResult', 'PearsonRResult', 'FitResult', 'OddsRatioResult', - 'Ttest_Result'] from ._binomtest import BinomTestResult from ._odds_ratio import OddsRati...
codereview_new_python_data_13363
PearsonRResult FitResult OddsRatioResult - Ttest_Result """ __all__ = ['BinomTestResult', 'RelativeRiskResult', 'TukeyHSDResult', 'PearsonRResult', 'FitResult', 'OddsRatioResult', - 'Ttest_Result'] from ._binomtest import BinomTestResult from ._odds_ratio import OddsRati...
codereview_new_python_data_13364
PearsonRResult FitResult OddsRatioResult - Ttest_Result """ __all__ = ['BinomTestResult', 'RelativeRiskResult', 'TukeyHSDResult', 'PearsonRResult', 'FitResult', 'OddsRatioResult', - 'Ttest_Result'] from ._binomtest import BinomTestResult from ._odds_ratio import OddsRati...
codereview_new_python_data_13365
class rv_histogram(rv_continuous): The second containing the (n+1) bin boundaries In particular the return value np.histogram is accepted - .. versionadded:: 1.10.0 - Notes ----- There are no additional shape parameters except for the loc and scale. ```suggestion ``` This was i...
codereview_new_python_data_13366
def shgo(func, bounds, args=(), constraints=None, n=None, iters=1, ... {'type': 'eq', 'fun': h1}) >>> bounds = [(0, 1.0),]*4 >>> res = shgo(f, bounds, iters=3, constraints=cons) message: Optimization terminated successfully. success: True fun: 29.894378159142136 ```suggest...
codereview_new_python_data_13367
def least_squares( is applied), a sparse matrix (csr_matrix preferred for performance) or a `scipy.sparse.linalg.LinearOperator`. bounds : 2-tuple of array_like or `Bounds`, optional - There are two ways to specify bounds for methods 'trf' and 'dogbox': 1. Instance of `Boun...
codereview_new_python_data_13368
def test_bounds_shape(self): method=self.method) assert_allclose(res.x, [0.0, 0.5], atol=1e-5) - def test_bound_instances(self): res = least_squares(fun_trivial, 0.5, bounds=Bounds()) assert_allclose(res.x, 0.0, atol=1e-4) ```suggestion def test_bounds_insta...
codereview_new_python_data_13369
class InterpolatedUnivariateSpline(UnivariateSpline): 2-sequence specifying the boundary of the approximation interval. If None (default), ``bbox=[x[0], x[-1]]``. k : int, optional - Degree of the smoothing spline. Must be 1 <= `k` <= 5. Default is - `k` = 3, a cubic spline. ...
codereview_new_python_data_13370
class InterpolatedUnivariateSpline(UnivariateSpline): 2-sequence specifying the boundary of the approximation interval. If None (default), ``bbox=[x[0], x[-1]]``. k : int, optional - Degree of the smoothing spline. Must be 1 <= `k` <= 5. Default is - `k` = 3, a cubic spline. ...
codereview_new_python_data_13371
class InterpolatedUnivariateSpline(UnivariateSpline): None (default), ``bbox=[x[0], x[-1]]``. k : int, optional Degree of the smoothing spline. Must be ``1 <= k <= 5``. Default is - ``k = 3`, a cubic spline. ext : int or str, optional Controls the extrapolation mode for ele...
codereview_new_python_data_13372
def ppf(self, q, *args, **kwds): cond = cond0 & cond1 output = np.full(shape(cond), fill_value=self.badvalue, dtype='d') # output type 'd' to handle nin and inf - place(output, (q == 0), _a - 1 + loc) place(output, cond2, _b + loc) if np.any(cond): gooda...
codereview_new_python_data_13373
def design_matrix(cls, x, t, k, extrapolate=False): else: int_dtype = np.int64 # Preallocate indptr and indices - indices = np.zeros(n * (k + 1), dtype=int_dtype) indptr = np.arange(0, (n + 1) * (k + 1), k + 1, dtype=int_dtype) data, indices, indptr = _bspl._ma...
codereview_new_python_data_13374
def ttest_1samp(a, popmean, axis=0, nan_policy='propagate', df = n - 1 mean = np.mean(a, axis) - d = mean - popmean[..., 0] # popmean is an array because of decorator v = _var(a, axis, ddof=1) denom = np.sqrt(v / n) Hmm the behavior was buggy before (see https://github.com/scipy/scipy/pull...
codereview_new_python_data_13375
def circstd(samples, high=2*pi, low=0, axis=None, nan_policy='propagate', *, ... 0.104, -0.136, -0.867, 0.012, 0.105]) >>> circstd_1 = circstd(samples_1) >>> circstd_2 = circstd(samples_2) - >>> fig, (left, right) = plt.subplots(ncols=2) Plot the samples. ```suggesti...
codereview_new_python_data_13376
class of similar problems can be solved together. Examples -------- >>> import numpy as np - >>> from scipy import optimize >>> import matplotlib.pyplot as plt >>> def f(x): ... return (x**3 - 1) # only one real root at x = 1 This plt import should be next to the np import cl...
codereview_new_python_data_13377
def circmean(samples, high=2*pi, low=0, axis=None, nan_policy='propagate'): Plot and compare the results of *circmean* and the regular *mean*. - >>> plt.plot(np.cos(np.linspace(0, 2*np.pi, 500), - ... np.sin(np.linspace(0, 2*np.pi, 500), ... c='k') >>> plt.scatter(np.cos(angl...
codereview_new_python_data_13378
def test_infeasible_prob_16609(): _msg_iter = "Iteration limit reached. (HiGHS Status 14:" -@pytest.mark.skipif(np.intp(0).itemsize < 8, reason="Unhandled 32-bit GCC FP bug") @pytest.mark.slow @pytest.mark.parametrize(["options", "msg"], [({"time_limit": 1}, _msg_time), ...
codereview_new_python_data_13379
def test_infeasible_prob_16609(): @pytest.mark.skipif(np.intp(0).itemsize < 8, reason="Unhandled 32-bit GCC FP bug") @pytest.mark.slow -@pytest.mark.parametrize(["options", "msg"], [({"time_limit": 1}, _msg_time), - ({"node_limit": 10}, _msg_iter)]) ...
codereview_new_python_data_13380
def test_infeasible_prob_16609(): @pytest.mark.skipif(np.intp(0).itemsize < 8, reason="Unhandled 32-bit GCC FP bug") @pytest.mark.slow @pytest.mark.parametrize(["options", "msg"], [({"time_limit": 10}, _msg_time), ({"node_limit": 1}, _msg_iter)]) ...
codereview_new_python_data_13381
def design_matrix(cls, x, t, k, extrapolate=False): # of knots. if len(t) < 2 * k + 2: raise ValueError(f"Length t is not enough for k={k}.") - if not np.isfinite(t).all(): - raise ValueError("Knots should not have nans or infs.") if extrapolate == 'periodic'...
codereview_new_python_data_13382
def skew_d(d): # skewness in terms of delta # MoM won't provide a good guess. Get out early. s = stats.skew(data) s_max = skew_d(1) - if np.abs(s) >= s_max and method == "mle": return super().fit(data, *args, **kwds) # If method is method of moments, we don't ...
codereview_new_python_data_13383
def skew_d(d): # skewness in terms of delta # MoM won't provide a good guess. Get out early. s = stats.skew(data) s_max = skew_d(1) - if np.abs(s) >= s_max and method == "mle": return super().fit(data, *args, **kwds) # If method is method of moments, we don't ...
codereview_new_python_data_13384
def skew_d(d): # skewness in terms of delta # MoM won't provide a good guess. Get out early. s = stats.skew(data) s_max = skew_d(1) - if np.abs(s) >= s_max and method == "mle": return super().fit(data, *args, **kwds) # If method is method of moments, we don't ...
codereview_new_python_data_13385
def test_incompatible_x_y(self, k): def test_broken_x(self, k): x = [0, 1, 1, 2, 3, 4] # duplicates y = [0, 1, 2, 3, 4, 5] - with assert_raises(ValueError, match="Expect x to not have duplicates"): make_interp_spline(x, y, k=k) x = [0, 2, 1, 3, 4, 5] # un...
codereview_new_python_data_13386
def dblquad(func, a, b, gfun, hfun, args=(), epsabs=1.49e-8, epsrel=1.49e-8): :math:`\\iint^{\\infty}_{-\\infty} e^{-(x^{2} + y^{2})} \\,dy\\,dx`: >>> import numpy as np - >>> from scipy import integrate >>> f = lambda x, y: np.exp(-(x ** 2 + y ** 2)) >>> integrate.dblquad(f, -np.inf, np.inf, ...
codereview_new_python_data_13387
def dblquad(func, a, b, gfun, hfun, args=(), epsabs=1.49e-8, epsrel=1.49e-8): :math:`\\iint^{\\infty}_{-\\infty} e^{-(x^{2} + y^{2})} \\,dy\\,dx`: >>> import numpy as np - >>> from scipy import integrate >>> f = lambda x, y: np.exp(-(x ** 2 + y ** 2)) >>> integrate.dblquad(f, -np.inf, np.inf, ...
codereview_new_python_data_13388
def statistic(i, axis=-1, data=data_iv, unpaired_statistic=statistic): message = ("Either `bootstrap_result.bootstrap_distribution.size` or " "`n_resamples` must be positive.") - if n_resamples_int == 0 and (not bootstrap_result or - not bootstrap_result.bootstrap_distribution.size...
codereview_new_python_data_13389
def test_concatenate(): def test_concatenate_wrong_type(): with pytest.raises(TypeError, match='Rotation objects only'): Rotation.concatenate([Rotation.identity(), 1, None]) - - def test_len_and_bool(): rotation_single = Rotation([0, 0, 0, 1]) rotation_multi = Rotation([[0, 0,...
codereview_new_python_data_13390
def _compute_covariance(self): self._data_covariance[::-1, ::-1]).T[::-1, ::-1] self.covariance = self._data_covariance * self.factor**2 - self.cho_cov = self._data_cho_cov * self.factor self.log_det = 2*np.log(np.diag(self.cho_cov * ...
codereview_new_python_data_13391
def test_gaussian_kde_subclassing(): assert_array_almost_equal_nulp(ys, y2, nulp=10) # subclass 3 was removed because we have no obligation to maintain support - # for manual invocation of private methods # subclass 4 kde4 = _kde_subclass4(x1) ```suggestion # for user invocation of pri...
codereview_new_python_data_13392
def _compute_covariance(self): @property def inv_cov(self): self.factor = self.covariance_factor() self._data_covariance = atleast_2d(cov(self.dataset, rowvar=1, bias=False, aweights=self.weights)) ```suggestion def inv_cov(self): ...
codereview_new_python_data_13393
def test_svd_LM_ones_matrix(self, shape, dtype): # Check some generic properties of svd. if (self.solver == 'arpack' and dtype is complex): - pytest.skip("ARPACK has additional restriction for complex dtype") _check_svds(A, k, U, s, VH, check_usvh_A=True, check_svd=False) ...
codereview_new_python_data_13394
def test_sg_filter_valid_window_length_3d(): savgol_filter(x, window_length=29, polyorder=3, mode='interp') - with pytest.raises(ValueError, match='window_length must be less than'): # window_length is more than x.shape[-1]. savgol_filter(x, window_length=31, polyorder=3, mode='interp') ...
codereview_new_python_data_13395
def anderson_ksamp(samples, midrank=True): distribution can be rejected at the 5% level because the returned test value is greater than the critical value for 5% (1.961) but not at the 2.5% level. The interpolation gives an approximate - p-value of 5.0%. >>> res = stats.anderson_ksamp([rng.nor...
codereview_new_python_data_13396
def test_pvalue_literature(self): assert_allclose(pvalue, 1/1001) @pytest.mark.slow - @pytest.mark.parametrize("is_twosamp", [True, False]) - def test_alias(self, is_twosamp): - x = np.arange(100) - y = np.arange(100) - res = stats.multiscale_graphcorr(x, y, is_twosamp=is_two...
codereview_new_python_data_13397
def curve_fit(f, xdata, ydata, p0=None, sigma=None, absolute_sigma=False, The model function, f(x, ...). It must take the independent variable as the first argument and the parameters to fit as separate remaining arguments. - xdata : array_like or object The independent variable ...
codereview_new_python_data_14677
def testConvertTimeValueFromSparkToH2OAndBack(spark, hc, timeZone, sparkType): df = spark.createDataFrame(data, ['strings']).select(col('strings').cast(sparkType).alias('time')) hf = hc.asH2OFrame(df) - hfResultString = hf.__unicode__() - hfParsedItems = hfResultString.split('\n')[1:5] hfParsedI...
codereview_new_python_data_14678
def testConvertTimeValueFromSparkToH2OAndBack(spark, hc, timeZone, sparkType): df = spark.createDataFrame(data, ['strings']).select(col('strings').cast(sparkType).alias('time')) hf = hc.asH2OFrame(df) - hfResultString = hf.__unicode__() - hfParsedItems = hfResultString.split('\n')[1:5] hfParsedI...
codereview_new_python_data_14680
def __add_url_to_classloader(gateway, url): jvm = gateway.jvm loader = jvm.Thread.currentThread().getContextClassLoader() logger = Initializer.__get_logger(jvm) while loader: try: - urlClassLoaderClass = jvm.py4j.reflection.ReflectionUtil.classForName("ja...
codereview_new_python_data_14681
def __add_url_to_classloader(gateway, url): jvm = gateway.jvm loader = jvm.Thread.currentThread().getContextClassLoader() logger = Initializer.__get_logger(jvm) while loader: try: - urlClassLoaderClass = jvm.py4j.reflection.ReflectionUtil.classForName("ja...
codereview_new_python_data_14682
def __add_url_to_classloader(gateway, url): jvm = gateway.jvm loader = jvm.Thread.currentThread().getContextClassLoader() logger = Initializer.__get_logger(jvm) while loader: try: - urlClassLoaderClass = jvm.py4j.reflection.ReflectionUtil.classForName("ja...
codereview_new_python_data_14685
def test_h2o_mojo_pipeline_contributions(spark): mojo = H2OMOJOPipelineModel.createFromMojo(mojo_path, settings) df = spark.read.csv(data_path, header=True, inferSchema=True) - predictions_and_contributions = mojo.transform(df).select("prediction.*") feature_columns = 1 prediction_columns = ...
codereview_new_python_data_14743
def test_is_start_event(self): self.assertEqual(17, len(starts)) def test_is_end_event(self): - starts = [e for e in LOG if log_utils.is_end_event(e)] - self.assertEqual(17, len(starts)) def test_filter_and_sort_log_entries(self): filtered = log_utils.filter_and_sort_log_e...
codereview_new_python_data_14744
def build_windows_from_events(backpressure_events, window_width_in_hours=1): """ - Generate histogram-friendly time windows with counts of backpressuring durations within each window. :param backpressure_events: a list of BackpressureEvents to be broken up into time windows :param window_width_i...