repo stringclasses 12
values | instance_id stringlengths 18 32 | base_commit stringlengths 40 40 | patch stringlengths 344 252k | test_patch stringlengths 398 22.9k | problem_statement stringlengths 119 25.4k | hints_text stringlengths 1 55.7k ⌀ | created_at stringlengths 20 20 | version float64 0.12 2.02k | FAIL_TO_PASS stringlengths 12 120k | PASS_TO_PASS stringlengths 2 114k | environment_setup_commit stringclasses 89
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
pydata/xarray | pydata__xarray-4750 | 0f1eb96c924bad60ea87edd9139325adabfefa33 | diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py
--- a/xarray/core/formatting.py
+++ b/xarray/core/formatting.py
@@ -365,12 +365,23 @@ def _calculate_col_width(col_items):
return col_width
-def _mapping_repr(mapping, title, summarizer, col_width=None):
+def _mapping_repr(mapping, title, summa... | diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py
--- a/xarray/tests/test_formatting.py
+++ b/xarray/tests/test_formatting.py
@@ -463,3 +463,36 @@ def test_large_array_repr_length():
result = repr(da).splitlines()
assert len(result) < 50
+
+
+@pytest.mark.parametrize(
+ "disp... | Limit number of data variables shown in repr
<!-- Please include a self-contained copy-pastable example that generates the issue if possible.
Please be concise with code posted. See guidelines below on how to provide a good bug report:
- Craft Minimal Bug Reports: http://matthewrocklin.com/blog/work/2018/02/28/minima... | 👍🏽 on adding a configurable option to the list of options supported via `xr.set_options()`
```python
import xarray as xr
xr.set_options(display_max_num_variables=25)
```
Yes, this sounds like a welcome new feature! As a general rule, the output of repr() should fit on one screen. | 2021-01-02T21:14:50Z | 0.12 | ["xarray/tests/test_formatting.py::test__mapping_repr[1-40-30]", "xarray/tests/test_formatting.py::test__mapping_repr[11-40-30]", "xarray/tests/test_formatting.py::test__mapping_repr[35-40-30]", "xarray/tests/test_formatting.py::test__mapping_repr[50-40-30]"] | ["xarray/tests/test_formatting.py::TestFormatting::test_array_repr", "xarray/tests/test_formatting.py::TestFormatting::test_attribute_repr", "xarray/tests/test_formatting.py::TestFormatting::test_diff_array_repr", "xarray/tests/test_formatting.py::TestFormatting::test_diff_attrs_repr_with_array", "xarray/tests/test_for... | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-4819 | a2b1712afd957deaf189c9b1a04e469596d853c9 | diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py
--- a/xarray/core/dataarray.py
+++ b/xarray/core/dataarray.py
@@ -2247,6 +2247,28 @@ def drop_sel(
ds = self._to_temp_dataset().drop_sel(labels, errors=errors)
return self._from_temp_dataset(ds)
+ def drop_isel(self, indexers=None, ... | diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py
--- a/xarray/tests/test_dataarray.py
+++ b/xarray/tests/test_dataarray.py
@@ -2327,6 +2327,12 @@ def test_drop_index_labels(self):
with pytest.warns(DeprecationWarning):
arr.drop([0, 1, 3], dim="y", errors="ignore")
+ ... | drop_sel indices in dimension that doesn't have coordinates?
<!-- Please do a quick search of existing issues to make sure that this has not been asked before. -->
**Is your feature request related to a problem? Please describe.**
I am trying to drop particular indices from a dimension that doesn't have coordinates.
... | I don't know of an easy way (which does not mean that there is none). `drop_sel` could be adjusted to work with _dimensions without coordinates_ by replacing
https://github.com/pydata/xarray/blob/ff6b1f542e52dc330e294fd367f846e02c2955a2/xarray/core/dataset.py#L4038
by `index = self.get_index(dim)`. That would then be... | 2021-01-17T12:08:18Z | 0.12 | ["xarray/tests/test_dataarray.py::TestDataArray::test_drop_index_positions", "xarray/tests/test_dataset.py::TestDataset::test_drop_index_labels", "xarray/tests/test_dataset.py::TestDataset::test_drop_labels_by_position"] | ["xarray/tests/test_dataarray.py::TestDataArray::test__title_for_slice", "xarray/tests/test_dataarray.py::TestDataArray::test__title_for_slice_truncate", "xarray/tests/test_dataarray.py::TestDataArray::test_align", "xarray/tests/test_dataarray.py::TestDataArray::test_align_copy", "xarray/tests/test_dataarray.py::TestDa... | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-4879 | 15c68366b8ba8fd678d675df5688cf861d1c7235 | diff --git a/xarray/backends/file_manager.py b/xarray/backends/file_manager.py
--- a/xarray/backends/file_manager.py
+++ b/xarray/backends/file_manager.py
@@ -3,8 +3,9 @@
import contextlib
import io
import threading
+import uuid
import warnings
-from typing import Any
+from typing import Any, Hashable
from ..cor... | diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py
--- a/xarray/tests/test_backends.py
+++ b/xarray/tests/test_backends.py
@@ -1207,6 +1207,39 @@ def test_multiindex_not_implemented(self) -> None:
pass
+class NetCDFBase(CFEncodedBase):
+ """Tests for all netCDF3 and netCD... | jupyter repr caching deleted netcdf file
**What happened**:
Testing xarray data storage in a jupyter notebook with varying data sizes and storing to a netcdf, i noticed that open_dataset/array (both show this behaviour) continue to return data from the first testing run, ignoring the fact that each run deletes the pre... | Thanks for the clear example!
This happens dues to xarray's caching logic for files:
https://github.com/pydata/xarray/blob/b1c7e315e8a18e86c5751a0aa9024d41a42ca5e8/xarray/backends/file_manager.py#L50-L76
This means that when you open the same filename, xarray doesn't actually reopen the file from disk -- instead it ... | 2021-02-07T21:48:06Z | 0.12 | ["xarray/tests/test_backends_file_manager.py::test_file_manager_cache_repeated_open"] | ["xarray/tests/test_backends.py::TestCommon::test_robust_getitem", "xarray/tests/test_backends.py::TestEncodingInvalid::test_extract_h5nc_encoding", "xarray/tests/test_backends.py::TestEncodingInvalid::test_extract_nc4_variable_encoding", "xarray/tests/test_backends.py::test_invalid_netcdf_raises[netcdf4]", "xarray/tes... | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-5033 | f94de6b4504482ab206f93ec800608f2e1f47b19 | diff --git a/xarray/backends/api.py b/xarray/backends/api.py
--- a/xarray/backends/api.py
+++ b/xarray/backends/api.py
@@ -375,10 +375,11 @@ def open_dataset(
scipy.io.netcdf (only netCDF3 supported). Byte-strings or file-like
objects are opened by scipy.io.netcdf (netCDF3) or h5py (netCDF4/HDF).
... | diff --git a/xarray/tests/test_backends_api.py b/xarray/tests/test_backends_api.py
--- a/xarray/tests/test_backends_api.py
+++ b/xarray/tests/test_backends_api.py
@@ -1,6 +1,9 @@
+import numpy as np
+
+import xarray as xr
from xarray.backends.api import _get_default_engine
-from . import requires_netCDF4, requires_s... | Simplify adding custom backends
<!-- Please do a quick search of existing issues to make sure that this has not been asked before. -->
**Is your feature request related to a problem? Please describe.**
I've been working on opening custom hdf formats in xarray, reading up on the apiv2 it is currently only possible to d... | null | 2021-03-13T22:12:39Z | 0.12 | ["xarray/tests/test_backends_api.py::test_custom_engine"] | [] | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-5126 | 6bfbaede69eb73810cb63672a8161bd1fc147594 | diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py
--- a/xarray/core/formatting.py
+++ b/xarray/core/formatting.py
@@ -11,7 +11,7 @@
from pandas.errors import OutOfBoundsDatetime
from .duck_array_ops import array_equiv
-from .options import OPTIONS
+from .options import OPTIONS, _get_boolean_with_de... | diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py
--- a/xarray/tests/test_formatting.py
+++ b/xarray/tests/test_formatting.py
@@ -391,6 +391,17 @@ def test_array_repr(self):
assert actual == expected
+ with xr.set_options(display_expand_data=False):
+ actual =... | FR: Provide option for collapsing the HTML display in notebooks
# Issue description
The overly long output of the text repr of xarray always bugged so I was very happy that the recently implemented html repr collapsed the data part, and equally sad to see that 0.16.0 reverted that, IMHO, correct design implementation b... | Related: #4182 | 2021-04-07T10:51:03Z | 0.12 | ["xarray/tests/test_formatting.py::TestFormatting::test_array_repr", "xarray/tests/test_formatting.py::test__mapping_repr[1-40-30]", "xarray/tests/test_formatting.py::test__mapping_repr[11-40-30]", "xarray/tests/test_formatting.py::test__mapping_repr[35-40-30]", "xarray/tests/test_formatting.py::test__mapping_repr[50-4... | ["xarray/tests/test_formatting.py::TestFormatting::test_attribute_repr", "xarray/tests/test_formatting.py::TestFormatting::test_diff_array_repr", "xarray/tests/test_formatting.py::TestFormatting::test_diff_attrs_repr_with_array", "xarray/tests/test_formatting.py::TestFormatting::test_diff_dataset_repr", "xarray/tests/t... | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-5131 | e56905889c836c736152b11a7e6117a229715975 | diff --git a/xarray/core/groupby.py b/xarray/core/groupby.py
--- a/xarray/core/groupby.py
+++ b/xarray/core/groupby.py
@@ -436,7 +436,7 @@ def __iter__(self):
return zip(self._unique_coord.values, self._iter_grouped())
def __repr__(self):
- return "{}, grouped over {!r} \n{!r} groups with labels ... | diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py
--- a/xarray/tests/test_groupby.py
+++ b/xarray/tests/test_groupby.py
@@ -388,7 +388,7 @@ def test_da_groupby_assign_coords():
def test_groupby_repr(obj, dim):
actual = repr(obj.groupby(dim))
expected = "%sGroupBy" % obj.__class__.__nam... | Trailing whitespace in DatasetGroupBy text representation
When displaying a DatasetGroupBy in an interactive Python session, the first line of output contains a trailing whitespace. The first example in the documentation demonstrate this:
```pycon
>>> import xarray as xr, numpy as np
>>> ds = xr.Dataset(
... {"foo... | I don't think this is intentional and we are happy to take a PR. The problem seems to be here:
https://github.com/pydata/xarray/blob/c7c4aae1fa2bcb9417e498e7dcb4acc0792c402d/xarray/core/groupby.py#L439
You will also have to fix the tests (maybe other places):
https://github.com/pydata/xarray/blob/c7c4aae1fa2bcb9417e... | 2021-04-08T09:19:30Z | 0.12 | ["xarray/tests/test_groupby.py::test_groupby_repr[obj0-month]", "xarray/tests/test_groupby.py::test_groupby_repr[obj0-x]", "xarray/tests/test_groupby.py::test_groupby_repr[obj0-y]", "xarray/tests/test_groupby.py::test_groupby_repr[obj0-z]", "xarray/tests/test_groupby.py::test_groupby_repr[obj1-month]", "xarray/tests/te... | ["xarray/tests/test_groupby.py::test_consolidate_slices", "xarray/tests/test_groupby.py::test_da_groupby_empty", "xarray/tests/test_groupby.py::test_da_groupby_quantile", "xarray/tests/test_groupby.py::test_ds_groupby_quantile", "xarray/tests/test_groupby.py::test_groupby_bins_timeseries", "xarray/tests/test_groupby.py... | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-5187 | b2351cbe3f3e92f0e242312dae5791fc83a4467a | diff --git a/xarray/core/dask_array_ops.py b/xarray/core/dask_array_ops.py
--- a/xarray/core/dask_array_ops.py
+++ b/xarray/core/dask_array_ops.py
@@ -51,3 +51,24 @@ def least_squares(lhs, rhs, rcond=None, skipna=False):
# See issue dask/dask#6516
coeffs, residuals, _, _ = da.linalg.lstsq(lhs_da, rhs)... | diff --git a/xarray/tests/test_duck_array_ops.py b/xarray/tests/test_duck_array_ops.py
--- a/xarray/tests/test_duck_array_ops.py
+++ b/xarray/tests/test_duck_array_ops.py
@@ -20,6 +20,7 @@
mean,
np_timedelta64_to_float,
pd_timedelta_to_float,
+ push,
py_timedelta_to_float,
stack,
timede... | bfill behavior dask arrays with small chunk size
```python
data = np.random.rand(100)
data[25] = np.nan
da = xr.DataArray(data)
#unchunked
print('output : orig',da[25].values, ' backfill : ',da.bfill('dim_0')[25].values )
output : orig nan backfill : 0.024710724099643477
#small chunk
da1 = da.chunk({'dim_0':1})
pr... | Thanks for the clear report. Indeed, this looks like a bug.
`bfill()` and `ffill()` are implemented on dask arrays via `apply_ufunc`, but they're applied independently on each chunk -- there's no filling between chunks:
https://github.com/pydata/xarray/blob/ddacf405fb256714ce01e1c4c464f829e1cc5058/xarray/core/missing.... | 2021-04-18T17:00:51Z | 0.12 | ["xarray/tests/test_duck_array_ops.py::TestArrayNotNullEquiv::test_equal[arr10-arr20]", "xarray/tests/test_duck_array_ops.py::TestArrayNotNullEquiv::test_equal[arr11-arr21]", "xarray/tests/test_duck_array_ops.py::TestArrayNotNullEquiv::test_equal[arr12-arr22]", "xarray/tests/test_duck_array_ops.py::TestArrayNotNullEqui... | [] | 1c198a191127c601d091213c4b3292a8bb3054e1 |
pydata/xarray | pydata__xarray-5365 | 3960ea3ba08f81d211899827612550f6ac2de804 | diff --git a/xarray/__init__.py b/xarray/__init__.py
--- a/xarray/__init__.py
+++ b/xarray/__init__.py
@@ -16,7 +16,16 @@
from .core.alignment import align, broadcast
from .core.combine import combine_by_coords, combine_nested
from .core.common import ALL_DIMS, full_like, ones_like, zeros_like
-from .core.computatio... | diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py
--- a/xarray/tests/test_computation.py
+++ b/xarray/tests/test_computation.py
@@ -1952,3 +1952,110 @@ def test_polyval(use_dask, use_datetime) -> None:
da_pv = xr.polyval(da.x, coeffs)
xr.testing.assert_allclose(da, da_pv.T)
+
... | Feature request: vector cross product
xarray currently has the `xarray.dot()` function for calculating arbitrary dot products which is indeed very handy.
Sometimes, especially for physical applications I also need a vector cross product. I' wondering whether you would be interested in having ` xarray.cross` as a wrappe... | Very useful :+1:
I would add:
```
try:
c.attrs["units"] = a.attrs["units"] + '*' + b.attrs["units"]
except KeyError:
pass
```
to preserve units - but I am not sure that is in scope for xarray.
it is not, but we have been working on [unit aware arrays with `pint`](https://github.com/pydata/xarra... | 2021-05-23T13:03:42Z | 0.18 | ["xarray/tests/test_computation.py::test_cross[a0-b0-ae0-be0-dim_0--1-False]", "xarray/tests/test_computation.py::test_cross[a1-b1-ae1-be1-dim_0--1-False]", "xarray/tests/test_computation.py::test_cross[a2-b2-ae2-be2-dim_0--1-False]", "xarray/tests/test_computation.py::test_cross[a3-b3-ae3-be3-dim_0--1-False]", "xarray... | ["xarray/tests/test_computation.py::test_apply_exclude", "xarray/tests/test_computation.py::test_autocov[None-da_a0]", "xarray/tests/test_computation.py::test_autocov[None-da_a1]", "xarray/tests/test_computation.py::test_autocov[None-da_a2]", "xarray/tests/test_computation.py::test_autocov[None-da_a3]", "xarray/tests/t... | 4f1e2d37b662079e830c9672400fabc19b44a376 |
pydata/xarray | pydata__xarray-6400 | 728b648d5c7c3e22fe3704ba163012840408bf66 | diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py
--- a/xarray/core/formatting.py
+++ b/xarray/core/formatting.py
@@ -520,7 +520,11 @@ def short_numpy_repr(array):
# default to lower precision so a full (abbreviated) line can fit on
# one line with the default display_width
- options = {... | diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py
--- a/xarray/tests/test_formatting.py
+++ b/xarray/tests/test_formatting.py
@@ -479,6 +479,12 @@ def test_short_numpy_repr() -> None:
num_lines = formatting.short_numpy_repr(array).count("\n") + 1
assert num_lines < 30
+ ... | Very poor html repr performance on large multi-indexes
<!-- Please include a self-contained copy-pastable example that generates the issue if possible.
Please be concise with code posted. See guidelines below on how to provide a good bug report:
- Craft Minimal Bug Reports: http://matthewrocklin.com/blog/work/2018/02... | I think it's some lazy calculation that kicks in. Because I can reproduce using np.asarray.
```python
import numpy as np
import xarray as xr
ds = xr.tutorial.load_dataset("air_temperature")
da = ds["air"].stack(z=[...])
coord = da.z.variable.to_index_variable()
# This is very slow:
a = np.asarray(coord)
da._repr_h... | 2022-03-22T12:57:37Z | 2,022.03 | ["xarray/tests/test_formatting.py::test_short_numpy_repr"] | ["xarray/tests/test_formatting.py::TestFormatting::test_array_repr", "xarray/tests/test_formatting.py::TestFormatting::test_array_repr_variable", "xarray/tests/test_formatting.py::TestFormatting::test_attribute_repr", "xarray/tests/test_formatting.py::TestFormatting::test_diff_array_repr", "xarray/tests/test_formatting... | d7931f9014a26e712ff5f30c4082cf0261f045d3 |
pydata/xarray | pydata__xarray-6461 | 851dadeb0338403e5021c3fbe80cbc9127ee672d | diff --git a/xarray/core/computation.py b/xarray/core/computation.py
--- a/xarray/core/computation.py
+++ b/xarray/core/computation.py
@@ -1825,11 +1825,10 @@ def where(cond, x, y, keep_attrs=None):
"""
if keep_attrs is None:
keep_attrs = _get_keep_attrs(default=False)
-
if keep_attrs is True:
... | diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py
--- a/xarray/tests/test_computation.py
+++ b/xarray/tests/test_computation.py
@@ -1928,6 +1928,10 @@ def test_where_attrs() -> None:
expected = xr.DataArray([1, 0], dims="x", attrs={"attr": "x"})
assert_identical(expected, actual... | xr.where with scalar as second argument fails with keep_attrs=True
### What happened?
``` python
import xarray as xr
xr.where(xr.DataArray([1, 2, 3]) > 0, 1, 0)
```
fails with
```
1809 if keep_attrs is True:
1810 # keep the attributes of x, the second parameter, by default to
1811 # be consistent w... | null | 2022-04-09T03:02:40Z | 2,022.03 | ["xarray/tests/test_computation.py::test_where_attrs"] | ["xarray/tests/test_computation.py::test_apply_1d_and_0d", "xarray/tests/test_computation.py::test_apply_exclude", "xarray/tests/test_computation.py::test_apply_groupby_add", "xarray/tests/test_computation.py::test_apply_identity", "xarray/tests/test_computation.py::test_apply_input_core_dimension", "xarray/tests/test_... | d7931f9014a26e712ff5f30c4082cf0261f045d3 |
pydata/xarray | pydata__xarray-6548 | 126051f2bf2ddb7926a7da11b047b852d5ca6b87 | diff --git a/asv_bench/benchmarks/polyfit.py b/asv_bench/benchmarks/polyfit.py
new file mode 100644
--- /dev/null
+++ b/asv_bench/benchmarks/polyfit.py
@@ -0,0 +1,38 @@
+import numpy as np
+
+import xarray as xr
+
+from . import parameterized, randn, requires_dask
+
+NDEGS = (2, 5, 20)
+NX = (10**2, 10**6)
+
+
+class P... | diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py
--- a/xarray/tests/test_computation.py
+++ b/xarray/tests/test_computation.py
@@ -1933,37 +1933,100 @@ def test_where_attrs() -> None:
assert actual.attrs == {}
-@pytest.mark.parametrize("use_dask", [True, False])
-@pytest.mark.pa... | xr.polyval first arg requires name attribute
### What happened?
I have some polynomial coefficients and want to evaluate them at some values using `xr.polyval`.
As described in the docstring/docu I created a 1D coordinate DataArray and pass it to `xr.polyval` but it raises a KeyError (see example).
### What did you... | Actually, I just realized that the second version also does not work since it uses the index of the `coord` argument and not its values. I guess that was meant by "The 1D coordinate along which to evaluate the polynomial".
Would you be open to a PR that allows any DataArray as `coord` argument and evaluates the polyno... | 2022-04-30T14:50:53Z | 2,022.03 | ["xarray/tests/test_computation.py::test_polyval[array-dataset-False]", "xarray/tests/test_computation.py::test_polyval[broadcast-x-False]", "xarray/tests/test_computation.py::test_polyval[dataset-array-False]", "xarray/tests/test_computation.py::test_polyval[dataset-dataset-False]", "xarray/tests/test_computation.py::... | ["xarray/tests/test_computation.py::test_apply_1d_and_0d", "xarray/tests/test_computation.py::test_apply_exclude", "xarray/tests/test_computation.py::test_apply_groupby_add", "xarray/tests/test_computation.py::test_apply_identity", "xarray/tests/test_computation.py::test_apply_input_core_dimension", "xarray/tests/test_... | d7931f9014a26e712ff5f30c4082cf0261f045d3 |
pydata/xarray | pydata__xarray-6889 | 790a444b11c244fd2d33e2d2484a590f8fc000ff | diff --git a/xarray/core/concat.py b/xarray/core/concat.py
--- a/xarray/core/concat.py
+++ b/xarray/core/concat.py
@@ -490,7 +490,7 @@ def _dataset_concat(
)
# determine which variables to merge, and then merge them according to compat
- variables_to_merge = (coord_names | data_names) - concat_over - dim... | diff --git a/xarray/tests/test_concat.py b/xarray/tests/test_concat.py
--- a/xarray/tests/test_concat.py
+++ b/xarray/tests/test_concat.py
@@ -513,6 +513,16 @@ def test_concat_multiindex(self) -> None:
assert expected.equals(actual)
assert isinstance(actual.x.to_index(), pd.MultiIndex)
+ def test... | Alignment of dataset with MultiIndex fails after applying xr.concat
### What happened?
After applying the `concat` function to a dataset with a Multiindex, a lot of functions related to indexing are broken. For example, it is not possible to apply `reindex_like` to itself anymore.
The error is raised in the alignm... | null | 2022-08-08T13:12:45Z | 2,022.06 | ["xarray/tests/test_concat.py::TestConcatDataset::test_concat_along_new_dim_multiindex"] | ["xarray/tests/test_concat.py::TestConcatDataArray::test_concat", "xarray/tests/test_concat.py::TestConcatDataArray::test_concat_combine_attrs_kwarg", "xarray/tests/test_concat.py::TestConcatDataArray::test_concat_coord_name", "xarray/tests/test_concat.py::TestConcatDataArray::test_concat_encoding", "xarray/tests/test_... | 50ea159bfd0872635ebf4281e741f3c87f0bef6b |
pydata/xarray | pydata__xarray-6999 | 1f4be33365573da19a684dd7f2fc97ace5d28710 | diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py
--- a/xarray/core/dataarray.py
+++ b/xarray/core/dataarray.py
@@ -2032,11 +2032,11 @@ def rename(
if utils.is_dict_like(new_name_or_name_dict) or new_name_or_name_dict is None:
# change dims/coords
name_dict = either_dic... | diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py
--- a/xarray/tests/test_dataarray.py
+++ b/xarray/tests/test_dataarray.py
@@ -1742,6 +1742,23 @@ def test_rename(self) -> None:
)
assert_identical(renamed_all, expected_all)
+ def test_rename_dimension_coord_warnings(sel... | [Bug]: rename_vars to dimension coordinate does not create an index
### What happened?
We used `Data{set,Array}.rename{_vars}({coord: dim_coord})` to make a coordinate a dimension coordinate (instead of `set_index`).
This results in the coordinate correctly being displayed as a dimension coordinate (with the *) but it... | This has been discussed in #4825.
A third option for `rename{_vars}` would be to rename the coordinate and its index (if any), regardless of whether the old and new names correspond to existing dimensions. We plan to drop the concept of a "dimension coordinate" with an implicit index in favor of indexes explicitly par... | 2022-09-06T16:16:17Z | 2,022.06 | ["xarray/tests/test_dataarray.py::TestDataArray::test_rename_dimension_coord_warnings", "xarray/tests/test_dataset.py::TestDataset::test_rename_dimension_coord_warnings"] | ["xarray/tests/test_dataarray.py::TestDataArray::test__title_for_slice", "xarray/tests/test_dataarray.py::TestDataArray::test__title_for_slice_truncate", "xarray/tests/test_dataarray.py::TestDataArray::test_align", "xarray/tests/test_dataarray.py::TestDataArray::test_align_copy", "xarray/tests/test_dataarray.py::TestDa... | 50ea159bfd0872635ebf4281e741f3c87f0bef6b |
pydata/xarray | pydata__xarray-7003 | 5bec4662a7dd4330eca6412c477ca3f238323ed2 | diff --git a/xarray/core/indexes.py b/xarray/core/indexes.py
--- a/xarray/core/indexes.py
+++ b/xarray/core/indexes.py
@@ -1092,12 +1092,13 @@ def get_unique(self) -> list[T_PandasOrXarrayIndex]:
"""Return a list of unique indexes, preserving order."""
unique_indexes: list[T_PandasOrXarrayIndex] = [... | diff --git a/xarray/tests/test_indexes.py b/xarray/tests/test_indexes.py
--- a/xarray/tests/test_indexes.py
+++ b/xarray/tests/test_indexes.py
@@ -9,6 +9,7 @@
import xarray as xr
from xarray.core.indexes import (
+ Hashable,
Index,
Indexes,
PandasIndex,
@@ -535,7 +536,7 @@ def test_copy(self) -> N... | Indexes.get_unique() TypeError with pandas indexes
@benbovy I also just tested the `get_unique()` method that you mentioned and maybe noticed a related issue here, which I'm not sure is wanted / expected.
Taking the above dataset `ds`, accessing this function results in an error:
```python
> ds.indexes.get_unique()
... | null | 2022-09-07T11:05:02Z | 2,022.06 | ["xarray/tests/test_indexes.py::TestIndexes::test_copy_indexes[pd_index]", "xarray/tests/test_indexes.py::TestIndexes::test_get_unique[pd_index]", "xarray/tests/test_indexes.py::TestIndexes::test_group_by_index[pd_index]"] | ["xarray/tests/test_indexes.py::TestIndex::test_concat", "xarray/tests/test_indexes.py::TestIndex::test_copy[False]", "xarray/tests/test_indexes.py::TestIndex::test_copy[True]", "xarray/tests/test_indexes.py::TestIndex::test_create_variables", "xarray/tests/test_indexes.py::TestIndex::test_equals", "xarray/tests/test_i... | 50ea159bfd0872635ebf4281e741f3c87f0bef6b |
pydata/xarray | pydata__xarray-7019 | 964d350a80fe21d4babf939c108986d5fd90a2cf | diff --git a/xarray/backends/api.py b/xarray/backends/api.py
--- a/xarray/backends/api.py
+++ b/xarray/backends/api.py
@@ -6,7 +6,16 @@
from glob import glob
from io import BytesIO
from numbers import Number
-from typing import TYPE_CHECKING, Any, Callable, Final, Literal, Union, cast, overload
+from typing import (... | diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py
--- a/xarray/tests/test_dask.py
+++ b/xarray/tests/test_dask.py
@@ -904,13 +904,12 @@ def test_to_dask_dataframe_dim_order(self):
@pytest.mark.parametrize("method", ["load", "compute"])
def test_dask_kwargs_variable(method):
- x = Variable("y", d... | Alternative parallel execution frameworks in xarray
### Is your feature request related to a problem?
Since early on the project xarray has supported wrapping `dask.array` objects in a first-class manner. However recent work on flexible array wrapping has made it possible to wrap all sorts of array types (and with #68... | This sounds great! We should finish up https://github.com/pydata/xarray/pull/4972 to make it easier to test.
Another parallel framework would be [Ramba](https://github.com/Python-for-HPC/ramba)
cc @DrTodd13
Sounds good to me. The challenge will be defining a parallel computing API that works across all these projects... | 2022-09-10T22:02:18Z | 2,022.06 | ["xarray/tests/test_parallelcompat.py::TestGetChunkManager::test_dont_get_dask_if_not_installed", "xarray/tests/test_parallelcompat.py::TestGetChunkManager::test_fail_on_nonexistent_chunkmanager", "xarray/tests/test_parallelcompat.py::TestGetChunkManager::test_get_chunkmanger", "xarray/tests/test_parallelcompat.py::Tes... | [] | 50ea159bfd0872635ebf4281e741f3c87f0bef6b |
pydata/xarray | pydata__xarray-7120 | 58ab594aa4315e75281569902e29c8c69834151f | diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py
--- a/xarray/core/dataset.py
+++ b/xarray/core/dataset.py
@@ -5401,6 +5401,13 @@ def transpose(
numpy.transpose
DataArray.transpose
"""
+ # Raise error if list is passed as dims
+ if (len(dims) > 0) and (isinstance(dim... | diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py
--- a/xarray/tests/test_dataset.py
+++ b/xarray/tests/test_dataset.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import pickle
+import re
import sys
import warnings
from copy import copy, deepcopy
@@ -6806,3 +6807,17 @@ def test_str... | Raise nicer error if passing a list of dimension names to transpose
### What happened?
Hello,
in xarray 0.20.1, I am getting the following error
`ds = xr.Dataset({"foo": (("x", "y", "z"), [[[42]]]), "bar": (("y", "z"), [[24]])})`
`ds.transpose("y", "z", "x")`
```
868 """Depending on the setting of missing_dims, d... | I can't reproduce on our dev branch. Can you try upgrading xarray please?
EDIT: can't reproduce on 2022.03.0 either.
Thanks. I upgraded to 2022.03.0
I am still getting the error
```
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" f... | 2022-10-03T23:53:43Z | 2,022.09 | ["xarray/tests/test_dataset.py::test_transpose_error"] | ["xarray/tests/test_dataset.py::TestDataset::test_align", "xarray/tests/test_dataset.py::TestDataset::test_align_exact", "xarray/tests/test_dataset.py::TestDataset::test_align_exclude", "xarray/tests/test_dataset.py::TestDataset::test_align_fill_value[2.0]", "xarray/tests/test_dataset.py::TestDataset::test_align_fill_v... | 087ebbb78668bdf5d2d41c3b2553e3f29ce75be1 |
pydata/xarray | pydata__xarray-7150 | f93b467db5e35ca94fefa518c32ee9bf93232475 | diff --git a/xarray/backends/api.py b/xarray/backends/api.py
--- a/xarray/backends/api.py
+++ b/xarray/backends/api.py
@@ -234,7 +234,7 @@ def _get_mtime(filename_or_obj):
def _protect_dataset_variables_inplace(dataset, cache):
for name, variable in dataset.variables.items():
- if name not in variable.di... | diff --git a/xarray/tests/test_backends_api.py b/xarray/tests/test_backends_api.py
--- a/xarray/tests/test_backends_api.py
+++ b/xarray/tests/test_backends_api.py
@@ -48,6 +48,25 @@ def open_dataset(
assert_identical(expected, actual)
+def test_multiindex() -> None:
+ # GH7139
+ # Check that we properly ... | xarray.open_dataset has issues if the dataset returned by the backend contains a multiindex
### What happened?
As a follow up of this comment: https://github.com/pydata/xarray/issues/6752#issuecomment-1236756285 I'm currently trying to implement a custom `NetCDF4` backend that allows me to also handle multiindices whe... | Hi @lukasbindreiter, could you add the whole error traceback please?
I can see this type of decoding breaking some assumption in the file reading process. A full traceback would help identify where.
I think the real solution is actually #4490, so you could explicitly provide a coder.
Here is the full stacktrace:
```p... | 2022-10-10T13:03:26Z | 2,022.09 | ["xarray/tests/test_backends_api.py::test_multiindex"] | ["xarray/tests/test_backends_api.py::test_custom_engine"] | 087ebbb78668bdf5d2d41c3b2553e3f29ce75be1 |
pydata/xarray | pydata__xarray-7391 | f128f248f87fe0442c9b213c2772ea90f91d168b | diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py
--- a/xarray/core/dataset.py
+++ b/xarray/core/dataset.py
@@ -6592,6 +6592,9 @@ def _binary_op(self, other, f, reflexive=False, join=None) -> Dataset:
self, other = align(self, other, join=align_type, copy=False) # type: ignore[assignment]
... | diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py
--- a/xarray/tests/test_dataset.py
+++ b/xarray/tests/test_dataset.py
@@ -5849,6 +5849,21 @@ def test_binary_op_join_setting(self) -> None:
actual = ds1 + ds2
assert_equal(actual, expected)
+ @pytest.mark.parametrize... | `Dataset` binary ops ignore `keep_attrs` option
### What is your issue?
When doing arithmetic operations on two Dataset operands,
the `keep_attrs=True` option is ignored and therefore attributes not kept.
Minimal example:
```python
import xarray as xr
ds1 = xr.Dataset(
data_vars={"a": 1, "b": 1},
attrs={'... | null | 2022-12-19T20:42:20Z | 2,022.09 | ["xarray/tests/test_dataset.py::TestDataset::test_binary_ops_keep_attrs[True]"] | ["xarray/tests/test_dataset.py::TestDataset::test_align", "xarray/tests/test_dataset.py::TestDataset::test_align_exact", "xarray/tests/test_dataset.py::TestDataset::test_align_exclude", "xarray/tests/test_dataset.py::TestDataset::test_align_fill_value[2.0]", "xarray/tests/test_dataset.py::TestDataset::test_align_fill_v... | 087ebbb78668bdf5d2d41c3b2553e3f29ce75be1 |
pydata/xarray | pydata__xarray-7393 | 41fef6f1352be994cd90056d47440fe9aa4c068f | diff --git a/xarray/core/indexing.py b/xarray/core/indexing.py
--- a/xarray/core/indexing.py
+++ b/xarray/core/indexing.py
@@ -1531,8 +1531,12 @@ def __init__(
self.level = level
def __array__(self, dtype: DTypeLike = None) -> np.ndarray:
+ if dtype is None:
+ dtype = self.dtype
... | diff --git a/xarray/tests/test_indexes.py b/xarray/tests/test_indexes.py
--- a/xarray/tests/test_indexes.py
+++ b/xarray/tests/test_indexes.py
@@ -697,3 +697,10 @@ def test_safe_cast_to_index_datetime_datetime():
actual = safe_cast_to_index(np.array(dates))
assert_array_equal(expected, actual)
assert isi... | stack casts int32 dtype coordinate to int64
### What happened?
The code example below results in `False`, because the data type of the `a` coordinate is changed from 'i4' to 'i8'.
### What did you expect to happen?
I expect the result to be `True`. Creating a MultiIndex should not change the data type of the Indexes... | Unfortunately this is a pandas thing, so we can't fix it. Pandas only provides `Int64Index` so everything gets cast to that. Fixing that is on the roadmap for pandas 2.0 I think (See https://github.com/pandas-dev/pandas/pull/44819#issuecomment-999790361)
Darn. Well, to help this be more transparent, I think it would be... | 2022-12-20T04:34:24Z | 2,022.09 | ["xarray/tests/test_indexes.py::test_restore_dtype_on_multiindexes[float32]", "xarray/tests/test_indexes.py::test_restore_dtype_on_multiindexes[int32]"] | ["xarray/tests/test_indexes.py::TestIndex::test_concat", "xarray/tests/test_indexes.py::TestIndex::test_copy[False]", "xarray/tests/test_indexes.py::TestIndex::test_copy[True]", "xarray/tests/test_indexes.py::TestIndex::test_create_variables", "xarray/tests/test_indexes.py::TestIndex::test_equals", "xarray/tests/test_i... | 087ebbb78668bdf5d2d41c3b2553e3f29ce75be1 |
pylint-dev/pylint | pylint-dev__pylint-4175 | ae6cbd1062c0a8e68d32a5cdc67c993da26d0f4a | diff --git a/pylint/lint/parallel.py b/pylint/lint/parallel.py
--- a/pylint/lint/parallel.py
+++ b/pylint/lint/parallel.py
@@ -160,7 +160,7 @@ def check_parallel(linter, jobs, files, arguments=None):
pool.join()
_merge_mapreduce_data(linter, all_mapreduce_data)
- linter.stats = _merge_stats(all_stats... | diff --git a/tests/test_check_parallel.py b/tests/test_check_parallel.py
--- a/tests/test_check_parallel.py
+++ b/tests/test_check_parallel.py
@@ -67,6 +67,68 @@ def process_module(self, _astroid):
self.data.append(record)
+class ParallelTestChecker(BaseChecker):
+ """A checker that does need to consoli... | Pylint 2.7.0 seems to ignore the min-similarity-lines setting
<!--
Hi there! Thank you for discovering and submitting an issue.
Before you submit this, make sure that the issue doesn't already exist
or if it is not closed.
Is your issue fixed on the preview release?: pip install pylint astroid --pre -U
-->
... | We are seeing the same problem. All of our automated builds failed this morning.
``` bash
$ pylint --version
pylint 2.7.0
astroid 2.5
Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
```
**Workaround**
Reverting back to pylint 2.6.2.
My projects pass if I disable `--jobs=N` ... | 2021-03-02T15:18:14Z | 2.1 | ["tests/test_check_parallel.py::TestCheckParallel::test_map_reduce[10-2-1]", "tests/test_check_parallel.py::TestCheckParallel::test_map_reduce[10-2-2]", "tests/test_check_parallel.py::TestCheckParallel::test_map_reduce[10-2-3]", "tests/test_check_parallel.py::TestCheckParallel::test_map_reduce[2-10-1]", "tests/test_che... | ["tests/test_check_parallel.py::TestCheckParallel::test_compare_workers_to_single_proc[1-2-1]", "tests/test_check_parallel.py::TestCheckParallel::test_compare_workers_to_single_proc[1-2-2]", "tests/test_check_parallel.py::TestCheckParallel::test_compare_workers_to_single_proc[1-2-3]", "tests/test_check_parallel.py::Tes... | bc95cd34071ec2e71de5bca8ff95cc9b88e23814 |
pylint-dev/pylint | pylint-dev__pylint-4516 | 0b5a44359d8255c136af27c0ef5f5b196a526430 | diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py
--- a/pylint/lint/expand_modules.py
+++ b/pylint/lint/expand_modules.py
@@ -1,5 +1,6 @@
import os
import sys
+from typing import List, Pattern, Tuple
from astroid import modutils
@@ -28,32 +29,33 @@ def get_python_path(filepath: str) -> s... | diff --git a/tests/lint/unittest_expand_modules.py b/tests/lint/unittest_expand_modules.py
--- a/tests/lint/unittest_expand_modules.py
+++ b/tests/lint/unittest_expand_modules.py
@@ -7,19 +7,29 @@
import pytest
-from pylint.lint.expand_modules import _basename_in_ignore_list_re, expand_modules
+from pylint.lint.ex... | Ignore clause not ignoring directories
This is a different issue to [issues/908](https://github.com/PyCQA/pylint/issues/908).
### Steps to reproduce
1. Create a directory `test` and within that a directory `stuff`.
2. Create files `test/a.py` and `test/stuff/b.py`. Put syntax errors in both.
3. From `test`, run `pylin... | The problem seems to be in `utils.expand_modules()` in which we find the code that actually performs the ignoring:
```python
if os.path.basename(something) in black_list:
continue
if _basename_in_blacklist_re(os.path.basename(something), black_list_re):
continue
```
Here `something` will be of the form `"stuff... | 2021-05-26T15:15:27Z | 2.8 | ["tests/lint/unittest_expand_modules.py::test__is_in_ignore_list_re_match", "tests/lint/unittest_expand_modules.py::test__is_in_ignore_list_re_nomatch", "tests/lint/unittest_expand_modules.py::test_expand_modules[files_or_modules0-expected0]", "tests/lint/unittest_expand_modules.py::test_expand_modules[files_or_modules... | [] | 49a6206c7756307844c1c32c256afdf9836d7bce |
pylint-dev/pylint | pylint-dev__pylint-5201 | 772b3dcc0b0770a843653783e5c93b4256e5ec6f | diff --git a/pylint/config/option.py b/pylint/config/option.py
--- a/pylint/config/option.py
+++ b/pylint/config/option.py
@@ -3,7 +3,9 @@
import copy
import optparse # pylint: disable=deprecated-module
+import pathlib
import re
+from typing import List, Pattern
from pylint import utils
@@ -25,6 +27,19 @@ de... | diff --git a/tests/lint/unittest_expand_modules.py b/tests/lint/unittest_expand_modules.py
--- a/tests/lint/unittest_expand_modules.py
+++ b/tests/lint/unittest_expand_modules.py
@@ -4,10 +4,14 @@
import re
from pathlib import Path
+from typing import Dict, Tuple, Type
import pytest
+from pylint.checkers impor... | ignore-paths: normalize path to PosixPath
### Current problem
In a project of mine, there is an entire directory, "dummy", that I want to exclude running pylint in. I've added the directory name to the "ignore" option and it works great when used from the command line.
```toml
# Files or directories to be skipped. T... | Thank you for opening the issue, this seems like a sensible thing to do. | 2021-10-23T10:09:51Z | 2.11 | ["tests/lint/unittest_expand_modules.py::TestExpandModules::test_expand_modules[files_or_modules0-expected0]", "tests/lint/unittest_expand_modules.py::TestExpandModules::test_expand_modules[files_or_modules1-expected1]", "tests/lint/unittest_expand_modules.py::TestExpandModules::test_expand_modules_with_ignore[files_or... | ["tests/lint/unittest_expand_modules.py::test__is_in_ignore_list_re_match", "tests/unittest_config.py::test__csv_validator_no_spaces", "tests/unittest_config.py::test__csv_validator_spaces", "tests/unittest_config.py::test__regexp_csv_validator_invalid", "tests/unittest_config.py::test__regexp_csv_validator_valid", "te... | 2c687133e4fcdd73ae3afa2e79be2160b150bb82 |
pylint-dev/pylint | pylint-dev__pylint-5446 | a1df7685a4e6a05b519ea011f16a2f0d49d08032 | diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -381,10 +381,19 @@ def append_stream(
else:
readlines = stream.readlines # type: ignore[assignment] # hint parameter is incorrectly typed as non-optional
... | diff --git a/tests/regrtest_data/duplicate_data_raw_strings/__init__.py b/tests/regrtest_data/duplicate_code/raw_strings_all/__init__.py
similarity index 100%
rename from tests/regrtest_data/duplicate_data_raw_strings/__init__.py
rename to tests/regrtest_data/duplicate_code/raw_strings_all/__init__.py
diff --git a/test... | The duplicate-code (R0801) can't be disabled
Originally reported by: **Anonymous**
---
It's seems like it's not possible to disable the duplicate code check on portions of a file. Looking at the source, I can see why as it's not a trivial thing to do (if you want to maintain the same scope semantics as other #pylint:... | _Original comment by_ **Radek Holý (BitBucket: [PyDeq](http://bitbucket.org/PyDeq), GitHub: @PyDeq?)**:
---
Pylint marks even import blocks as duplicates. In my case, it is:
```
#!python
import contextlib
import io
import itertools
import os
import subprocess
import tempfile
```
I doubt it is possible to clean up/... | 2021-11-30T16:56:42Z | 2.13 | ["tests/test_similar.py::TestSimilarCodeChecker::test_duplicate_code_raw_strings_disable_file_double", "tests/test_similar.py::TestSimilarCodeChecker::test_duplicate_code_raw_strings_disable_line_disable_all", "tests/test_similar.py::TestSimilarCodeChecker::test_duplicate_code_raw_strings_disable_line_midle", "tests/te... | ["tests/test_self.py::TestRunTC::test_abbreviations_are_not_supported", "tests/test_self.py::TestRunTC::test_all", "tests/test_self.py::TestRunTC::test_allow_import_of_files_found_in_modules_during_parallel_check", "tests/test_self.py::TestRunTC::test_bom_marker", "tests/test_self.py::TestRunTC::test_can_list_directori... | 3b2fbaec045697d53bdd4435e59dbfc2b286df4b |
pylint-dev/pylint | pylint-dev__pylint-6059 | 789a3818fec81754cf95bef2a0b591678142c227 | diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py
--- a/pylint/checkers/base_checker.py
+++ b/pylint/checkers/base_checker.py
@@ -61,7 +61,15 @@ def __init__(
def __gt__(self, other):
"""Permit to sort a list of Checker by name."""
- return f"{self.name}{self.msgs}" >... | diff --git a/tests/checkers/unittest_base_checker.py b/tests/checkers/unittest_base_checker.py
--- a/tests/checkers/unittest_base_checker.py
+++ b/tests/checkers/unittest_base_checker.py
@@ -33,6 +33,17 @@ class LessBasicChecker(OtherBasicChecker):
)
+class DifferentBasicChecker(BaseChecker):
+ name = "diff... | Is `BaseChecker.__gt__` required
### Bug description
As noted by @DanielNoord [here](https://github.com/PyCQA/pylint/pull/5938#discussion_r837867526), [`BaseCheck.__gt__`](https://github.com/PyCQA/pylint/blob/742e60dc07077cdd3338dffc3bb809cd4c27085f/pylint/checkers/base_checker.py#L62-L64) is not currently covered. If... | I think this was used originally to be able to assert that a list of checker is equal to another one in tests. If it's not covered it means we do not do that anymore.
It's used in Sphinx and maybe downstream libraries see #6047 .
Shall we add a no coverage param then?
It's pretty easy to add a unit test for this so wi... | 2022-03-30T18:23:36Z | 2.14 | ["tests/checkers/unittest_base_checker.py::test_base_checker_ordering"] | ["tests/checkers/unittest_base_checker.py::test_base_checker_doc"] | 680edebc686cad664bbed934a490aeafa775f163 |
pylint-dev/pylint | pylint-dev__pylint-6386 | 754b487f4d892e3d4872b6fc7468a71db4e31c13 | diff --git a/pylint/config/argument.py b/pylint/config/argument.py
--- a/pylint/config/argument.py
+++ b/pylint/config/argument.py
@@ -457,6 +457,7 @@ def __init__(
kwargs: dict[str, Any],
hide_help: bool,
section: str | None,
+ metavar: str,
) -> None:
super().__init__(
... | diff --git a/tests/config/test_config.py b/tests/config/test_config.py
--- a/tests/config/test_config.py
+++ b/tests/config/test_config.py
@@ -100,3 +100,10 @@ def test_unknown_py_version(capsys: CaptureFixture) -> None:
Run([str(EMPTY_MODULE), "--py-version=the-newest"], exit=False)
output = capsys.reado... | Argument expected for short verbose option
### Bug description
The short option of the `verbose` option expects an argument.
Also, the help message for the `verbose` option suggests a value `VERBOSE` should be provided.
The long option works ok & doesn't expect an argument:
`pylint mytest.py --verbose`
### Command ... | null | 2022-04-19T06:34:57Z | 2.14 | ["tests/config/test_config.py::test_short_verbose"] | ["tests/config/test_config.py::test_can_read_toml_env_variable", "tests/config/test_config.py::test_unknown_confidence", "tests/config/test_config.py::test_unknown_message_id", "tests/config/test_config.py::test_unknown_option_name", "tests/config/test_config.py::test_unknown_py_version", "tests/config/test_config.py::... | 680edebc686cad664bbed934a490aeafa775f163 |
pylint-dev/pylint | pylint-dev__pylint-6517 | 58c4f370c7395d9d4e202ba83623768abcc3ac24 | diff --git a/pylint/config/argument.py b/pylint/config/argument.py
--- a/pylint/config/argument.py
+++ b/pylint/config/argument.py
@@ -44,6 +44,8 @@
def _confidence_transformer(value: str) -> Sequence[str]:
"""Transforms a comma separated string of confidence values."""
+ if not value:
+ return interf... | diff --git a/tests/config/test_config.py b/tests/config/test_config.py
--- a/tests/config/test_config.py
+++ b/tests/config/test_config.py
@@ -10,6 +10,7 @@
import pytest
from pytest import CaptureFixture
+from pylint.interfaces import CONFIDENCE_LEVEL_NAMES
from pylint.lint import Run as LintRun
from pylint.test... | Pylint runs unexpectedly pass if `confidence=` in pylintrc
### Bug description
Runs unexpectedly pass in 2.14 if a pylintrc file has `confidence=`.
(Default pylintrc files have `confidence=`. `pylint`'s own config was fixed in #6140 to comment it out, but this might bite existing projects.)
```python
import time
```... | The documentation of the option says "Leave empty to show all."
```diff
diff --git a/pylint/config/argument.py b/pylint/config/argument.py
index 8eb6417dc..bbaa7d0d8 100644
--- a/pylint/config/argument.py
+++ b/pylint/config/argument.py
@@ -44,6 +44,8 @@ _ArgumentTypes = Union[
def _confidence_transformer(value: str... | 2022-05-05T22:04:31Z | 2.14 | ["tests/config/test_config.py::test_empty_confidence"] | ["tests/config/test_config.py::test_can_read_toml_env_variable", "tests/config/test_config.py::test_short_verbose", "tests/config/test_config.py::test_unknown_confidence", "tests/config/test_config.py::test_unknown_message_id", "tests/config/test_config.py::test_unknown_option_name", "tests/config/test_config.py::test_... | 680edebc686cad664bbed934a490aeafa775f163 |
pylint-dev/pylint | pylint-dev__pylint-6528 | 273a8b25620467c1e5686aa8d2a1dbb8c02c78d0 | diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py
--- a/pylint/lint/expand_modules.py
+++ b/pylint/lint/expand_modules.py
@@ -46,6 +46,20 @@ def _is_in_ignore_list_re(element: str, ignore_list_re: list[Pattern[str]]) -> b
return any(file_pattern.match(element) for file_pattern in ignore_li... | diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py
--- a/tests/lint/unittest_lint.py
+++ b/tests/lint/unittest_lint.py
@@ -864,6 +864,49 @@ def test_by_module_statement_value(initialized_linter: PyLinter) -> None:
assert module_stats["statement"] == linter2.stats.statement
+@pytest.mark... | Pylint does not respect ignores in `--recursive=y` mode
### Bug description
Pylint does not respect the `--ignore`, `--ignore-paths`, or `--ignore-patterns` setting when running in recursive mode. This contradicts the documentation and seriously compromises the usefulness of recursive mode.
### Configuration
_No res... | I suppose that ignored paths needs to be filtered here:
https://github.com/PyCQA/pylint/blob/0220a39f6d4dddd1bf8f2f6d83e11db58a093fbe/pylint/lint/pylinter.py#L676 | 2022-05-06T21:03:37Z | 2.14 | ["tests/lint/unittest_lint.py::test_recursive_ignore[--ignore-ignored_subdirectory]", "tests/lint/unittest_lint.py::test_recursive_ignore[--ignore-patterns-ignored_*]", "tests/test_self.py::TestRunTC::test_ignore_pattern_recursive", "tests/test_self.py::TestRunTC::test_ignore_recursive"] | ["tests/lint/unittest_lint.py::test_addmessage", "tests/lint/unittest_lint.py::test_addmessage_invalid", "tests/lint/unittest_lint.py::test_analyze_explicit_script", "tests/lint/unittest_lint.py::test_by_module_statement_value", "tests/lint/unittest_lint.py::test_custom_should_analyze_file", "tests/lint/unittest_lint.p... | 680edebc686cad664bbed934a490aeafa775f163 |
pylint-dev/pylint | pylint-dev__pylint-6556 | fa183c7d15b5f3c7dd8dee86fc74caae42c3926c | diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py
--- a/pylint/lint/pylinter.py
+++ b/pylint/lint/pylinter.py
@@ -937,8 +937,6 @@ def _check_astroid_module(
self.process_tokens(tokens)
if self._ignore_file:
return False
- # walk ast to collect line numb... | diff --git a/tests/functional/b/bad_option_value_disable.py b/tests/functional/b/bad_option_value_disable.py
new file mode 100644
--- /dev/null
+++ b/tests/functional/b/bad_option_value_disable.py
@@ -0,0 +1,14 @@
+"""Tests for the disabling of bad-option-value."""
+# pylint: disable=invalid-name
+
+# pylint: disable=b... | Can't disable bad-option-value
### Steps to reproduce
1. Write code on a computer with a somewhat new pylint (2.4.3 in my example). Get a warning like `useless-object-inheritance` that I want to ignore, as I'm writing code compatible with python2 and python3.
2. Disable said warning with `# pylint: disable=useless-obje... | Thanks for the report, this is definitely something we should be able to fix.
Hi. It seems to work when it's on the same line but not globally (which could be useful but I didn't found anything on the documentation). So I have to do:
`# pylint: disable=bad-option-value,useless-object-inheritance`
If I later want to use... | 2022-05-09T07:24:39Z | 2.14 | ["tests/lint/unittest_lint.py::test_enable_message_block", "tests/test_deprecation.py::test_collectblocklines"] | ["tests/lint/unittest_lint.py::test_addmessage", "tests/lint/unittest_lint.py::test_addmessage_invalid", "tests/lint/unittest_lint.py::test_analyze_explicit_script", "tests/lint/unittest_lint.py::test_by_module_statement_value", "tests/lint/unittest_lint.py::test_custom_should_analyze_file", "tests/lint/unittest_lint.p... | 680edebc686cad664bbed934a490aeafa775f163 |
pylint-dev/pylint | pylint-dev__pylint-7993 | e90702074e68e20dc8e5df5013ee3ecf22139c3e | diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py
--- a/pylint/reporters/text.py
+++ b/pylint/reporters/text.py
@@ -175,7 +175,7 @@ def on_set_current_module(self, module: str, filepath: str | None) -> None:
self._template = template
# Check to see if all parameters in the template ar... | diff --git a/tests/reporters/unittest_reporting.py b/tests/reporters/unittest_reporting.py
--- a/tests/reporters/unittest_reporting.py
+++ b/tests/reporters/unittest_reporting.py
@@ -14,6 +14,7 @@
from typing import TYPE_CHECKING
import pytest
+from _pytest.recwarn import WarningsRecorder
from pylint import chec... | Using custom braces in message template does not work
### Bug description
Have any list of errors:
On pylint 1.7 w/ python3.6 - I am able to use this as my message template
```
$ pylint test.py --msg-template='{{ "Category": "{category}" }}'
No config file found, using default configuration
************* Module [reda... | Subsequently, there is also this behavior with the quotes
```
$ pylint test.py --msg-template='"Category": "{category}"'
************* Module test
Category": "convention
Category": "error
Category": "error
Category": "convention
Category": "convention
Category": "error
$ pylint test.py --msg-template='""Category": "{c... | 2022-12-27T18:20:50Z | 2.15 | ["tests/reporters/unittest_reporting.py::test_template_option_with_header"] | ["tests/reporters/unittest_reporting.py::test_deprecation_set_output", "tests/reporters/unittest_reporting.py::test_display_results_is_renamed", "tests/reporters/unittest_reporting.py::test_multi_format_output", "tests/reporters/unittest_reporting.py::test_multi_reporter_independant_messages", "tests/reporters/unittest... | e90702074e68e20dc8e5df5013ee3ecf22139c3e |
pylint-dev/pylint | pylint-dev__pylint-8124 | eb950615d77a6b979af6e0d9954fdb4197f4a722 | diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py
--- a/pylint/checkers/imports.py
+++ b/pylint/checkers/imports.py
@@ -439,6 +439,15 @@ class ImportsChecker(DeprecatedMixin, BaseChecker):
"help": "Allow wildcard imports from modules that define __all__.",
},
),... | diff --git a/tests/checkers/unittest_imports.py b/tests/checkers/unittest_imports.py
--- a/tests/checkers/unittest_imports.py
+++ b/tests/checkers/unittest_imports.py
@@ -137,3 +137,46 @@ def test_preferred_module(capsys: CaptureFixture[str]) -> None:
assert "Prefer importing 'sys' instead of 'os'" in output
... | false positive 'useless-import-alias' error for mypy-compatible explicit re-exports
### Bug description
Suppose a package has the following layout:
```console
package/
_submodule1.py # defines Api1
_submodule2.py # defines Api2
__init__.py # imports and re-exports Api1 and Api2
```
Since the submodules her... | > The reason for the as aliases here is to be explicit that these imports are for the purpose of re-export (without having to resort to defining __all__, which is error-prone).
I think ``__all__``is the way to be explicit about the API of a module.That way you have the API documented in one place at the top of the mod... | 2023-01-27T23:46:57Z | 2.16 | ["tests/checkers/unittest_imports.py::TestImportsChecker::test_allow_reexport_package"] | ["tests/checkers/unittest_imports.py::TestImportsChecker::test_preferred_module", "tests/checkers/unittest_imports.py::TestImportsChecker::test_relative_beyond_top_level", "tests/checkers/unittest_imports.py::TestImportsChecker::test_relative_beyond_top_level_four", "tests/checkers/unittest_imports.py::TestImportsCheck... | ff8cdd2b4096c44854731aba556f8a948ff9b3c4 |
pylint-dev/pylint | pylint-dev__pylint-8169 | 4689b195d8539ef04fd0c30423037a5f4932a20f | diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -2933,7 +2933,7 @@ def _check_module_attrs(
break
try:
module = next(module.getattr(name)[0].infer())
- if modul... | diff --git a/tests/regrtest_data/pkg_mod_imports/__init__.py b/tests/regrtest_data/pkg_mod_imports/__init__.py
new file mode 100644
--- /dev/null
+++ b/tests/regrtest_data/pkg_mod_imports/__init__.py
@@ -0,0 +1,6 @@
+base = [
+ 'Exchange',
+ 'Precise',
+ 'exchanges',
+ 'decimal_to_precision',
+]
diff --git ... | False positive `no-name-in-module` when importing from ``from ccxt.base.errors`` even when using the ``ignored-modules`` option
### Bug description
Simply importing exceptions from the [`ccxt`](https://github.com/ccxt/ccxt) library is giving this error. Here's an example of how we import them:
```python
from ccxt.bas... | Could you upgrade to at least 2.15.10 (better yet 2.16.0b1) and confirm the issue still exists, please ?
Tried with
```
pylint 2.15.10
astroid 2.13.4
Python 3.9.16 (main, Dec 7 2022, 10:16:11)
[Clang 14.0.0 (clang-1400.0.29.202)]
```
and also with pylint 2.16.0b1 and I still get the same issue.
Thank you ! I can repr... | 2023-02-02T12:18:35Z | 2.17 | ["tests/test_self.py::TestRunTC::test_no_name_in_module"] | ["tests/test_self.py::TestCallbackOptions::test_enable_all_extensions", "tests/test_self.py::TestCallbackOptions::test_errors_only", "tests/test_self.py::TestCallbackOptions::test_errors_only_functions_as_disable", "tests/test_self.py::TestCallbackOptions::test_generate_config_disable_symbolic_names", "tests/test_self.... | 80e024af5cfdc65a2b9fef1f25ff602ab4fa0f88 |
pylint-dev/pylint | pylint-dev__pylint-8929 | f40e9ffd766bb434a0181dd9db3886115d2dfb2f | diff --git a/pylint/interfaces.py b/pylint/interfaces.py
--- a/pylint/interfaces.py
+++ b/pylint/interfaces.py
@@ -35,3 +35,4 @@ class Confidence(NamedTuple):
CONFIDENCE_LEVELS = [HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, UNDEFINED]
CONFIDENCE_LEVEL_NAMES = [i.name for i in CONFIDENCE_LEVELS]
+CONFIDENCE_MA... | diff --git a/tests/reporters/unittest_json_reporter.py b/tests/reporters/unittest_json_reporter.py
--- a/tests/reporters/unittest_json_reporter.py
+++ b/tests/reporters/unittest_json_reporter.py
@@ -8,15 +8,16 @@
import json
from io import StringIO
+from pathlib import Path
from typing import Any
import pytest
... | Exporting to JSON does not honor score option
<!--
Hi there! Thank you for discovering and submitting an issue.
Before you submit this, make sure that the issue doesn't already exist
or if it is not closed.
Is your issue fixed on the preview release?: pip install pylint astroid --pre -U
-->
### Steps to rep... | Thank you for the report, I can reproduce this bug.
I have a fix, but I think this has the potential to break countless continuous integration and annoy a lot of persons, so I'm going to wait for a review by someone else before merging.
The fix is not going to be merged before a major version see https://github.com/Py... | 2023-08-05T16:56:45Z | 3 | ["tests/reporters/unittest_json_reporter.py::test_json2_result_with_broken_score", "tests/reporters/unittest_json_reporter.py::test_serialize_deserialize[everything-defined]", "tests/reporters/unittest_json_reporter.py::test_serialize_deserialize_for_v2[everything-defined]", "tests/reporters/unittest_json_reporter.py::... | [] | a0ce6e424e3a208f3aed1cbf6e16c40853bec3c0 |
pytest-dev/pytest | pytest-dev__pytest-10356 | 3c1534944cbd34e8a41bc9e76818018fadefc9a1 | diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py
--- a/src/_pytest/mark/structures.py
+++ b/src/_pytest/mark/structures.py
@@ -355,12 +355,35 @@ def __call__(self, *args: object, **kwargs: object):
return self.with_args(*args, **kwargs)
-def get_unpacked_marks(obj: object) -> It... | diff --git a/testing/test_mark.py b/testing/test_mark.py
--- a/testing/test_mark.py
+++ b/testing/test_mark.py
@@ -1109,3 +1109,27 @@ def test_foo():
result = pytester.runpytest(foo, "-m", expr)
result.stderr.fnmatch_lines([expected])
assert result.ret == ExitCode.USAGE_ERROR
+
+
+def test_mark_mro() -> ... | Consider MRO when obtaining marks for classes
When using pytest markers in two baseclasses `Foo` and `Bar`, inheriting from both of those baseclasses will lose the markers of one of those classes. This behavior is present in pytest 3-6, and I think it may as well have been intended. I am still filing it as a bug becaus... | ronny has already refactored this multiple times iirc, but I wonder if it would make sense to store markers as `pytestmark_foo` and `pytestmark_bar` on the class instead of in one `pytestmark` array, that way you can leverage regular inheritance rules
Thanks for bringing this to attention, pytest show walk the mro of a... | 2022-10-08T06:20:42Z | 7.2 | ["testing/test_mark.py::test_mark_mro"] | ["testing/test_mark.py::TestFunctional::test_keyword_added_for_session", "testing/test_mark.py::TestFunctional::test_keywords_at_node_level", "testing/test_mark.py::TestFunctional::test_mark_closest", "testing/test_mark.py::TestFunctional::test_mark_decorator_baseclasses_merged", "testing/test_mark.py::TestFunctional::... | 572b5657d7ca557593418ce0319fabff88800c73 |
pytest-dev/pytest | pytest-dev__pytest-11148 | 2f7415cfbc4b6ca62f9013f1abd27136f46b9653 | diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py
--- a/src/_pytest/pathlib.py
+++ b/src/_pytest/pathlib.py
@@ -523,6 +523,8 @@ def import_path(
if mode is ImportMode.importlib:
module_name = module_name_from_path(path, root)
+ with contextlib.suppress(KeyError):
+ return sy... | diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py
--- a/testing/acceptance_test.py
+++ b/testing/acceptance_test.py
@@ -1315,3 +1315,38 @@ def test_stuff():
)
res = pytester.runpytest()
res.stdout.fnmatch_lines(["*Did you mean to use `assert` instead of `return`?*"])
+
+
+def test_doct... | Module imported twice under import-mode=importlib
In pmxbot/pmxbot@7f189ad, I'm attempting to switch pmxbot off of pkg_resources style namespace packaging to PEP 420 namespace packages. To do so, I've needed to switch to `importlib` for the `import-mode` and re-organize the tests to avoid import errors on the tests.
Y... | In pmxbot/pmxbot@3adc54c, I've managed to pare down the project to a bare minimum reproducer. The issue only happens when `import-mode=importlib` and `doctest-modules` and one of the modules imports another module.
This issue may be related to (or same as) #10341.
I think you'll agree this is pretty basic behavior th... | 2023-06-29T00:04:33Z | 8 | ["testing/acceptance_test.py::test_doctest_and_normal_imports_with_importlib", "testing/test_pathlib.py::TestImportPath::test_remembers_previous_imports"] | ["testing/acceptance_test.py::TestDurations::test_calls", "testing/acceptance_test.py::TestDurations::test_calls_show_2", "testing/acceptance_test.py::TestDurations::test_calls_showall", "testing/acceptance_test.py::TestDurations::test_calls_showall_verbose", "testing/acceptance_test.py::TestDurations::test_with_desele... | 10056865d2a4784934ce043908a0e78d0578f677 |
pytest-dev/pytest | pytest-dev__pytest-5103 | 10ca84ffc56c2dd2d9dc4bd71b7b898e083500cd | diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py
--- a/src/_pytest/assertion/rewrite.py
+++ b/src/_pytest/assertion/rewrite.py
@@ -964,6 +964,8 @@ def visit_Call_35(self, call):
"""
visit `ast.Call` nodes on Python3.5 and after
"""
+ if isinstance(call.f... | diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py
--- a/testing/test_assertrewrite.py
+++ b/testing/test_assertrewrite.py
@@ -656,6 +656,12 @@ def __repr__(self):
else:
assert lines == ["assert 0 == 1\n + where 1 = \\n{ \\n~ \\n}.a"]
+ def test_unroll_expression(self... | Unroll the iterable for all/any calls to get better reports
Sometime I need to assert some predicate on all of an iterable, and for that the builtin functions `all`/`any` are great - but the failure messages aren't useful at all!
For example - the same test written in three ways:
- A generator expression
```sh ... | Hello, I am new here and would be interested in working on this issue if that is possible.
@danielx123
Sure! But I don't think this is an easy issue, since it involved the assertion rewriting - but if you're familar with Python's AST and pytest's internals feel free to pick this up.
We also have a tag "easy" for issu... | 2019-04-13T16:17:45Z | 4.5 | ["testing/test_assertrewrite.py::TestAssertionRewrite::test_unroll_expression"] | ["testing/test_assertrewrite.py::TestAssertionRewrite::test_assert_already_has_message", "testing/test_assertrewrite.py::TestAssertionRewrite::test_assert_raising_nonzero_in_comparison", "testing/test_assertrewrite.py::TestAssertionRewrite::test_assertion_message", "testing/test_assertrewrite.py::TestAssertionRewrite::... | 693c3b7f61d4d32f8927a74f34ce8ac56d63958e |
pytest-dev/pytest | pytest-dev__pytest-5254 | 654d8da9f7ffd7a88e02ae2081ffcb2ca2e765b3 | diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py
--- a/src/_pytest/fixtures.py
+++ b/src/_pytest/fixtures.py
@@ -1129,18 +1129,40 @@ def __init__(self, session):
self._nodeid_and_autousenames = [("", self.config.getini("usefixtures"))]
session.config.pluginmanager.register(self, "funcman... | diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py
--- a/testing/python/fixtures.py
+++ b/testing/python/fixtures.py
@@ -3950,3 +3950,46 @@ def fix():
with pytest.raises(pytest.fail.Exception):
assert fix() == 1
+
+
+def test_fixture_param_shadowing(testdir):
+ """Parametrized argum... | `pytest.mark.parametrize` does not correctly hide fixtures of the same name (it misses its dependencies)
From https://github.com/smarie/python-pytest-cases/issues/36
This works:
```python
@pytest.fixture(params=['a', 'b'])
def arg(request):
return request.param
@pytest.mark.parametrize("arg", [1])
def test_refer... | null | 2019-05-12T23:50:35Z | 4.5 | ["testing/python/fixtures.py::test_fixture_param_shadowing"] | ["testing/python/fixtures.py::TestAutouseDiscovery::test_autouse_in_conftests", "testing/python/fixtures.py::TestAutouseDiscovery::test_autouse_in_module_and_two_classes", "testing/python/fixtures.py::TestAutouseDiscovery::test_callables_nocode", "testing/python/fixtures.py::TestAutouseDiscovery::test_parsefactories_co... | 693c3b7f61d4d32f8927a74f34ce8ac56d63958e |
pytest-dev/pytest | pytest-dev__pytest-5495 | 1aefb24b37c30fba8fd79a744829ca16e252f340 | diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py
--- a/src/_pytest/assertion/util.py
+++ b/src/_pytest/assertion/util.py
@@ -254,17 +254,38 @@ def _compare_eq_iterable(left, right, verbose=0):
def _compare_eq_sequence(left, right, verbose=0):
+ comparing_bytes = isinstance(left, bytes)... | diff --git a/testing/test_assertion.py b/testing/test_assertion.py
--- a/testing/test_assertion.py
+++ b/testing/test_assertion.py
@@ -331,6 +331,27 @@ def test_multiline_text_diff(self):
assert "- spam" in diff
assert "+ eggs" in diff
+ def test_bytes_diff_normal(self):
+ """Check special... | Confusing assertion rewriting message with byte strings
The comparison with assertion rewriting for byte strings is confusing:
```
def test_b():
> assert b"" == b"42"
E AssertionError: assert b'' == b'42'
E Right contains more items, first extra item: 52
E Full diff:
E - b''
E ... | hmmm yes, this ~kinda makes sense as `bytes` objects are sequences of integers -- we should maybe just omit the "contains more items" messaging for bytes objects? | 2019-06-25T23:41:16Z | 4.6 | ["testing/test_assertion.py::TestAssert_reprcompare::test_bytes_diff_normal", "testing/test_assertion.py::TestAssert_reprcompare::test_bytes_diff_verbose"] | ["testing/test_assertion.py::TestAssert_reprcompare::test_Sequence", "testing/test_assertion.py::TestAssert_reprcompare::test_dict", "testing/test_assertion.py::TestAssert_reprcompare::test_dict_different_items", "testing/test_assertion.py::TestAssert_reprcompare::test_dict_omitting", "testing/test_assertion.py::TestAs... | d5843f89d3c008ddcb431adbc335b080a79e617e |
pytest-dev/pytest | pytest-dev__pytest-5692 | 29e336bd9bf87eaef8e2683196ee1975f1ad4088 | diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py
--- a/src/_pytest/junitxml.py
+++ b/src/_pytest/junitxml.py
@@ -10,9 +10,11 @@
"""
import functools
import os
+import platform
import re
import sys
import time
+from datetime import datetime
import py
@@ -666,6 +668,8 @@ def pytest_sessionfinish(... | diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py
--- a/testing/test_junitxml.py
+++ b/testing/test_junitxml.py
@@ -1,4 +1,6 @@
import os
+import platform
+from datetime import datetime
from xml.dom import minidom
import py
@@ -139,6 +141,30 @@ def test_xpass():
node = dom.find_first_by_tag... | Hostname and timestamp properties in generated JUnit XML reports
Pytest enables generating JUnit XML reports of the tests.
However, there are some properties missing, specifically `hostname` and `timestamp` from the `testsuite` XML element. Is there an option to include them?
Example of a pytest XML report:
```xml
<?... | null | 2019-08-03T14:15:04Z | 5 | ["testing/test_junitxml.py::TestPython::test_hostname_in_xml", "testing/test_junitxml.py::TestPython::test_timestamp_in_xml"] | ["testing/test_junitxml.py::TestNonPython::test_summing_simple", "testing/test_junitxml.py::TestPython::test_assertion_binchars", "testing/test_junitxml.py::TestPython::test_avoid_double_stdout", "testing/test_junitxml.py::TestPython::test_call_failure_teardown_error", "testing/test_junitxml.py::TestPython::test_classn... | c2f762460f4c42547de906d53ea498dd499ea837 |
pytest-dev/pytest | pytest-dev__pytest-5808 | 404cf0c872880f2aac8214bb490b26c9a659548e | diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py
--- a/src/_pytest/pastebin.py
+++ b/src/_pytest/pastebin.py
@@ -65,7 +65,7 @@ def create_new_paste(contents):
from urllib.request import urlopen
from urllib.parse import urlencode
- params = {"code": contents, "lexer": "python3", "expiry": "1... | diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py
--- a/testing/test_pastebin.py
+++ b/testing/test_pastebin.py
@@ -165,7 +165,7 @@ def test_create_new_paste(self, pastebin, mocked_urlopen):
assert len(mocked_urlopen) == 1
url, data = mocked_urlopen[0]
assert type(data) is byte... | Lexer "python3" in --pastebin feature causes HTTP errors
The `--pastebin` option currently submits the output of `pytest` to `bpaste.net` using `lexer=python3`: https://github.com/pytest-dev/pytest/blob/d47b9d04d4cf824150caef46c9c888779c1b3f58/src/_pytest/pastebin.py#L68-L73
For some `contents`, this will raise a "HTT... | null | 2019-08-30T19:36:55Z | 5.1 | ["testing/test_pastebin.py::TestPaste::test_create_new_paste"] | ["testing/test_pastebin.py::TestPaste::test_create_new_paste_failure", "testing/test_pastebin.py::TestPaste::test_pastebin_http_error", "testing/test_pastebin.py::TestPaste::test_pastebin_invalid_url", "testing/test_pastebin.py::TestPasteCapture::test_all", "testing/test_pastebin.py::TestPasteCapture::test_failed", "te... | c1361b48f83911aa721b21a4515a5446515642e2 |
pytest-dev/pytest | pytest-dev__pytest-5809 | 8aba863a634f40560e25055d179220f0eefabe9a | diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py
--- a/src/_pytest/pastebin.py
+++ b/src/_pytest/pastebin.py
@@ -77,11 +77,7 @@ def create_new_paste(contents):
from urllib.request import urlopen
from urllib.parse import urlencode
- params = {
- "code": contents,
- "lex... | diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py
--- a/testing/test_pastebin.py
+++ b/testing/test_pastebin.py
@@ -126,7 +126,7 @@ def test_create_new_paste(self, pastebin, mocked_urlopen):
assert len(mocked_urlopen) == 1
url, data = mocked_urlopen[0]
assert type(data) is byte... | Lexer "python3" in --pastebin feature causes HTTP errors
The `--pastebin` option currently submits the output of `pytest` to `bpaste.net` using `lexer=python3`: https://github.com/pytest-dev/pytest/blob/d47b9d04d4cf824150caef46c9c888779c1b3f58/src/_pytest/pastebin.py#L68-L73
For some `contents`, this will raise a "HTT... | null | 2019-09-01T04:40:09Z | 4.6 | ["testing/test_pastebin.py::TestPaste::test_create_new_paste"] | ["testing/test_pastebin.py::TestPasteCapture::test_all", "testing/test_pastebin.py::TestPasteCapture::test_failed", "testing/test_pastebin.py::TestPasteCapture::test_non_ascii_paste_text"] | d5843f89d3c008ddcb431adbc335b080a79e617e |
pytest-dev/pytest | pytest-dev__pytest-5840 | 73c5b7f4b11a81e971f7d1bb18072e06a87060f4 | diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py
--- a/src/_pytest/config/__init__.py
+++ b/src/_pytest/config/__init__.py
@@ -30,7 +30,6 @@
from _pytest.compat import importlib_metadata
from _pytest.outcomes import fail
from _pytest.outcomes import Skipped
-from _pytest.pathlib import un... | diff --git a/testing/test_conftest.py b/testing/test_conftest.py
--- a/testing/test_conftest.py
+++ b/testing/test_conftest.py
@@ -1,12 +1,12 @@
-import os.path
+import os
import textwrap
+from pathlib import Path
import py
import pytest
from _pytest.config import PytestPluginManager
from _pytest.main import E... | 5.1.2 ImportError while loading conftest (windows import folder casing issues)
5.1.1 works fine. after upgrade to 5.1.2, the path was converted to lower case
```
Installing collected packages: pytest
Found existing installation: pytest 5.1.1
Uninstalling pytest-5.1.1:
Successfully uninstalled pytest-5.1.1
S... | Can you show the import line that it is trying to import exactly? The cause might be https://github.com/pytest-dev/pytest/pull/5792.
cc @Oberon00
Seems very likely, unfortunately. If instead of using `os.normcase`, we could find a way to get the path with correct casing (`Path.resolve`?) that would probably be a safe ... | 2019-09-12T01:09:28Z | 5.1 | ["testing/test_conftest.py::test_setinitial_conftest_subdirs[test]", "testing/test_conftest.py::test_setinitial_conftest_subdirs[tests]"] | ["testing/test_conftest.py::TestConftestValueAccessGlobal::test_basic_init[global]", "testing/test_conftest.py::TestConftestValueAccessGlobal::test_basic_init[inpackage]", "testing/test_conftest.py::TestConftestValueAccessGlobal::test_immediate_initialiation_and_incremental_are_the_same[global]", "testing/test_conftest... | c1361b48f83911aa721b21a4515a5446515642e2 |
pytest-dev/pytest | pytest-dev__pytest-6116 | e670ff76cbad80108bde9bab616b66771b8653cf | diff --git a/src/_pytest/main.py b/src/_pytest/main.py
--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -109,6 +109,7 @@ def pytest_addoption(parser):
group.addoption(
"--collectonly",
"--collect-only",
+ "--co",
action="store_true",
help="only collect tests, don't ... | diff --git a/testing/test_collection.py b/testing/test_collection.py
--- a/testing/test_collection.py
+++ b/testing/test_collection.py
@@ -402,7 +402,7 @@ def pytest_collect_file(path, parent):
)
testdir.mkdir("sub")
testdir.makepyfile("def test_x(): pass")
- result = testdir.runpytest... | pytest --collect-only needs a one char shortcut command
I find myself needing to run `--collect-only` very often and that cli argument is a very long to type one.
I do think that it would be great to allocate a character for it, not sure which one yet. Please use up/down thumbs to vote if you would find it useful or ... | Agreed, it's probably the option I use most which doesn't have a shortcut.
Both `-c` and `-o` are taken. I guess `-n` (as in "no action", compare `-n`/`--dry-run` for e.g. `git clean`) could work?
Maybe `--co` (for either "**co**llect" or "**c**ollect **o**nly), similar to other two-character shortcuts we already ha... | 2019-11-01T20:05:53Z | 5.2 | ["testing/test_collection.py::TestCustomConftests::test_pytest_collect_file_from_sister_dir", "testing/test_collection.py::TestCustomConftests::test_pytest_fs_collect_hooks_are_seen"] | ["testing/test_collection.py::TestCollectFS::test__in_venv[Activate.bat]", "testing/test_collection.py::TestCollectFS::test__in_venv[Activate.ps1]", "testing/test_collection.py::TestCollectFS::test__in_venv[Activate]", "testing/test_collection.py::TestCollectFS::test__in_venv[activate.csh]", "testing/test_collection.py... | f36ea240fe3579f945bf5d6cc41b5e45a572249d |
pytest-dev/pytest | pytest-dev__pytest-6202 | 3a668ea6ff24b0c8f00498c3144c63bac561d925 | diff --git a/src/_pytest/python.py b/src/_pytest/python.py
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -285,8 +285,7 @@ def getmodpath(self, stopatmodule=True, includemodule=False):
break
parts.append(name)
parts.reverse()
- s = ".".join(parts)
- r... | diff --git a/testing/test_collection.py b/testing/test_collection.py
--- a/testing/test_collection.py
+++ b/testing/test_collection.py
@@ -685,6 +685,8 @@ def test_2():
def test_example_items1(self, testdir):
p = testdir.makepyfile(
"""
+ import pytest
+
def testone():... | '.[' replaced with '[' in the headline shown of the test report
```
bug.py F [100%]
=================================== FAILURES ===================================
_________________________________ test_boo[.[] _________________________________
a = '..... | Thanks for the fantastic report @linw1995, this is really helpful :smile:
I find out the purpose of replacing '.[' with '['. The older version of pytest, support to generate test by using the generator function.
[https://github.com/pytest-dev/pytest/blob/9eb1d55380ae7c25ffc600b65e348dca85f99221/py/test/testing/test_c... | 2019-11-16T07:45:21Z | 5.2 | ["testing/test_collection.py::Test_genitems::test_example_items1"] | ["testing/test_collection.py::TestCollectFS::test__in_venv[Activate.bat]", "testing/test_collection.py::TestCollectFS::test__in_venv[Activate.ps1]", "testing/test_collection.py::TestCollectFS::test__in_venv[Activate]", "testing/test_collection.py::TestCollectFS::test__in_venv[activate.csh]", "testing/test_collection.py... | f36ea240fe3579f945bf5d6cc41b5e45a572249d |
pytest-dev/pytest | pytest-dev__pytest-6680 | 194b52145b98fda8ad1c62ebacf96b9e2916309c | diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py
--- a/src/_pytest/deprecated.py
+++ b/src/_pytest/deprecated.py
@@ -36,7 +36,10 @@
NODE_USE_FROM_PARENT = UnformattedWarning(
PytestDeprecationWarning,
- "direct construction of {name} has been deprecated, please use {name}.from_parent",
+ ... | diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py
--- a/testing/deprecated_test.py
+++ b/testing/deprecated_test.py
@@ -86,7 +86,7 @@ class MockConfig:
ms = MockConfig()
with pytest.warns(
DeprecationWarning,
- match="direct construction of .* has been deprecated, please use... | Improve deprecation docs for Node.from_parent
In the "Node Construction changed to Node.from_parent" section in the deprecation docs, we definitely need to add:
* [x] An example of the warning that users will see (so they can find the session on google).
* [x] The warning `NODE_USE_FROM_PARENT` should point to the dep... | null | 2020-02-05T23:00:43Z | 5.3 | ["testing/deprecated_test.py::test_node_direct_ctor_warning"] | ["testing/deprecated_test.py::test_external_plugins_integrated[pytest_capturelog]", "testing/deprecated_test.py::test_external_plugins_integrated[pytest_catchlog]", "testing/deprecated_test.py::test_external_plugins_integrated[pytest_faulthandler]", "testing/deprecated_test.py::test_noprintlogs_is_deprecated_cmdline", ... | 92767fec5122a14fbf671374c9162e947278339b |
pytest-dev/pytest | pytest-dev__pytest-7122 | be68496440508b760ba1f988bcc63d1d09ace206 | diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py
new file mode 100644
--- /dev/null
+++ b/src/_pytest/mark/expression.py
@@ -0,0 +1,173 @@
+r"""
+Evaluate match expressions, as used by `-k` and `-m`.
+
+The grammar is:
+
+expression: expr? EOF
+expr: and_expr ('or' and_expr)*
+and_expr... | diff --git a/testing/test_mark.py b/testing/test_mark.py
--- a/testing/test_mark.py
+++ b/testing/test_mark.py
@@ -200,6 +200,8 @@ def test_hello():
"spec",
[
("xyz", ("test_one",)),
+ ("((( xyz)) )", ("test_one",)),
+ ("not not xyz", ("test_one",)),
("xyz and xyz2", ()),
... | -k mishandles numbers
Using `pytest 5.4.1`.
It seems that pytest cannot handle keyword selection with numbers, like `-k "1 or 2"`.
Considering the following tests:
```
def test_1():
pass
def test_2():
pass
def test_3():
pass
```
Selecting with `-k 2` works:
```
(venv) Victors-MacBook-Pro:keyword_numb... | IMO this is a bug.
This happens before the `-k` expression is evaluated using `eval`, `1` and `2` are evaluated as numbers, and `1 or 2` is just evaluated to True which means all tests are included. On the other hand `_1` is an identifier which only evaluates to True if matches the test name.
If you are interested on... | 2020-04-25T13:16:25Z | 5.4 | ["testing/test_mark.py::TestFunctional::test_keyword_added_for_session", "testing/test_mark.py::TestFunctional::test_keywords_at_node_level", "testing/test_mark.py::TestFunctional::test_mark_closest", "testing/test_mark.py::TestFunctional::test_mark_decorator_baseclasses_merged", "testing/test_mark.py::TestFunctional::... | [] | 678c1a0745f1cf175c442c719906a1f13e496910 |
pytest-dev/pytest | pytest-dev__pytest-7236 | c98bc4cd3d687fe9b392d8eecd905627191d4f06 | diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py
--- a/src/_pytest/unittest.py
+++ b/src/_pytest/unittest.py
@@ -41,7 +41,7 @@ def collect(self):
if not getattr(cls, "__test__", True):
return
- skipped = getattr(cls, "__unittest_skip__", False)
+ skipped = _is_skipped... | diff --git a/testing/test_unittest.py b/testing/test_unittest.py
--- a/testing/test_unittest.py
+++ b/testing/test_unittest.py
@@ -1193,6 +1193,40 @@ def test_2(self):
]
+@pytest.mark.parametrize("mark", ["@unittest.skip", "@pytest.mark.skip"])
+def test_pdb_teardown_skipped(testdir, monkeypatch, mark):
+ "... | unittest.TestCase.tearDown executed on skipped tests when running --pdb
With this minimal test:
```python
import unittest
class MyTestCase(unittest.TestCase):
def setUp(self):
xxx
@unittest.skip("hello")
def test_one(self):
pass
def tearDown(self):
xxx
```
```
$ python --versi... | This might a regression from https://github.com/pytest-dev/pytest/pull/7151 , I see it changes pdb, skip and teardown
I'd like to work on this.
Hi @gdhameeja,
Thanks for the offer, but this is a bit trickier because of the unittest-pytest interaction. I plan to tackle this today as it is a regression. 👍
But again t... | 2020-05-21T19:53:14Z | 5.4 | ["testing/test_unittest.py::test_pdb_teardown_skipped[@unittest.skip]"] | ["testing/test_unittest.py::test_BdbQuit", "testing/test_unittest.py::test_async_support", "testing/test_unittest.py::test_class_method_containing_test_issue1558", "testing/test_unittest.py::test_cleanup_functions", "testing/test_unittest.py::test_djangolike_testcase", "testing/test_unittest.py::test_error_message_with... | 678c1a0745f1cf175c442c719906a1f13e496910 |
pytest-dev/pytest | pytest-dev__pytest-7283 | b7b729298cb780b3468e3a0580a27ce62b6e818a | diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py
--- a/src/_pytest/unittest.py
+++ b/src/_pytest/unittest.py
@@ -41,7 +41,7 @@ def collect(self):
if not getattr(cls, "__test__", True):
return
- skipped = getattr(cls, "__unittest_skip__", False)
+ skipped = _is_skipped... | diff --git a/testing/test_unittest.py b/testing/test_unittest.py
--- a/testing/test_unittest.py
+++ b/testing/test_unittest.py
@@ -1193,6 +1193,40 @@ def test_2(self):
]
+@pytest.mark.parametrize("mark", ["@unittest.skip", "@pytest.mark.skip"])
+def test_pdb_teardown_skipped(testdir, monkeypatch, mark):
+ "... | unittest.TestCase.tearDown executed on skipped tests when running --pdb
With this minimal test:
```python
import unittest
class MyTestCase(unittest.TestCase):
def setUp(self):
xxx
@unittest.skip("hello")
def test_one(self):
pass
def tearDown(self):
xxx
```
```
$ python --versi... | This might a regression from https://github.com/pytest-dev/pytest/pull/7151 , I see it changes pdb, skip and teardown
I'd like to work on this.
Hi @gdhameeja,
Thanks for the offer, but this is a bit trickier because of the unittest-pytest interaction. I plan to tackle this today as it is a regression. 👍
But again t... | 2020-05-30T17:36:37Z | 5.4 | ["testing/test_unittest.py::test_pdb_teardown_skipped[@unittest.skip]"] | ["testing/test_unittest.py::test_BdbQuit", "testing/test_unittest.py::test_async_support", "testing/test_unittest.py::test_class_method_containing_test_issue1558", "testing/test_unittest.py::test_cleanup_functions", "testing/test_unittest.py::test_djangolike_testcase", "testing/test_unittest.py::test_error_message_with... | 678c1a0745f1cf175c442c719906a1f13e496910 |
pytest-dev/pytest | pytest-dev__pytest-7535 | 7ec6401ffabf79d52938ece5b8ff566a8b9c260e | diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py
--- a/src/_pytest/_code/code.py
+++ b/src/_pytest/_code/code.py
@@ -262,7 +262,15 @@ def __str__(self) -> str:
raise
except BaseException:
line = "???"
- return " File %r:%d in %s\n %s\n" % (self.path, self.li... | diff --git a/testing/code/test_code.py b/testing/code/test_code.py
--- a/testing/code/test_code.py
+++ b/testing/code/test_code.py
@@ -1,3 +1,4 @@
+import re
import sys
from types import FrameType
from unittest import mock
@@ -170,6 +171,15 @@ def test_getsource(self) -> None:
assert len(source) == 6
... | pytest 6: Traceback in pytest.raises contains repr of py.path.local
The [werkzeug](https://github.com/pallets/werkzeug) tests fail with pytest 6:
```python
def test_import_string_provides_traceback(tmpdir, monkeypatch):
monkeypatch.syspath_prepend(str(tmpdir))
# Couple of packages
dir_a = t... | null | 2020-07-23T14:15:26Z | 6 | ["testing/code/test_code.py::TestTracebackEntry::test_tb_entry_str"] | ["testing/code/test_code.py::TestExceptionInfo::test_bad_getsource", "testing/code/test_code.py::TestExceptionInfo::test_from_current_with_missing", "testing/code/test_code.py::TestReprFuncArgs::test_not_raise_exception_with_mixed_encoding", "testing/code/test_code.py::TestTracebackEntry::test_getsource", "testing/code... | 634cde9506eb1f48dec3ec77974ee8dc952207c6 |
pytest-dev/pytest | pytest-dev__pytest-7673 | 75af2bfa06436752165df884d4666402529b1d6a | diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py
--- a/src/_pytest/logging.py
+++ b/src/_pytest/logging.py
@@ -439,7 +439,8 @@ def set_level(self, level: Union[int, str], logger: Optional[str] = None) -> Non
# Save the original log-level to restore it during teardown.
self._initial_logger_... | diff --git a/testing/logging/test_fixture.py b/testing/logging/test_fixture.py
--- a/testing/logging/test_fixture.py
+++ b/testing/logging/test_fixture.py
@@ -65,6 +65,7 @@ def test_change_level_undos_handler_level(testdir: Testdir) -> None:
def test1(caplog):
assert caplog.handler.level == 0
+ ... | logging: handler level restored incorrectly if caplog.set_level is called more than once
pytest version: 6.0.1
The fix in #7571 (backported to 6.0.1) has a bug where it does a "set" instead of "setdefault" to the `_initial_handler_level`. So if there are multiple calls to `caplog.set_level`, the level will be restored... | null | 2020-08-22T14:47:31Z | 6 | ["testing/logging/test_fixture.py::test_change_level_undos_handler_level"] | ["testing/logging/test_fixture.py::test_caplog_can_override_global_log_level", "testing/logging/test_fixture.py::test_caplog_captures_despite_exception", "testing/logging/test_fixture.py::test_caplog_captures_for_all_stages", "testing/logging/test_fixture.py::test_change_level", "testing/logging/test_fixture.py::test_c... | 634cde9506eb1f48dec3ec77974ee8dc952207c6 |
pytest-dev/pytest | pytest-dev__pytest-7982 | a7e38c5c61928033a2dc1915cbee8caa8544a4d0 | diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py
--- a/src/_pytest/pathlib.py
+++ b/src/_pytest/pathlib.py
@@ -558,7 +558,7 @@ def visit(
entries = sorted(os.scandir(path), key=lambda entry: entry.name)
yield from entries
for entry in entries:
- if entry.is_dir(follow_symlinks=False) a... | diff --git a/testing/test_collection.py b/testing/test_collection.py
--- a/testing/test_collection.py
+++ b/testing/test_collection.py
@@ -9,6 +9,7 @@
from _pytest.main import _in_venv
from _pytest.main import Session
from _pytest.pathlib import symlink_or_skip
+from _pytest.pytester import Pytester
from _pytest.py... | Symlinked directories not collected since pytest 6.1.0
When there is a symlink to a directory in a test directory, is is just skipped over, but it should be followed and collected as usual.
This regressed in b473e515bc57ff1133fe650f1e7e6d7e22e5d841 (included in 6.1.0). For some reason I added a `follow_symlinks=False`... | null | 2020-10-31T12:27:03Z | 6.2 | ["testing/test_collection.py::test_collect_symlink_dir"] | ["testing/test_collection.py::TestCollectFS::test__in_venv[Activate.bat]", "testing/test_collection.py::TestCollectFS::test__in_venv[Activate.ps1]", "testing/test_collection.py::TestCollectFS::test__in_venv[Activate]", "testing/test_collection.py::TestCollectFS::test__in_venv[activate.csh]", "testing/test_collection.py... | 902739cfc3bbc3379e6ef99c8e250de35f52ecde |
pytest-dev/pytest | pytest-dev__pytest-8022 | e986d84466dfa98dbbc55cc1bf5fcb99075f4ac3 | diff --git a/src/_pytest/main.py b/src/_pytest/main.py
--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -765,12 +765,14 @@ def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
self._notfound.append((report_arg, col))
continue
- # If __init__... | diff --git a/testing/test_doctest.py b/testing/test_doctest.py
--- a/testing/test_doctest.py
+++ b/testing/test_doctest.py
@@ -68,9 +68,13 @@ def my_func():
assert isinstance(items[0].parent, DoctestModule)
assert items[0].parent is items[1].parent
- def test_collect_module_two_doctest_no... | Doctest collection only returns single test for __init__.py
<!--
Thanks for submitting an issue!
Quick check-list while reporting bugs:
-->
`pytest --doctest-modules __init__.py` will only collect a single doctest because of this:
https://github.com/pytest-dev/pytest/blob/e986d84466dfa98dbbc55cc1bf5fcb99075f4ac3/src... | 2020-11-10T20:57:51Z | 6.2 | ["testing/test_doctest.py::TestDoctests::test_collect_module_two_doctest_no_modulelevel[__init__]"] | ["testing/test_doctest.py::TestDoctestAutoUseFixtures::test_auto_use_request_attributes[class]", "testing/test_doctest.py::TestDoctestAutoUseFixtures::test_auto_use_request_attributes[function]", "testing/test_doctest.py::TestDoctestAutoUseFixtures::test_auto_use_request_attributes[module]", "testing/test_doctest.py::T... | 902739cfc3bbc3379e6ef99c8e250de35f52ecde | |
pytest-dev/pytest | pytest-dev__pytest-8906 | 69356d20cfee9a81972dcbf93d8caf9eabe113e8 | diff --git a/src/_pytest/python.py b/src/_pytest/python.py
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -608,10 +608,10 @@ def _importtestmodule(self):
if e.allow_module_level:
raise
raise self.CollectError(
- "Using pytest.skip outside of a test i... | diff --git a/testing/test_skipping.py b/testing/test_skipping.py
--- a/testing/test_skipping.py
+++ b/testing/test_skipping.py
@@ -1341,7 +1341,7 @@ def test_func():
)
result = pytester.runpytest()
result.stdout.fnmatch_lines(
- ["*Using pytest.skip outside of a test is not allowed*"]
+ ["*... | Improve handling of skip for module level
This is potentially about updating docs, updating error messages or introducing a new API.
Consider the following scenario:
`pos_only.py` is using Python 3,8 syntax:
```python
def foo(a, /, b):
return a + b
```
It should not be tested under Python 3.6 and 3.7.
This is a ... | SyntaxErrors are thrown before execution, so how would the skip call stop the interpreter from parsing the 'incorrect' syntax?
unless we hook the interpreter that is.
A solution could be to ignore syntax errors based on some parameter
if needed we can extend this to have some functionality to evaluate conditions in whi... | 2021-07-14T08:00:50Z | 7 | ["testing/test_skipping.py::test_module_level_skip_error"] | ["testing/test_skipping.py::TestBooleanCondition::test_skipif", "testing/test_skipping.py::TestBooleanCondition::test_skipif_noreason", "testing/test_skipping.py::TestBooleanCondition::test_xfail", "testing/test_skipping.py::TestEvaluation::test_marked_one_arg", "testing/test_skipping.py::TestEvaluation::test_marked_on... | e2ee3144ed6e241dea8d96215fcdca18b3892551 |
pytest-dev/pytest | pytest-dev__pytest-8952 | 6d6bc97231f2d9a68002f1d191828fd3476ca8b8 | diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py
--- a/src/_pytest/pytester.py
+++ b/src/_pytest/pytester.py
@@ -588,6 +588,7 @@ def assert_outcomes(
errors: int = 0,
xpassed: int = 0,
xfailed: int = 0,
+ warnings: int = 0,
) -> None:
"""Assert that the spec... | diff --git a/testing/test_nose.py b/testing/test_nose.py
--- a/testing/test_nose.py
+++ b/testing/test_nose.py
@@ -335,7 +335,7 @@ def test_failing():
"""
)
result = pytester.runpytest(p)
- result.assert_outcomes(skipped=1)
+ result.assert_outcomes(skipped=1, warnings=1)
def test_SkipTest_... | Enhance `RunResult` warning assertion capabilities
while writing some other bits and pieces, I had a use case for checking the `warnings` omitted, `RunResult` has a `assert_outcomes()` that doesn't quite offer `warnings=` yet the information is already available in there, I suspect there is a good reason why we don't h... | null | 2021-07-28T21:11:34Z | 7 | ["testing/test_pytester.py::test_pytester_assert_outcomes_warnings"] | ["testing/test_pytester.py::TestInlineRunModulesCleanup::test_external_test_module_imports_not_cleaned_up", "testing/test_pytester.py::TestInlineRunModulesCleanup::test_inline_run_sys_modules_snapshot_restore_preserving_modules", "testing/test_pytester.py::TestInlineRunModulesCleanup::test_inline_run_taking_and_restori... | e2ee3144ed6e241dea8d96215fcdca18b3892551 |
pytest-dev/pytest | pytest-dev__pytest-8987 | a446ee81fd6674c2b7d1f0ee76467f1ffc1619fc | diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py
--- a/src/_pytest/mark/expression.py
+++ b/src/_pytest/mark/expression.py
@@ -6,7 +6,7 @@
expr: and_expr ('or' and_expr)*
and_expr: not_expr ('and' not_expr)*
not_expr: 'not' not_expr | '(' expr ')' | ident
-ident: (\w|:|\+|-... | diff --git a/testing/test_mark_expression.py b/testing/test_mark_expression.py
--- a/testing/test_mark_expression.py
+++ b/testing/test_mark_expression.py
@@ -66,6 +66,20 @@ def test_syntax_oddeties(expr: str, expected: bool) -> None:
assert evaluate(expr, matcher) is expected
+def test_backslash_not_treated_s... | pytest -k doesn't work with "\"?
### Discussed in https://github.com/pytest-dev/pytest/discussions/8982
<div type='discussions-op-text'>
<sup>Originally posted by **nguydavi** August 7, 2021</sup>
Hey!
I've been trying to use `pytest -k` passing the name I got by parametrizing my test. For example,
```
$ pytest -v... | null | 2021-08-08T08:58:47Z | 7 | ["testing/test_mark_expression.py::test_backslash_not_treated_specially", "testing/test_mark_expression.py::test_valid_idents[\\\\nhe\\\\\\\\l\\\\lo\\\\n\\\\t\\\\rbye]"] | ["testing/test_mark_expression.py::test_basic[(not", "testing/test_mark_expression.py::test_basic[false", "testing/test_mark_expression.py::test_basic[false-False]", "testing/test_mark_expression.py::test_basic[not", "testing/test_mark_expression.py::test_basic[true", "testing/test_mark_expression.py::test_basic[true-T... | e2ee3144ed6e241dea8d96215fcdca18b3892551 |
pytest-dev/pytest | pytest-dev__pytest-9133 | 7720154ca023da23581d87244a31acf5b14979f2 | diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py
--- a/src/_pytest/pytester.py
+++ b/src/_pytest/pytester.py
@@ -589,6 +589,7 @@ def assert_outcomes(
xpassed: int = 0,
xfailed: int = 0,
warnings: int = 0,
+ deselected: int = 0,
) -> None:
"""Assert that the ... | diff --git a/testing/test_pytester.py b/testing/test_pytester.py
--- a/testing/test_pytester.py
+++ b/testing/test_pytester.py
@@ -861,3 +861,17 @@ def test_with_warning():
)
result = pytester.runpytest()
result.assert_outcomes(passed=1, warnings=1)
+
+
+def test_pytester_outcomes_deselected(pytester: Py... | Add a `deselected` parameter to `assert_outcomes()`
<!--
Thanks for suggesting a feature!
Quick check-list while suggesting features:
-->
#### What's the problem this feature will solve?
<!-- What are you trying to do, that you are unable to achieve with pytest as it currently stands? -->
I'd like to be able to use `... | Sounds reasonable. 👍
Hi! I would like to work on this proposal. I went ahead and modified `pytester.RunResult.assert_outcomes()` to also compare the `deselected` count to that returned by `parseoutcomes()`. I also modified `pytester_assertions.assert_outcomes()` called by `pytester.RunResult.assert_outcomes()`.
Whil... | 2021-09-29T14:28:54Z | 7 | ["testing/test_pytester.py::test_pytester_outcomes_deselected"] | ["testing/test_pytester.py::TestInlineRunModulesCleanup::test_external_test_module_imports_not_cleaned_up", "testing/test_pytester.py::TestInlineRunModulesCleanup::test_inline_run_sys_modules_snapshot_restore_preserving_modules", "testing/test_pytester.py::TestInlineRunModulesCleanup::test_inline_run_taking_and_restori... | e2ee3144ed6e241dea8d96215fcdca18b3892551 |
pytest-dev/pytest | pytest-dev__pytest-9249 | 1824349f74298112722396be6f84a121bc9d6d63 | diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py
--- a/src/_pytest/mark/expression.py
+++ b/src/_pytest/mark/expression.py
@@ -6,7 +6,7 @@
expr: and_expr ('or' and_expr)*
and_expr: not_expr ('and' not_expr)*
not_expr: 'not' not_expr | '(' expr ')' | ident
-ident: (\w|:|\+|-... | diff --git a/testing/test_mark.py b/testing/test_mark.py
--- a/testing/test_mark.py
+++ b/testing/test_mark.py
@@ -1111,7 +1111,7 @@ def test_pytest_param_id_allows_none_or_string(s) -> None:
assert pytest.param(id=s)
-@pytest.mark.parametrize("expr", ("NOT internal_err", "NOT (internal_err)", "bogus/"))
+@pyt... | test ids with `/`s cannot be selected with `-k`
By default pytest 6.2.2 parametrize does user arguments to generate IDs, but some of these ids cannot be used with `-k` option because you endup with errors like `unexpected character "/"` when trying to do so.
The solution for this bug is to assure that auto-generated ... | The test ids are not invalid, keyword expressions are simply not able to express slashes
It's not clear to me if that should be added
I am not sure either, but I wanted to underline the issue, hoping that we can find a way to improve the UX. The idea is what what we display should also be easily used to run a test or... | 2021-10-29T13:58:57Z | 7 | ["testing/test_mark_expression.py::test_valid_idents[a/b]"] | ["testing/test_mark.py::TestFunctional::test_keyword_added_for_session", "testing/test_mark.py::TestFunctional::test_keywords_at_node_level", "testing/test_mark.py::TestFunctional::test_mark_closest", "testing/test_mark.py::TestFunctional::test_mark_decorator_baseclasses_merged", "testing/test_mark.py::TestFunctional::... | e2ee3144ed6e241dea8d96215fcdca18b3892551 |
pytest-dev/pytest | pytest-dev__pytest-9359 | e2ee3144ed6e241dea8d96215fcdca18b3892551 | diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py
--- a/src/_pytest/_code/source.py
+++ b/src/_pytest/_code/source.py
@@ -149,6 +149,11 @@ def get_statement_startend2(lineno: int, node: ast.AST) -> Tuple[int, Optional[i
values: List[int] = []
for x in ast.walk(node):
if isinstanc... | diff --git a/testing/code/test_source.py b/testing/code/test_source.py
--- a/testing/code/test_source.py
+++ b/testing/code/test_source.py
@@ -618,6 +618,19 @@ def something():
assert str(source) == "def func(): raise ValueError(42)"
+def test_decorator() -> None:
+ s = """\
+def foo(f):
+ pass
+
+@foo
+... | Error message prints extra code line when using assert in python3.9
<!--
Thanks for submitting an issue!
Quick check-list while reporting bugs:
-->
- [x] a detailed description of the bug or problem you are having
- [x] output of `pip list` from the virtual environment you are using
- [x] pytest and operating system ... | null | 2021-12-01T14:31:38Z | 7 | ["testing/code/test_source.py::test_decorator"] | ["testing/code/test_source.py::TestAccesses::test_getline", "testing/code/test_source.py::TestAccesses::test_getrange", "testing/code/test_source.py::TestAccesses::test_getrange_step_not_supported", "testing/code/test_source.py::TestAccesses::test_iter", "testing/code/test_source.py::TestAccesses::test_len", "testing/c... | e2ee3144ed6e241dea8d96215fcdca18b3892551 |
pytest-dev/pytest | pytest-dev__pytest-9646 | 6aaa017b1e81f6eccc48ee4f6b52d25c49747554 | diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py
--- a/src/_pytest/nodes.py
+++ b/src/_pytest/nodes.py
@@ -656,20 +656,6 @@ class Item(Node):
nextitem = None
- def __init_subclass__(cls) -> None:
- problems = ", ".join(
- base.__name__ for base in cls.__bases__ if issubclass(base, ... | diff --git a/testing/test_nodes.py b/testing/test_nodes.py
--- a/testing/test_nodes.py
+++ b/testing/test_nodes.py
@@ -1,3 +1,5 @@
+import re
+import warnings
from pathlib import Path
from typing import cast
from typing import List
@@ -58,30 +60,31 @@ def test_subclassing_both_item_and_collector_deprecated(
req... | Pytest 7 not ignoring warnings as instructed on `pytest.ini`
<!--
Thanks for submitting an issue!
Quick check-list while reporting bugs:
-->
- [x] a detailed description of the bug or problem you are having
- [x] output of `pip list` from the virtual environment you are using
- [x] pytest and operating system version... | null | 2022-02-08T13:38:22Z | 7.1 | ["testing/test_nodes.py::test_subclassing_both_item_and_collector_deprecated"] | ["testing/test_nodes.py::test__check_initialpaths_for_relpath", "testing/test_nodes.py::test_failure_with_changed_cwd", "testing/test_nodes.py::test_iterparentnodeids[-expected0]", "testing/test_nodes.py::test_iterparentnodeids[::xx-expected6]", "testing/test_nodes.py::test_iterparentnodeids[a-expected1]", "testing/tes... | 4a8f8ada431974f2837260af3ed36299fd382814 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10198 | 726fa36f2556e0d604d85a1de48ba56a8b6550db | diff --git a/sklearn/preprocessing/_encoders.py b/sklearn/preprocessing/_encoders.py
--- a/sklearn/preprocessing/_encoders.py
+++ b/sklearn/preprocessing/_encoders.py
@@ -240,6 +240,8 @@ class OneHotEncoder(_BaseEncoder):
>>> enc.inverse_transform([[0, 1, 1, 0, 0], [0, 0, 0, 1, 0]])
array([['Male', 1],
... | diff --git a/sklearn/preprocessing/tests/test_encoders.py b/sklearn/preprocessing/tests/test_encoders.py
--- a/sklearn/preprocessing/tests/test_encoders.py
+++ b/sklearn/preprocessing/tests/test_encoders.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from __future__ import division
import re
@@ -455,6 +456,47 @@ def t... | add get_feature_names to CategoricalEncoder
We should add a ``get_feature_names`` to the new CategoricalEncoder, as discussed [here](https://github.com/scikit-learn/scikit-learn/pull/9151#issuecomment-345830056). I think it would be good to be consistent with the PolynomialFeature which allows passing in original featu... | I'd like to try this one.
If you haven't contributed before, I suggest you try an issue labeled "good first issue". Though this one isn't too hard, eigher.
@amueller
I think I can handle it.
So we want something like this right?
enc.fit([['male',0], ['female', 1]])
enc.get_feature_names()
>> ['female', '... | 2017-11-24T16:19:38Z | 0.2 | ["sklearn/preprocessing/tests/test_encoders.py::test_one_hot_encoder_feature_names", "sklearn/preprocessing/tests/test_encoders.py::test_one_hot_encoder_feature_names_unicode"] | ["sklearn/preprocessing/tests/test_encoders.py::test_categorical_encoder_stub", "sklearn/preprocessing/tests/test_encoders.py::test_encoder_dtypes", "sklearn/preprocessing/tests/test_encoders.py::test_encoder_dtypes_pandas", "sklearn/preprocessing/tests/test_encoders.py::test_one_hot_encoder[mixed]", "sklearn/preproces... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10297 | b90661d6a46aa3619d3eec94d5281f5888add501 | diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py
--- a/sklearn/linear_model/ridge.py
+++ b/sklearn/linear_model/ridge.py
@@ -1212,18 +1212,18 @@ class RidgeCV(_BaseRidgeCV, RegressorMixin):
store_cv_values : boolean, default=False
Flag indicating if the cross-validation values ... | diff --git a/sklearn/linear_model/tests/test_ridge.py b/sklearn/linear_model/tests/test_ridge.py
--- a/sklearn/linear_model/tests/test_ridge.py
+++ b/sklearn/linear_model/tests/test_ridge.py
@@ -575,8 +575,7 @@ def test_class_weights_cv():
def test_ridgecv_store_cv_values():
- # Test _RidgeCV's store_cv_values ... | linear_model.RidgeClassifierCV's Parameter store_cv_values issue
#### Description
Parameter store_cv_values error on sklearn.linear_model.RidgeClassifierCV
#### Steps/Code to Reproduce
import numpy as np
from sklearn import linear_model as lm
#test database
n = 100
x = np.random.randn(n, 30)
y = np.random.normal(size... | thanks for the report. PR welcome.
Can I give it a try?
sure, thanks! please make the change and add a test in your pull request
Can I take this?
Thanks for the PR! LGTM
@MechCoder review and merge?
I suppose this should include a brief test...
Indeed, please @yurii-andrieiev add a quick test to check that setti... | 2017-12-12T22:07:47Z | 0.2 | ["sklearn/linear_model/tests/test_ridge.py::test_ridge_classifier_cv_store_cv_values"] | ["sklearn/linear_model/tests/test_ridge.py::test_class_weight_vs_sample_weight", "sklearn/linear_model/tests/test_ridge.py::test_class_weights", "sklearn/linear_model/tests/test_ridge.py::test_class_weights_cv", "sklearn/linear_model/tests/test_ridge.py::test_dtype_match", "sklearn/linear_model/tests/test_ridge.py::tes... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10306 | b90661d6a46aa3619d3eec94d5281f5888add501 | diff --git a/sklearn/cluster/affinity_propagation_.py b/sklearn/cluster/affinity_propagation_.py
--- a/sklearn/cluster/affinity_propagation_.py
+++ b/sklearn/cluster/affinity_propagation_.py
@@ -390,5 +390,5 @@ def predict(self, X):
else:
warnings.warn("This model does not have any cluster centers... | diff --git a/sklearn/cluster/tests/test_affinity_propagation.py b/sklearn/cluster/tests/test_affinity_propagation.py
--- a/sklearn/cluster/tests/test_affinity_propagation.py
+++ b/sklearn/cluster/tests/test_affinity_propagation.py
@@ -133,12 +133,14 @@ def test_affinity_propagation_predict_non_convergence():
X = n... | Some UserWarnings should be ConvergenceWarnings
Some warnings raised during testing show that we do not use `ConvergenceWarning` when it is appropriate in some cases. For example (from [here](https://github.com/scikit-learn/scikit-learn/issues/10158#issuecomment-345453334)):
```python
/home/lesteve/dev/alt-scikit-lear... | Could I give this a go?
@patrick1011 please go ahead! | 2017-12-13T15:10:48Z | 0.2 | ["sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation_predict_non_convergence", "sklearn/cluster/tests/test_birch.py::test_n_clusters", "sklearn/cross_decomposition/tests/test_pls.py::test_convergence_fail", "sklearn/decomposition/tests/test_fastica.py::test_fastica_convergence_fail", "sklearn... | ["sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation", "sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities", "sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence", "sklearn/cluster/tests/test_af... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10428 | db127bd9693068a5b187d49d08738e690c5c7d98 | diff --git a/sklearn/utils/estimator_checks.py b/sklearn/utils/estimator_checks.py
--- a/sklearn/utils/estimator_checks.py
+++ b/sklearn/utils/estimator_checks.py
@@ -226,6 +226,7 @@ def _yield_all_checks(name, estimator):
for check in _yield_clustering_checks(name, estimator):
yield check
yi... | diff --git a/sklearn/utils/tests/test_estimator_checks.py b/sklearn/utils/tests/test_estimator_checks.py
--- a/sklearn/utils/tests/test_estimator_checks.py
+++ b/sklearn/utils/tests/test_estimator_checks.py
@@ -134,6 +134,23 @@ def predict(self, X):
return np.ones(X.shape[0])
+class NotInvariantPredict(Bas... | Add common test to ensure all(predict(X[mask]) == predict(X)[mask])
I don't think we currently test that estimator predictions/transformations are invariant whether performed in batch or on subsets of a dataset. For some fitted estimator `est`, data `X` and any boolean mask `mask` of length `X.shape[0]`, we need:
```p... | Hi, could I take this issue ?
sure, it seems right up your alley. thanks!
| 2018-01-08T21:07:00Z | 0.2 | ["sklearn/utils/tests/test_estimator_checks.py::test_check_estimator"] | ["sklearn/utils/tests/test_estimator_checks.py::test_check_estimator_clones", "sklearn/utils/tests/test_estimator_checks.py::test_check_estimator_pairwise", "sklearn/utils/tests/test_estimator_checks.py::test_check_estimators_unfitted", "sklearn/utils/tests/test_estimator_checks.py::test_check_no_attributes_set_in_init... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10443 | 48f3303bfc0be26136b98e9aa95dc3b3f916daff | diff --git a/sklearn/feature_extraction/text.py b/sklearn/feature_extraction/text.py
--- a/sklearn/feature_extraction/text.py
+++ b/sklearn/feature_extraction/text.py
@@ -11,7 +11,7 @@
The :mod:`sklearn.feature_extraction.text` submodule gathers utilities to
build feature vectors from text documents.
"""
-from __fut... | diff --git a/sklearn/feature_extraction/tests/test_text.py b/sklearn/feature_extraction/tests/test_text.py
--- a/sklearn/feature_extraction/tests/test_text.py
+++ b/sklearn/feature_extraction/tests/test_text.py
@@ -1,6 +1,9 @@
from __future__ import unicode_literals
import warnings
+import pytest
+from scipy import... | TfidfVectorizer dtype argument ignored
#### Description
TfidfVectorizer's fit/fit_transform output is always np.float64 instead of the specified dtype
#### Steps/Code to Reproduce
```py
from sklearn.feature_extraction.text import TfidfVectorizer
test = TfidfVectorizer(dtype=np.float32)
print(test.fit_transform(["Help ... | null | 2018-01-10T04:02:32Z | 0.2 | ["sklearn/feature_extraction/tests/test_text.py::test_tfidf_transformer_type[float32]", "sklearn/feature_extraction/tests/test_text.py::test_tfidf_vectorizer_type[float32-float32-None-None]", "sklearn/feature_extraction/tests/test_text.py::test_tfidf_vectorizer_type[int32-float64-UserWarning-'dtype'", "sklearn/feature_... | ["sklearn/feature_extraction/tests/test_text.py::test_char_ngram_analyzer", "sklearn/feature_extraction/tests/test_text.py::test_char_wb_ngram_analyzer", "sklearn/feature_extraction/tests/test_text.py::test_count_binary_occurrences", "sklearn/feature_extraction/tests/test_text.py::test_count_vectorizer_max_features", "... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10452 | 3e5469eda719956c076ae8e685ec1183bfd98569 | diff --git a/sklearn/preprocessing/data.py b/sklearn/preprocessing/data.py
--- a/sklearn/preprocessing/data.py
+++ b/sklearn/preprocessing/data.py
@@ -1325,7 +1325,7 @@ def fit(self, X, y=None):
-------
self : instance
"""
- n_samples, n_features = check_array(X).shape
+ n_sampl... | diff --git a/sklearn/preprocessing/tests/test_data.py b/sklearn/preprocessing/tests/test_data.py
--- a/sklearn/preprocessing/tests/test_data.py
+++ b/sklearn/preprocessing/tests/test_data.py
@@ -7,10 +7,12 @@
import warnings
import re
+
import numpy as np
import numpy.linalg as la
from scipy import sparse, stats... | Polynomial Features for sparse data
I'm not sure if that came up before but PolynomialFeatures doesn't support sparse data, which is not great. Should be easy but I haven't checked ;)
| I'll take this up.
@dalmia @amueller any news on this feature? We're eagerly anticipating it ;-)
See also #3512, #3514
For the benefit of @amueller, my [comment](https://github.com/scikit-learn/scikit-learn/pull/8380#issuecomment-299164291) on #8380:
> [@jnothman] closed both #3512 and #3514 at the time, in favor of... | 2018-01-11T06:56:51Z | 0.2 | ["sklearn/preprocessing/tests/test_data.py::test_polynomial_features_sparse_X[1-True-False-int]", "sklearn/preprocessing/tests/test_data.py::test_polynomial_features_sparse_X[2-True-False-float32]", "sklearn/preprocessing/tests/test_data.py::test_polynomial_features_sparse_X[2-True-False-float64]", "sklearn/preprocessi... | ["sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature", "sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature_coo", "sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature_csc", "sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature_csr", "sklearn/preprocessing/tests/test_d... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10459 | 2e85c8608c93ad0e3290414c4e5e650b87d44b27 | diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py
--- a/sklearn/utils/validation.py
+++ b/sklearn/utils/validation.py
@@ -31,7 +31,7 @@
warnings.simplefilter('ignore', NonBLASDotWarning)
-def _assert_all_finite(X):
+def _assert_all_finite(X, allow_nan=False):
"""Like assert_all_finite, bu... | diff --git a/sklearn/utils/tests/test_validation.py b/sklearn/utils/tests/test_validation.py
--- a/sklearn/utils/tests/test_validation.py
+++ b/sklearn/utils/tests/test_validation.py
@@ -6,8 +6,8 @@
from tempfile import NamedTemporaryFile
from itertools import product
+import pytest
import numpy as np
-from numpy.... | [RFC] Dissociate NaN and Inf when considering force_all_finite in check_array
Due to changes proposed in #10404, it seems that `check_array` as currently a main limitation. `force_all_finite` will force both `NaN` and `inf`to be rejected. If preprocessing methods (whenever this is possible) should let pass `NaN`, this ... | Unsurprisingly, @raghavrv's PR was forgotten in recent discussion of this. I think we want `force_all_finite='allow-nan'` or =`'-nan'` or similar
Note: solving #10438 depends on this decision.
Oops! Had not noticed that @glemaitre had started this issue, so was tinkering around with the "allow_nan" and "allow_inf" ar... | 2018-01-12T09:47:57Z | 0.2 | ["sklearn/utils/tests/test_validation.py::test_check_array_force_all_finite_valid[asarray-nan-allow-nan]", "sklearn/utils/tests/test_validation.py::test_check_array_force_all_finite_valid[csr_matrix-nan-allow-nan]"] | ["sklearn/utils/tests/test_validation.py::test_as_float_array", "sklearn/utils/tests/test_validation.py::test_as_float_array_nan[X0]", "sklearn/utils/tests/test_validation.py::test_as_float_array_nan[X1]", "sklearn/utils/tests/test_validation.py::test_check_array", "sklearn/utils/tests/test_validation.py::test_check_ar... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10495 | d6aa098dadc5eddca5287e823cacef474ac0d23f | diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py
--- a/sklearn/utils/validation.py
+++ b/sklearn/utils/validation.py
@@ -516,6 +516,15 @@ def check_array(array, accept_sparse=False, dtype="numeric", order=None,
# To ensure that array flags are maintained
array = np.array(... | diff --git a/sklearn/utils/tests/test_validation.py b/sklearn/utils/tests/test_validation.py
--- a/sklearn/utils/tests/test_validation.py
+++ b/sklearn/utils/tests/test_validation.py
@@ -285,6 +285,42 @@ def test_check_array():
result = check_array(X_no_array)
assert_true(isinstance(result, np.ndarray))
+ ... | check_array(X, dtype='numeric') should fail if X has strings
Currently, dtype='numeric' is defined as "dtype is preserved unless array.dtype is object". This seems overly lenient and strange behaviour, as in #9342 where @qinhanmin2014 shows that `check_array(['a', 'b', 'c'], dtype='numeric')` works without error and pr... | ping @jnothman
> This seems overly lenient and strange behaviour, as in #9342 where @qinhanmin2014 shows that check_array(['a', 'b', 'c'], dtype='numeric') works without error and produces an array of strings!
I think you mean #9835 (https://github.com/scikit-learn/scikit-learn/pull/9835#issuecomment-348069380) ?
Y... | 2018-01-18T03:11:24Z | 0.2 | ["sklearn/utils/tests/test_validation.py::test_check_array"] | ["sklearn/utils/tests/test_validation.py::test_as_float_array", "sklearn/utils/tests/test_validation.py::test_as_float_array_nan[X0]", "sklearn/utils/tests/test_validation.py::test_as_float_array_nan[X1]", "sklearn/utils/tests/test_validation.py::test_check_array_accept_sparse_no_exception", "sklearn/utils/tests/test_v... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10581 | b27e285ea39450550fc8c81f308a91a660c03a56 | diff --git a/sklearn/linear_model/coordinate_descent.py b/sklearn/linear_model/coordinate_descent.py
--- a/sklearn/linear_model/coordinate_descent.py
+++ b/sklearn/linear_model/coordinate_descent.py
@@ -700,19 +700,23 @@ def fit(self, X, y, check_input=True):
raise ValueError('precompute should be one of T... | diff --git a/sklearn/linear_model/tests/test_coordinate_descent.py b/sklearn/linear_model/tests/test_coordinate_descent.py
--- a/sklearn/linear_model/tests/test_coordinate_descent.py
+++ b/sklearn/linear_model/tests/test_coordinate_descent.py
@@ -3,6 +3,7 @@
# License: BSD 3 clause
import numpy as np
+import pytest... | ElasticNet overwrites X even with copy_X=True
The `fit` function of an `ElasticNet`, called with `check_input=False`, overwrites X, even when `copy_X=True`:
```python
import numpy as np
from sklearn.linear_model import ElasticNet
rng = np.random.RandomState(0)
n_samples, n_features = 20, 2
X = rng.randn(n_samples, n_... | I think this will be easy to fix. The culprit is this line https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/linear_model/coordinate_descent.py#L715 which passes `copy=False`, instead of `copy=self.copy_X`. That'll probably fix the issue.
Thanks for reporting it.
Thanks for the diagnosis, @gxyd!
@jnothm... | 2018-02-03T15:23:17Z | 0.2 | ["sklearn/linear_model/tests/test_coordinate_descent.py::test_enet_copy_X_True[False]"] | ["sklearn/linear_model/tests/test_coordinate_descent.py::test_1d_multioutput_enet_and_multitask_enet_cv", "sklearn/linear_model/tests/test_coordinate_descent.py::test_1d_multioutput_lasso_and_multitask_lasso_cv", "sklearn/linear_model/tests/test_coordinate_descent.py::test_check_input_false", "sklearn/linear_model/test... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10687 | 69e9111b437084f99011dde6ab8ccc848c8c3783 | diff --git a/sklearn/linear_model/coordinate_descent.py b/sklearn/linear_model/coordinate_descent.py
--- a/sklearn/linear_model/coordinate_descent.py
+++ b/sklearn/linear_model/coordinate_descent.py
@@ -762,8 +762,12 @@ def fit(self, X, y, check_input=True):
if n_targets == 1:
self.n_iter_ = sel... | diff --git a/sklearn/linear_model/tests/test_coordinate_descent.py b/sklearn/linear_model/tests/test_coordinate_descent.py
--- a/sklearn/linear_model/tests/test_coordinate_descent.py
+++ b/sklearn/linear_model/tests/test_coordinate_descent.py
@@ -803,3 +803,9 @@ def test_enet_l1_ratio():
est.fit(X, y[:, None])... | Shape of `coef_` wrong for linear_model.Lasso when using `fit_intercept=False`
<!--
If your issue is a usage question, submit it here instead:
- StackOverflow with the scikit-learn tag: http://stackoverflow.com/questions/tagged/scikit-learn
- Mailing List: https://mail.python.org/mailman/listinfo/scikit-learn
For more... | So coef_ is a 0-dimensional array. Sounds like a misuse of `np.squeeze`.
Hi, Jnothman, I am new to this community, may I try this one? @jnothman
Sure, if you understand the problem: add a test, fix it, and open a pull
request.
@jnothman
This problem happens to Elastic Net too. Not just Lasso. But I did not find it ... | 2018-02-24T16:37:13Z | 0.2 | ["sklearn/linear_model/tests/test_coordinate_descent.py::test_coef_shape_not_zero"] | ["sklearn/linear_model/tests/test_coordinate_descent.py::test_1d_multioutput_enet_and_multitask_enet_cv", "sklearn/linear_model/tests/test_coordinate_descent.py::test_1d_multioutput_lasso_and_multitask_lasso_cv", "sklearn/linear_model/tests/test_coordinate_descent.py::test_check_input_false", "sklearn/linear_model/test... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10774 | ccbf9975fcf1676f6ac4f311e388529d3a3c4d3f | diff --git a/sklearn/datasets/california_housing.py b/sklearn/datasets/california_housing.py
--- a/sklearn/datasets/california_housing.py
+++ b/sklearn/datasets/california_housing.py
@@ -50,7 +50,8 @@
logger = logging.getLogger(__name__)
-def fetch_california_housing(data_home=None, download_if_missing=True):
+def... | diff --git a/sklearn/datasets/tests/test_20news.py b/sklearn/datasets/tests/test_20news.py
--- a/sklearn/datasets/tests/test_20news.py
+++ b/sklearn/datasets/tests/test_20news.py
@@ -5,6 +5,8 @@
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_true
from sklearn.utils.testing im... | return_X_y should be available on more dataset loaders/fetchers
Version 0.18 added a `return_X_y` option to `load_iris` et al., but not to, for example, `fetch_kddcup99`.
All dataset loaders that currently return Bunches should also be able to return (X, y).
| Looks like a doable first issue - may I take it on?
Sure.
On 1 March 2018 at 12:59, Chris Catalfo <notifications@github.com> wrote:
> Looks like a doable first issue - may I take it on?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.... | 2018-03-08T02:48:49Z | 0.2 | ["sklearn/datasets/tests/test_lfw.py::test_load_fake_lfw_people"] | ["sklearn/datasets/tests/test_base.py::test_bunch_dir", "sklearn/datasets/tests/test_base.py::test_bunch_pickle_generated_with_0_16_and_read_with_0_17", "sklearn/datasets/tests/test_base.py::test_data_home", "sklearn/datasets/tests/test_base.py::test_default_empty_load_files", "sklearn/datasets/tests/test_base.py::test... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10870 | b0e91e4110942e5b3c4333b1c6b6dfefbd1a6124 | diff --git a/sklearn/mixture/base.py b/sklearn/mixture/base.py
--- a/sklearn/mixture/base.py
+++ b/sklearn/mixture/base.py
@@ -172,11 +172,14 @@ def _initialize(self, X, resp):
def fit(self, X, y=None):
"""Estimate model parameters with the EM algorithm.
- The method fits the model `n_init` times... | diff --git a/sklearn/mixture/tests/test_gaussian_mixture.py b/sklearn/mixture/tests/test_gaussian_mixture.py
--- a/sklearn/mixture/tests/test_gaussian_mixture.py
+++ b/sklearn/mixture/tests/test_gaussian_mixture.py
@@ -764,7 +764,6 @@ def test_gaussian_mixture_verbose():
def test_warm_start():
-
random_state ... | In Gaussian mixtures, when n_init > 1, the lower_bound_ is not always the max
#### Description
In Gaussian mixtures, when `n_init` is set to any value greater than 1, the `lower_bound_` is not the max lower bound across all initializations, but just the lower bound of the last initialization.
The bug can be fixed by a... | 2018-03-25T14:06:57Z | 0.2 | ["sklearn/mixture/tests/test_gaussian_mixture.py::test_init"] | ["sklearn/mixture/tests/test_gaussian_mixture.py::test_bic_1d_1component", "sklearn/mixture/tests/test_gaussian_mixture.py::test_check_X", "sklearn/mixture/tests/test_gaussian_mixture.py::test_check_means", "sklearn/mixture/tests/test_gaussian_mixture.py::test_check_precisions", "sklearn/mixture/tests/test_gaussian_mix... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 | |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10881 | 4989a9503753a92089f39e154a2bb5d160b5d276 | diff --git a/sklearn/linear_model/logistic.py b/sklearn/linear_model/logistic.py
--- a/sklearn/linear_model/logistic.py
+++ b/sklearn/linear_model/logistic.py
@@ -707,7 +707,7 @@ def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True,
func, w0, fprime=None,
args=(... | diff --git a/sklearn/linear_model/tests/test_logistic.py b/sklearn/linear_model/tests/test_logistic.py
--- a/sklearn/linear_model/tests/test_logistic.py
+++ b/sklearn/linear_model/tests/test_logistic.py
@@ -800,15 +800,6 @@ def test_logistic_regression_class_weights():
assert_array_almost_equal(clf1.coef_, clf... | No warning when LogisticRegression does not converge
<!--
If your issue is a usage question, submit it here instead:
- StackOverflow with the scikit-learn tag: http://stackoverflow.com/questions/tagged/scikit-learn
- Mailing List: https://mail.python.org/mailman/listinfo/scikit-learn
For more information, see User Ques... | If you use verbose=1 in your snippet, you'll get plenty of ConvergenceWarning.
```py
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegressionCV
data = load_breast_cancer()
y = data.target
X = data.data
clf = LogisticRegressionCV(verbose=1)
clf.fit(X, y)
print(clf.n_iter_)
`... | 2018-03-28T12:36:45Z | 0.2 | ["sklearn/linear_model/tests/test_logistic.py::test_max_iter", "sklearn/svm/tests/test_svm.py::test_linear_svm_convergence_warnings"] | ["sklearn/linear_model/tests/test_logistic.py::test_check_solver_option", "sklearn/linear_model/tests/test_logistic.py::test_consistency_path", "sklearn/linear_model/tests/test_logistic.py::test_dtype_match", "sklearn/linear_model/tests/test_logistic.py::test_error", "sklearn/linear_model/tests/test_logistic.py::test_i... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-10986 | ca436e7017ae069a29de19caf71689e9b9b9c452 | diff --git a/sklearn/linear_model/logistic.py b/sklearn/linear_model/logistic.py
--- a/sklearn/linear_model/logistic.py
+++ b/sklearn/linear_model/logistic.py
@@ -675,7 +675,13 @@ def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True,
'shape (%d, %d) or (%d, %d)' % (
... | diff --git a/sklearn/linear_model/tests/test_logistic.py b/sklearn/linear_model/tests/test_logistic.py
--- a/sklearn/linear_model/tests/test_logistic.py
+++ b/sklearn/linear_model/tests/test_logistic.py
@@ -7,6 +7,7 @@
from sklearn.preprocessing import LabelEncoder
from sklearn.utils import compute_class_weight
from... | Warm start bug when fitting a LogisticRegression model on binary outcomes with `multi_class='multinomial'`.
<!--
If your issue is a usage question, submit it here instead:
- StackOverflow with the scikit-learn tag: http://stackoverflow.com/questions/tagged/scikit-learn
- Mailing List: https://mail.python.org/mailman/li... | Thanks for the report. At a glance, that looks very plausible.. Test and patch welcome
I'm happy to do this although would be interested in opinions on the test. I could do either
1) Test what causes the bug above i.e. the model doesn't converge when warm starting.
2) Test that the initial `w0` used in `logistic_regre... | 2018-04-16T17:53:06Z | 0.2 | ["sklearn/linear_model/tests/test_logistic.py::test_warm_start_converge_LR"] | ["sklearn/linear_model/tests/test_logistic.py::test_check_solver_option", "sklearn/linear_model/tests/test_logistic.py::test_consistency_path", "sklearn/linear_model/tests/test_logistic.py::test_dtype_match", "sklearn/linear_model/tests/test_logistic.py::test_error", "sklearn/linear_model/tests/test_logistic.py::test_i... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-11281 | 4143356c3c51831300789e4fdf795d83716dbab6 | diff --git a/sklearn/mixture/base.py b/sklearn/mixture/base.py
--- a/sklearn/mixture/base.py
+++ b/sklearn/mixture/base.py
@@ -172,7 +172,7 @@ def _initialize(self, X, resp):
def fit(self, X, y=None):
"""Estimate model parameters with the EM algorithm.
- The method fit the model `n_init` times an... | diff --git a/sklearn/mixture/tests/test_bayesian_mixture.py b/sklearn/mixture/tests/test_bayesian_mixture.py
--- a/sklearn/mixture/tests/test_bayesian_mixture.py
+++ b/sklearn/mixture/tests/test_bayesian_mixture.py
@@ -1,12 +1,16 @@
# Author: Wei Xue <xuewei4d@gmail.com>
# Thierry Guillemot <thierry.guillemot... | Should mixture models have a clusterer-compatible interface
Mixture models are currently a bit different. They are basically clusterers, except they are probabilistic, and are applied to inductive problems unlike many clusterers. But they are unlike clusterers in API:
* they have an `n_components` parameter, with ident... | In my opinion, yes.
I wanted to compare K-Means, GMM and HDBSCAN and was very disappointed that GMM does not have a `fit_predict` method. The HDBSCAN examples use `fit_predict`, so I was expecting GMM to have the same interface.
I think we should add ``fit_predict`` at least. I wouldn't rename ``n_components``.
I woul... | 2018-06-15T17:15:25Z | 0.2 | ["sklearn/mixture/tests/test_bayesian_mixture.py::test_bayesian_mixture_fit_predict", "sklearn/mixture/tests/test_gaussian_mixture.py::test_gaussian_mixture_fit_predict"] | ["sklearn/mixture/tests/test_bayesian_mixture.py::test_bayesian_mixture_check_is_fitted", "sklearn/mixture/tests/test_bayesian_mixture.py::test_bayesian_mixture_covariance_type", "sklearn/mixture/tests/test_bayesian_mixture.py::test_bayesian_mixture_means_prior_initialisation", "sklearn/mixture/tests/test_bayesian_mixt... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-11315 | bb5110b8e0b70d98eae2f7f8b6d4deaa5d2de038 | diff --git a/sklearn/compose/_column_transformer.py b/sklearn/compose/_column_transformer.py
--- a/sklearn/compose/_column_transformer.py
+++ b/sklearn/compose/_column_transformer.py
@@ -6,7 +6,7 @@
# Author: Andreas Mueller
# Joris Van den Bossche
# License: BSD
-
+from itertools import chain
import nump... | diff --git a/sklearn/compose/tests/test_column_transformer.py b/sklearn/compose/tests/test_column_transformer.py
--- a/sklearn/compose/tests/test_column_transformer.py
+++ b/sklearn/compose/tests/test_column_transformer.py
@@ -37,6 +37,14 @@ def transform(self, X, y=None):
return X
+class DoubleTrans(BaseE... | _BaseCompostion._set_params broken where there are no estimators
`_BaseCompostion._set_params` raises an error when the composition has no estimators.
This is a marginal case, but it might be interesting to support alongside #11315.
```py
>>> from sklearn.compose import ColumnTransformer
>>> ColumnTransformer([]).se... | null | 2018-06-18T19:56:04Z | 0.2 | ["sklearn/compose/tests/test_column_transformer.py::test_column_transformer_dataframe", "sklearn/compose/tests/test_column_transformer.py::test_column_transformer_drop_all_sparse_remainder_transformer", "sklearn/compose/tests/test_column_transformer.py::test_column_transformer_drops_all_remainder_transformer", "sklearn... | ["sklearn/compose/tests/test_column_transformer.py::test_2D_transformer_output", "sklearn/compose/tests/test_column_transformer.py::test_2D_transformer_output_pandas", "sklearn/compose/tests/test_column_transformer.py::test_column_transformer", "sklearn/compose/tests/test_column_transformer.py::test_column_transformer_... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-11496 | cb0140017740d985960911c4f34820beea915846 | diff --git a/sklearn/impute.py b/sklearn/impute.py
--- a/sklearn/impute.py
+++ b/sklearn/impute.py
@@ -133,7 +133,6 @@ class SimpleImputer(BaseEstimator, TransformerMixin):
a new copy will always be made, even if `copy=False`:
- If X is not an array of floating values;
- - If X is sparse and ... | diff --git a/sklearn/tests/test_impute.py b/sklearn/tests/test_impute.py
--- a/sklearn/tests/test_impute.py
+++ b/sklearn/tests/test_impute.py
@@ -97,6 +97,23 @@ def test_imputation_deletion_warning(strategy):
imputer.fit_transform(X)
+@pytest.mark.parametrize("strategy", ["mean", "median",
+ ... | BUG: SimpleImputer gives wrong result on sparse matrix with explicit zeros
The current implementation of the `SimpleImputer` can't deal with zeros stored explicitly in sparse matrix.
Even when stored explicitly, we'd expect that all zeros are treating equally, right ?
See for example the code below:
```python
import nu... | null | 2018-07-12T17:05:58Z | 0.2 | ["sklearn/tests/test_impute.py::test_imputation_error_sparse_0[constant]", "sklearn/tests/test_impute.py::test_imputation_error_sparse_0[mean]", "sklearn/tests/test_impute.py::test_imputation_error_sparse_0[median]", "sklearn/tests/test_impute.py::test_imputation_error_sparse_0[most_frequent]"] | ["sklearn/tests/test_impute.py::test_chained_imputer_additive_matrix", "sklearn/tests/test_impute.py::test_chained_imputer_clip", "sklearn/tests/test_impute.py::test_chained_imputer_imputation_order[arabic]", "sklearn/tests/test_impute.py::test_chained_imputer_imputation_order[ascending]", "sklearn/tests/test_impute.py... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-11542 | cd7d9d985e1bbe2dbbbae17da0e9fbbba7e8c8c6 | diff --git a/examples/applications/plot_prediction_latency.py b/examples/applications/plot_prediction_latency.py
--- a/examples/applications/plot_prediction_latency.py
+++ b/examples/applications/plot_prediction_latency.py
@@ -285,7 +285,7 @@ def plot_benchmark_throughput(throughputs, configuration):
'complex... | diff --git a/sklearn/ensemble/tests/test_forest.py b/sklearn/ensemble/tests/test_forest.py
--- a/sklearn/ensemble/tests/test_forest.py
+++ b/sklearn/ensemble/tests/test_forest.py
@@ -31,6 +31,7 @@
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import assert_warns
from sklearn.utils.testin... | Change default n_estimators in RandomForest (to 100?)
Analysis of code on github shows that people use default parameters when they shouldn't. We can make that a little bit less bad by providing reasonable defaults. The default for n_estimators is not great imho and I think we should change it. I suggest 100.
We could ... | I would like to give it a shot. Is the default value 100 final?
@ArihantJain456 I didn't tag this one as "help wanted" because I wanted to wait for other core devs to chime in before we do anything.
I agree. Bad defaults should be deprecated. The warning doesn't hurt.
I'm also +1 for n_estimators=100 by default
Both... | 2018-07-15T22:29:04Z | 0.2 | ["sklearn/ensemble/tests/test_forest.py::test_nestimators_future_warning[ExtraTreesClassifier]", "sklearn/ensemble/tests/test_forest.py::test_nestimators_future_warning[ExtraTreesRegressor]", "sklearn/ensemble/tests/test_forest.py::test_nestimators_future_warning[RandomForestClassifier]", "sklearn/ensemble/tests/test_f... | ["sklearn/ensemble/tests/test_forest.py::test_1d_input[ExtraTreesClassifier]", "sklearn/ensemble/tests/test_forest.py::test_1d_input[ExtraTreesRegressor]", "sklearn/ensemble/tests/test_forest.py::test_1d_input[RandomForestClassifier]", "sklearn/ensemble/tests/test_forest.py::test_1d_input[RandomForestRegressor]", "skle... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-11578 | dd69361a0d9c6ccde0d2353b00b86e0e7541a3e3 | diff --git a/sklearn/linear_model/logistic.py b/sklearn/linear_model/logistic.py
--- a/sklearn/linear_model/logistic.py
+++ b/sklearn/linear_model/logistic.py
@@ -922,7 +922,7 @@ def _log_reg_scoring_path(X, y, train, test, pos_class=None, Cs=10,
check_input=False, max_squared_sum=max_squared_sum,
sam... | diff --git a/sklearn/linear_model/tests/test_logistic.py b/sklearn/linear_model/tests/test_logistic.py
--- a/sklearn/linear_model/tests/test_logistic.py
+++ b/sklearn/linear_model/tests/test_logistic.py
@@ -6,6 +6,7 @@
from sklearn.datasets import load_iris, make_classification
from sklearn.metrics import log_loss
... | For probabilistic scorers, LogisticRegressionCV(multi_class='multinomial') uses OvR to calculate scores
Description:
For scorers such as `neg_log_loss` that use `.predict_proba()` to get probability estimates out of a classifier, the predictions used to generate the scores for `LogisticRegression(multi_class='multinom... | Yes, that sounds like a bug. Thanks for the report. A fix and a test is welcome.
> It seems like altering L922 to read
> log_reg = LogisticRegression(fit_intercept=fit_intercept, multi_class=multi_class)
> so that the LogisticRegression() instance supplied to the scoring function at line 955 inherits the multi_class op... | 2018-07-16T23:21:56Z | 0.2 | ["sklearn/linear_model/tests/test_logistic.py::test_logistic_cv_multinomial_score[neg_log_loss-multiclass_agg_list3]"] | ["sklearn/linear_model/tests/test_logistic.py::test_check_solver_option[LogisticRegressionCV]", "sklearn/linear_model/tests/test_logistic.py::test_check_solver_option[LogisticRegression]", "sklearn/linear_model/tests/test_logistic.py::test_consistency_path", "sklearn/linear_model/tests/test_logistic.py::test_dtype_matc... | 55bf5d93e5674f13a1134d93a11fd0cd11aabcd1 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12421 | 013d295a13721ffade7ac321437c6d4458a64c7d | diff --git a/sklearn/cluster/optics_.py b/sklearn/cluster/optics_.py
--- a/sklearn/cluster/optics_.py
+++ b/sklearn/cluster/optics_.py
@@ -39,9 +39,8 @@ def optics(X, min_samples=5, max_eps=np.inf, metric='minkowski',
This implementation deviates from the original OPTICS by first performing
k-nearest-neighbor... | diff --git a/sklearn/cluster/tests/test_optics.py b/sklearn/cluster/tests/test_optics.py
--- a/sklearn/cluster/tests/test_optics.py
+++ b/sklearn/cluster/tests/test_optics.py
@@ -22,7 +22,7 @@
rng = np.random.RandomState(0)
-n_points_per_cluster = 50
+n_points_per_cluster = 10
C1 = [-5, -2] + .8 * rng.randn(n_poi... | OPTICS: self.core_distances_ inconsistent with documentation&R implementation
In the doc, we state that ``Points which will never be core have a distance of inf.``, but it's not the case.
Result from scikit-learn:
```
import numpy as np
from sklearn.cluster import OPTICS
X = np.array([-5, -2, -4.8, -1.8, -5.2, -2.2, 10... | Does this have an impact on the clustering? I assume it doesn't. But yes, I
suppose we can mask those out as inf.
> Does this have an impact on the clustering?
AFAIK, no. So maybe it's not an urgent one. (I'll try to debug other urgent issues these days). My point here is that we should ensure the correctness of publ... | 2018-10-19T09:32:51Z | 0.21 | ["sklearn/cluster/tests/test_optics.py::test_compare_to_ELKI", "sklearn/cluster/tests/test_optics.py::test_processing_order"] | ["sklearn/cluster/tests/test_optics.py::test_bad_extract", "sklearn/cluster/tests/test_optics.py::test_bad_reachability", "sklearn/cluster/tests/test_optics.py::test_close_extract", "sklearn/cluster/tests/test_optics.py::test_cluster_sigmin_pruning[reach0-2-members0]", "sklearn/cluster/tests/test_optics.py::test_cluste... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12462 | 9ec5a15823dcb924a5cca322f9f97357f9428345 | diff --git a/sklearn/utils/validation.py b/sklearn/utils/validation.py
--- a/sklearn/utils/validation.py
+++ b/sklearn/utils/validation.py
@@ -140,7 +140,12 @@ def _num_samples(x):
if len(x.shape) == 0:
raise TypeError("Singleton array %r cannot be considered"
" a vali... | diff --git a/sklearn/utils/tests/test_validation.py b/sklearn/utils/tests/test_validation.py
--- a/sklearn/utils/tests/test_validation.py
+++ b/sklearn/utils/tests/test_validation.py
@@ -41,6 +41,7 @@
check_memory,
check_non_negative,
LARGE_SPARSE_SUPPORTED,
+ _num_samples
)
import sklearn
@@ -786... | SkLearn `.score()` method generating error with Dask DataFrames
When using Dask Dataframes with SkLearn, I used to be able to just ask SkLearn for the score of any given algorithm. It would spit out a nice answer and I'd move on. After updating to the newest versions, all metrics that compute based on (y_true, y_predic... | Some context: dask DataFrame doesn't know it's length. Previously, it didn't have a `shape` attribute.
Now dask DataFrame has a shape that returns a `Tuple[Delayed, int]` for the number of rows and columns.
> Work-around shown below, but it's not ideal because it requires me to cast from Dask Arrays to numpy arrays w... | 2018-10-25T21:53:00Z | 0.21 | ["sklearn/utils/tests/test_validation.py::test_retrieve_samples_from_non_standard_shape"] | ["sklearn/utils/tests/test_validation.py::test_as_float_array", "sklearn/utils/tests/test_validation.py::test_as_float_array_nan[X0]", "sklearn/utils/tests/test_validation.py::test_as_float_array_nan[X1]", "sklearn/utils/tests/test_validation.py::test_check_X_y_informative_error", "sklearn/utils/tests/test_validation.p... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12557 | 4de404d46d24805ff48ad255ec3169a5155986f0 | diff --git a/examples/svm/plot_svm_tie_breaking.py b/examples/svm/plot_svm_tie_breaking.py
new file mode 100644
--- /dev/null
+++ b/examples/svm/plot_svm_tie_breaking.py
@@ -0,0 +1,64 @@
+"""
+=========================================================
+SVM Tie Breaking Example
+==========================================... | diff --git a/sklearn/svm/tests/test_svm.py b/sklearn/svm/tests/test_svm.py
--- a/sklearn/svm/tests/test_svm.py
+++ b/sklearn/svm/tests/test_svm.py
@@ -985,6 +985,41 @@ def test_ovr_decision_function():
assert np.all(pred_class_deci_val[:, 0] < pred_class_deci_val[:, 1])
+@pytest.mark.parametrize("SVCClass", [s... | SVC.decision_function disagrees with predict
In ``SVC`` with ``decision_function_shape="ovr"`` argmax of the decision function is not the same as ``predict``. This is related to the tie-breaking mentioned in #8276.
The ``decision_function`` now includes tie-breaking, which the ``predict`` doesn't.
I'm not sure the tie... | The relevant issue on `libsvm` (i.e. issue https://github.com/cjlin1/libsvm/issues/85) seems to be stalled and I'm not sure if it's had a conclusion. At least on the `libsvm` side it seems they prefer not to include the confidences for computational cost of it.
Now the question is, do we want to change the `svm.cpp` t... | 2018-11-10T15:45:52Z | 0.22 | ["sklearn/svm/tests/test_svm.py::test_svc_invalid_break_ties_param[NuSVC]", "sklearn/svm/tests/test_svm.py::test_svc_invalid_break_ties_param[SVC]", "sklearn/svm/tests/test_svm.py::test_svc_ovr_tie_breaking[NuSVC]", "sklearn/svm/tests/test_svm.py::test_svc_ovr_tie_breaking[SVC]"] | ["sklearn/svm/tests/test_svm.py::test_auto_weight", "sklearn/svm/tests/test_svm.py::test_bad_input", "sklearn/svm/tests/test_svm.py::test_consistent_proba", "sklearn/svm/tests/test_svm.py::test_crammer_singer_binary", "sklearn/svm/tests/test_svm.py::test_decision_function", "sklearn/svm/tests/test_svm.py::test_decision... | 7e85a6d1f038bbb932b36f18d75df6be937ed00d |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12583 | e8c6cb151cff869cf1b61bddd3c72841318501ab | diff --git a/sklearn/impute.py b/sklearn/impute.py
--- a/sklearn/impute.py
+++ b/sklearn/impute.py
@@ -141,13 +141,26 @@ class SimpleImputer(BaseEstimator, TransformerMixin):
a new copy will always be made, even if `copy=False`:
- If X is not an array of floating values;
- - If X is encoded a... | diff --git a/sklearn/tests/test_impute.py b/sklearn/tests/test_impute.py
--- a/sklearn/tests/test_impute.py
+++ b/sklearn/tests/test_impute.py
@@ -952,15 +952,15 @@ def test_missing_indicator_error(X_fit, X_trans, params, msg_err):
])
@pytest.mark.parametrize(
"param_features, n_features, features_indices",... | add_indicator switch in imputers
For whatever imputers we have, but especially [SimpleImputer](http://scikit-learn.org/dev/modules/generated/sklearn.impute.SimpleImputer.html), we should have an `add_indicator` parameter, which simply stacks a [MissingIndicator](http://scikit-learn.org/dev/modules/generated/sklearn.imp... | This allows downstream models to adjust for the fact that a value was imputed, rather than observed.
Can I take this up if no one else is working on it yet @jnothman ?
Go for it
@prathusha94 are you still working on this? | 2018-11-14T11:41:05Z | 0.21 | ["sklearn/tests/test_impute.py::test_imputation_add_indicator[-1]", "sklearn/tests/test_impute.py::test_imputation_add_indicator[0]", "sklearn/tests/test_impute.py::test_imputation_add_indicator[nan]", "sklearn/tests/test_impute.py::test_imputation_add_indicator_sparse_matrix[bsr_matrix]", "sklearn/tests/test_impute.py... | ["sklearn/tests/test_impute.py::test_imputation_const_mostf_error_invalid_types[dtype1-constant]", "sklearn/tests/test_impute.py::test_imputation_const_mostf_error_invalid_types[dtype1-most_frequent]", "sklearn/tests/test_impute.py::test_imputation_const_mostf_error_invalid_types[dtype2-constant]", "sklearn/tests/test_... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12834 | 55a98ab7e3b10966f6d00c3562f3a99896797964 | diff --git a/sklearn/ensemble/forest.py b/sklearn/ensemble/forest.py
--- a/sklearn/ensemble/forest.py
+++ b/sklearn/ensemble/forest.py
@@ -547,7 +547,10 @@ def predict(self, X):
else:
n_samples = proba[0].shape[0]
- predictions = np.zeros((n_samples, self.n_outputs_))
+ # a... | diff --git a/sklearn/ensemble/tests/test_forest.py b/sklearn/ensemble/tests/test_forest.py
--- a/sklearn/ensemble/tests/test_forest.py
+++ b/sklearn/ensemble/tests/test_forest.py
@@ -532,14 +532,14 @@ def check_multioutput(name):
if name in FOREST_CLASSIFIERS:
with np.errstate(divide="ignore"):
... | `predict` fails for multioutput ensemble models with non-numeric DVs
#### Description
<!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluate_every > 0-->
Multioutput forest models assume that the dependent variables are numeric. Passing string DVs returns the following error:
`Va... | Is numeric-only an intentional limitation in this case? There are lines that explicitly cast to double (https://github.com/scikit-learn/scikit-learn/blob/e73acef80de4159722b11e3cd6c20920382b9728/sklearn/ensemble/forest.py#L279). It's not an issue for single-output models, though.
Sorry what do you mean by "DV"?
You're ... | 2018-12-19T22:36:36Z | 0.21 | ["sklearn/ensemble/tests/test_forest.py::test_multioutput_string[ExtraTreesClassifier]", "sklearn/ensemble/tests/test_forest.py::test_multioutput_string[RandomForestClassifier]"] | ["sklearn/ensemble/tests/test_forest.py::test_1d_input[ExtraTreesClassifier]", "sklearn/ensemble/tests/test_forest.py::test_1d_input[ExtraTreesRegressor]", "sklearn/ensemble/tests/test_forest.py::test_1d_input[RandomForestClassifier]", "sklearn/ensemble/tests/test_forest.py::test_1d_input[RandomForestRegressor]", "skle... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12938 | acb810647233e40839203ac553429e8663169702 | diff --git a/sklearn/utils/_pprint.py b/sklearn/utils/_pprint.py
--- a/sklearn/utils/_pprint.py
+++ b/sklearn/utils/_pprint.py
@@ -321,7 +321,10 @@ def _pprint_key_val_tuple(self, object, stream, indent, allowance, context,
self._format(v, stream, indent + len(rep) + len(middle), allowance,
... | diff --git a/sklearn/utils/tests/test_pprint.py b/sklearn/utils/tests/test_pprint.py
--- a/sklearn/utils/tests/test_pprint.py
+++ b/sklearn/utils/tests/test_pprint.py
@@ -1,4 +1,5 @@
import re
+from pprint import PrettyPrinter
from sklearn.utils._pprint import _EstimatorPrettyPrinter
from sklearn.pipeline import m... | AttributeError: 'PrettyPrinter' object has no attribute '_indent_at_name'
There's a failing example in #12654, and here's a piece of code causing it:
```
import numpy as np
from sklearn.datasets import load_digits
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.svm i... | So for some reason, the class is `PrettyPrinter` instead of `_EstimatorPrettyPrinter` (which inherits from `PrettyPrinter`). But then
```
File "/path/to//sklearn/utils/_pprint.py", line 175, in _pprint_estimator
if self._indent_at_name:
```
is a `_EstimatorPrettyPrinter` method, so I don't understand what is go... | 2019-01-07T22:45:53Z | 0.21 | ["sklearn/utils/tests/test_pprint.py::test_builtin_prettyprinter"] | ["sklearn/utils/tests/test_pprint.py::test_basic", "sklearn/utils/tests/test_pprint.py::test_changed_only", "sklearn/utils/tests/test_pprint.py::test_deeply_nested", "sklearn/utils/tests/test_pprint.py::test_gridsearch", "sklearn/utils/tests/test_pprint.py::test_gridsearch_pipeline", "sklearn/utils/tests/test_pprint.py... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-12973 | a7b8b9e9e16d4e15fabda5ae615086c2e1c47d8a | diff --git a/sklearn/linear_model/least_angle.py b/sklearn/linear_model/least_angle.py
--- a/sklearn/linear_model/least_angle.py
+++ b/sklearn/linear_model/least_angle.py
@@ -1479,7 +1479,7 @@ def __init__(self, criterion='aic', fit_intercept=True, verbose=False,
self.eps = eps
self.fit_path = True
... | diff --git a/sklearn/linear_model/tests/test_least_angle.py b/sklearn/linear_model/tests/test_least_angle.py
--- a/sklearn/linear_model/tests/test_least_angle.py
+++ b/sklearn/linear_model/tests/test_least_angle.py
@@ -18,7 +18,7 @@
from sklearn.utils.testing import TempMemmap
from sklearn.exceptions import Convergen... | LassoLarsIC: unintuitive copy_X behaviour
Hi, I would like to report what seems to be a bug in the treatment of the `copy_X` parameter of the `LassoLarsIC` class. Because it's a simple bug, it's much easier to see in the code directly than in the execution, so I am not posting steps to reproduce it.
As you can see her... | null | 2019-01-13T16:19:52Z | 0.21 | ["sklearn/linear_model/tests/test_least_angle.py::test_lasso_lars_fit_copyX_behaviour[False]"] | ["sklearn/linear_model/tests/test_least_angle.py::test_all_precomputed", "sklearn/linear_model/tests/test_least_angle.py::test_collinearity", "sklearn/linear_model/tests/test_least_angle.py::test_estimatorclasses_positive_constraint", "sklearn/linear_model/tests/test_least_angle.py::test_lars_add_features", "sklearn/li... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13087 | a73260db9c0b63d582ef4a7f3c696b68058c1c43 | diff --git a/sklearn/calibration.py b/sklearn/calibration.py
--- a/sklearn/calibration.py
+++ b/sklearn/calibration.py
@@ -519,7 +519,8 @@ def predict(self, T):
return expit(-(self.a_ * T + self.b_))
-def calibration_curve(y_true, y_prob, normalize=False, n_bins=5):
+def calibration_curve(y_true, y_prob, n... | diff --git a/sklearn/tests/test_calibration.py b/sklearn/tests/test_calibration.py
--- a/sklearn/tests/test_calibration.py
+++ b/sklearn/tests/test_calibration.py
@@ -259,6 +259,21 @@ def test_calibration_curve():
assert_raises(ValueError, calibration_curve, [1.1], [-0.1],
normalize=False)
+ ... | Feature request: support for arbitrary bin spacing in calibration.calibration_curve
#### Description
I was using [`sklearn.calibration.calibration_curve`](https://scikit-learn.org/stable/modules/generated/sklearn.calibration.calibration_curve.html), and it currently accepts an `n_bins` parameter to specify the number o... | It actually sounds like the problem is not the number of bins, but that
bins should be constructed to reflect the distribution, rather than the
range, of the input. I think we should still use n_bins as the primary
parameter, but allow those bins to be quantile based, providing a strategy
option for discretisation (
ht... | 2019-02-04T08:08:07Z | 0.21 | ["sklearn/tests/test_calibration.py::test_calibration_curve"] | ["sklearn/tests/test_calibration.py::test_calibration", "sklearn/tests/test_calibration.py::test_calibration_less_classes", "sklearn/tests/test_calibration.py::test_calibration_multiclass", "sklearn/tests/test_calibration.py::test_calibration_nan_imputer", "sklearn/tests/test_calibration.py::test_calibration_prefit", "... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13157 | 85440978f517118e78dc15f84e397d50d14c8097 | diff --git a/sklearn/base.py b/sklearn/base.py
--- a/sklearn/base.py
+++ b/sklearn/base.py
@@ -359,10 +359,32 @@ def score(self, X, y, sample_weight=None):
-------
score : float
R^2 of self.predict(X) wrt. y.
+
+ Notes
+ -----
+ The R2 score used when calling ``score`... | diff --git a/sklearn/cross_decomposition/tests/test_pls.py b/sklearn/cross_decomposition/tests/test_pls.py
--- a/sklearn/cross_decomposition/tests/test_pls.py
+++ b/sklearn/cross_decomposition/tests/test_pls.py
@@ -1,3 +1,4 @@
+import pytest
import numpy as np
from numpy.testing import assert_approx_equal
@@ -377,6... | Different r2_score multioutput default in r2_score and base.RegressorMixin
We've changed multioutput default in r2_score to "uniform_average" in 0.19, but in base.RegressorMixin, we still use ``multioutput='variance_weighted'`` (#5143).
Also see the strange things below:
https://github.com/scikit-learn/scikit-learn/blo... | Should we be deprecating and changing the `multioutput` used in RegressorMixin? How do we allow the user to select the new approach in a deprecation period?
@agramfort @ogrisel can you explain the rational behind this?
It looks to me like the behavior before the PR was exactly what we wanted an the PR broke the depreca... | 2019-02-13T12:55:30Z | 0.21 | ["sklearn/tests/test_base.py::test_regressormixin_score_multioutput"] | ["sklearn/cross_decomposition/tests/test_pls.py::test_PLSSVD", "sklearn/cross_decomposition/tests/test_pls.py::test_convergence_fail", "sklearn/cross_decomposition/tests/test_pls.py::test_pls", "sklearn/cross_decomposition/tests/test_pls.py::test_pls_errors", "sklearn/cross_decomposition/tests/test_pls.py::test_pls_sca... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13174 | 09bc27630fb8feea2f10627dce25e93cd6ff258a | diff --git a/sklearn/ensemble/weight_boosting.py b/sklearn/ensemble/weight_boosting.py
--- a/sklearn/ensemble/weight_boosting.py
+++ b/sklearn/ensemble/weight_boosting.py
@@ -30,16 +30,15 @@
from scipy.special import xlogy
from .base import BaseEnsemble
-from ..base import ClassifierMixin, RegressorMixin, is_regres... | diff --git a/sklearn/ensemble/tests/test_weight_boosting.py b/sklearn/ensemble/tests/test_weight_boosting.py
--- a/sklearn/ensemble/tests/test_weight_boosting.py
+++ b/sklearn/ensemble/tests/test_weight_boosting.py
@@ -471,7 +471,6 @@ def fit(self, X, y, sample_weight=None):
def test_sample_weight_adaboost_regressor()... | Minimize validation of X in ensembles with a base estimator
Currently AdaBoost\* requires `X` to be an array or sparse matrix of numerics. However, since the data is not processed directly by `AdaBoost*` but by its base estimator (on which `fit`, `predict_proba` and `predict` may be called), we should not need to const... | That could be applied to any meta-estimator that uses a base estimator, right?
Yes, it could be. I didn't have time when I wrote this issue to check the applicability to other ensembles.
Updated title and description
@jnothman I think that we have two options.
- Validate the input early as it is now and introduce a ... | 2019-02-15T22:37:43Z | 0.21 | ["sklearn/ensemble/tests/test_weight_boosting.py::test_multidimensional_X"] | ["sklearn/ensemble/tests/test_weight_boosting.py::test_base_estimator", "sklearn/ensemble/tests/test_weight_boosting.py::test_boston", "sklearn/ensemble/tests/test_weight_boosting.py::test_classification_toy", "sklearn/ensemble/tests/test_weight_boosting.py::test_error", "sklearn/ensemble/tests/test_weight_boosting.py:... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13280 | face9daf045846bb0a39bfb396432c8685570cdd | diff --git a/sklearn/naive_bayes.py b/sklearn/naive_bayes.py
--- a/sklearn/naive_bayes.py
+++ b/sklearn/naive_bayes.py
@@ -460,8 +460,14 @@ def _update_class_log_prior(self, class_prior=None):
" classes.")
self.class_log_prior_ = np.log(class_prior)
elif self.fit_... | diff --git a/sklearn/tests/test_naive_bayes.py b/sklearn/tests/test_naive_bayes.py
--- a/sklearn/tests/test_naive_bayes.py
+++ b/sklearn/tests/test_naive_bayes.py
@@ -18,6 +18,7 @@
from sklearn.utils.testing import assert_raise_message
from sklearn.utils.testing import assert_greater
from sklearn.utils.testing impor... | partial_fit does not account for unobserved target values when fitting priors to data
My understanding is that priors should be fitted to the data using observed target frequencies **and a variant of [Laplace smoothing](https://en.wikipedia.org/wiki/Additive_smoothing) to avoid assigning 0 probability to targets not y... | I can reproduce the bug. Thanks for reporting. I will work on the fix. | 2019-02-26T14:08:41Z | 0.21 | ["sklearn/tests/test_naive_bayes.py::test_mnb_prior_unobserved_targets"] | ["sklearn/tests/test_naive_bayes.py::test_alpha", "sklearn/tests/test_naive_bayes.py::test_alpha_vector", "sklearn/tests/test_naive_bayes.py::test_bnb", "sklearn/tests/test_naive_bayes.py::test_check_accuracy_on_digits", "sklearn/tests/test_naive_bayes.py::test_check_update_with_no_data", "sklearn/tests/test_naive_baye... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13302 | 4de404d46d24805ff48ad255ec3169a5155986f0 | diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py
--- a/sklearn/linear_model/ridge.py
+++ b/sklearn/linear_model/ridge.py
@@ -226,9 +226,17 @@ def _solve_svd(X, y, alpha):
return np.dot(Vt.T, d_UT_y).T
+def _get_valid_accept_sparse(is_X_sparse, solver):
+ if is_X_sparse and solver i... | diff --git a/sklearn/linear_model/tests/test_ridge.py b/sklearn/linear_model/tests/test_ridge.py
--- a/sklearn/linear_model/tests/test_ridge.py
+++ b/sklearn/linear_model/tests/test_ridge.py
@@ -1,3 +1,4 @@
+import os
import numpy as np
import scipy.sparse as sp
from scipy import linalg
@@ -6,6 +7,7 @@
import pytes... | [WIP] EHN: Ridge with solver SAG/SAGA does not cast to float64
closes #11642
build upon #11155
TODO:
- [ ] Merge #11155 to reduce the diff.
- [ ] Ensure that the casting rule is clear between base classes, classes and functions. I suspect that we have some copy which are not useful.
| null | 2019-02-27T10:28:25Z | 0.22 | ["sklearn/linear_model/tests/test_ridge.py::test_dtype_match[sag]", "sklearn/linear_model/tests/test_ridge.py::test_dtype_match[saga]", "sklearn/linear_model/tests/test_ridge.py::test_ridge_regression_dtype_stability[sag]", "sklearn/linear_model/tests/test_ridge.py::test_ridge_regression_dtype_stability[saga]"] | ["sklearn/linear_model/tests/test_ridge.py::test_class_weight_vs_sample_weight[RidgeClassifierCV]", "sklearn/linear_model/tests/test_ridge.py::test_class_weight_vs_sample_weight[RidgeClassifier]", "sklearn/linear_model/tests/test_ridge.py::test_class_weights", "sklearn/linear_model/tests/test_ridge.py::test_class_weigh... | 7e85a6d1f038bbb932b36f18d75df6be937ed00d |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13313 | cdfca8cba33be63ef50ba9e14d8823cc551baf92 | diff --git a/sklearn/utils/estimator_checks.py b/sklearn/utils/estimator_checks.py
--- a/sklearn/utils/estimator_checks.py
+++ b/sklearn/utils/estimator_checks.py
@@ -1992,7 +1992,10 @@ def check_class_weight_balanced_linear_classifier(name, Classifier):
classifier.set_params(class_weight=class_weight)
coef_m... | diff --git a/sklearn/utils/tests/test_estimator_checks.py b/sklearn/utils/tests/test_estimator_checks.py
--- a/sklearn/utils/tests/test_estimator_checks.py
+++ b/sklearn/utils/tests/test_estimator_checks.py
@@ -13,6 +13,8 @@
assert_equal, ignore_warnings,
... | check_class_weight_balanced_classifiers is never run?!
> git grep check_class_weight_balanced_classifiers
sklearn/utils/estimator_checks.py:def check_class_weight_balanced_classifiers(name, Classifier, X_train, y_train,
Same for ``check_class_weight_balanced_linear_classifier``
| `check_class_weight_balanced_linear_classifier` is run at tests/test_common.
```
git grep check_class_weight_balanced_linear_classifier
sklearn/tests/test_common.py: check_class_weight_balanced_linear_classifier)
sklearn/tests/test_common.py: yield _named_check(check_class_weight_balanced_linear_classifier,
s... | 2019-02-27T15:51:20Z | 0.21 | ["sklearn/utils/tests/test_estimator_checks.py::test_check_class_weight_balanced_linear_classifier"] | ["sklearn/utils/tests/test_estimator_checks.py::test_check_estimator", "sklearn/utils/tests/test_estimator_checks.py::test_check_estimator_clones", "sklearn/utils/tests/test_estimator_checks.py::test_check_estimator_pairwise", "sklearn/utils/tests/test_estimator_checks.py::test_check_estimator_transformer_no_mixin", "s... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13333 | 04a5733b86bba57a48520b97b9c0a5cd325a1b9a | diff --git a/sklearn/preprocessing/data.py b/sklearn/preprocessing/data.py
--- a/sklearn/preprocessing/data.py
+++ b/sklearn/preprocessing/data.py
@@ -424,7 +424,7 @@ def minmax_scale(X, feature_range=(0, 1), axis=0, copy=True):
X_scaled = X_std * (max - min) + min
where min, max = feature_range.
-
+
... | diff --git a/sklearn/preprocessing/tests/test_data.py b/sklearn/preprocessing/tests/test_data.py
--- a/sklearn/preprocessing/tests/test_data.py
+++ b/sklearn/preprocessing/tests/test_data.py
@@ -1260,6 +1260,13 @@ def test_quantile_transform_check_error():
assert_raise_message(ValueError,
... | DOC Improve doc of n_quantiles in QuantileTransformer
#### Description
The `QuantileTransformer` uses numpy.percentile(X_train, .) as the estimator of the quantile function of the training data. To know this function perfectly we just need to take `n_quantiles=n_samples`. Then it is just a linear interpolation (which ... | When you say prevent, do you mean that we should raise an error if
n_quantiles > n_samples, or that we should adjust n_quantiles to
min(n_quantiles, n_samples)? I'd be in favour of the latter, perhaps with a
warning. And yes, improved documentation is always good (albeit often
ignored).
I was only talking about the do... | 2019-02-28T15:01:19Z | 0.21 | ["sklearn/preprocessing/tests/test_data.py::test_quantile_transform_check_error"] | ["sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature", "sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature_coo", "sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature_csc", "sklearn/preprocessing/tests/test_data.py::test_add_dummy_feature_csr", "sklearn/preprocessing/tests/test_d... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13363 | eda99f3cec70ba90303de0ef3ab7f988657fadb9 | diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py
--- a/sklearn/linear_model/ridge.py
+++ b/sklearn/linear_model/ridge.py
@@ -368,12 +368,25 @@ def _ridge_regression(X, y, alpha, sample_weight=None, solver='auto',
return_n_iter=False, return_intercept=False,
... | diff --git a/sklearn/linear_model/tests/test_ridge.py b/sklearn/linear_model/tests/test_ridge.py
--- a/sklearn/linear_model/tests/test_ridge.py
+++ b/sklearn/linear_model/tests/test_ridge.py
@@ -7,6 +7,7 @@
from sklearn.utils.testing import assert_almost_equal
from sklearn.utils.testing import assert_array_almost_e... | return_intercept==True in ridge_regression raises an exception
<!--
If your issue is a usage question, submit it here instead:
- StackOverflow with the scikit-learn tag: https://stackoverflow.com/questions/tagged/scikit-learn
- Mailing List: https://mail.python.org/mailman/listinfo/scikit-learn
For more information, se... | null | 2019-03-01T16:25:10Z | 0.21 | ["sklearn/linear_model/tests/test_ridge.py::test_raises_value_error_if_solver_not_supported", "sklearn/linear_model/tests/test_ridge.py::test_ridge_fit_intercept_sparse", "sklearn/linear_model/tests/test_ridge.py::test_ridge_regression_check_arguments_validity[auto-array-None-True]", "sklearn/linear_model/tests/test_ri... | ["sklearn/linear_model/tests/test_ridge.py::test_class_weight_vs_sample_weight[RidgeClassifierCV]", "sklearn/linear_model/tests/test_ridge.py::test_class_weight_vs_sample_weight[RidgeClassifier]", "sklearn/linear_model/tests/test_ridge.py::test_class_weights", "sklearn/linear_model/tests/test_ridge.py::test_class_weigh... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13368 | afd432137fd840adc182f0bad87f405cb80efac7 | diff --git a/sklearn/model_selection/_validation.py b/sklearn/model_selection/_validation.py
--- a/sklearn/model_selection/_validation.py
+++ b/sklearn/model_selection/_validation.py
@@ -876,10 +876,11 @@ def _fit_and_predict(estimator, X, y, train, test, verbose, fit_params,
float_min = np.finfo(predictio... | diff --git a/sklearn/model_selection/tests/test_validation.py b/sklearn/model_selection/tests/test_validation.py
--- a/sklearn/model_selection/tests/test_validation.py
+++ b/sklearn/model_selection/tests/test_validation.py
@@ -975,6 +975,26 @@ def test_cross_val_predict_pandas():
cross_val_predict(clf, X_df, y... | cross_val_predict returns bad prediction when evaluated on a dataset with very few samples
#### Description
`cross_val_predict` returns bad prediction when evaluated on a dataset with very few samples on 1 class, causing class being ignored on some CV splits.
#### Steps/Code to Reproduce
```python
from sklearn.dataset... | null | 2019-03-01T17:46:46Z | 0.21 | ["sklearn/model_selection/tests/test_validation.py::test_cross_val_predict_unbalanced"] | ["sklearn/model_selection/tests/test_validation.py::test_check_is_permutation", "sklearn/model_selection/tests/test_validation.py::test_cross_val_predict", "sklearn/model_selection/tests/test_validation.py::test_cross_val_predict_class_subset", "sklearn/model_selection/tests/test_validation.py::test_cross_val_predict_d... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13472 | 3b35104c93cb53f67fb5f52ae2fece76ef7144da | diff --git a/sklearn/ensemble/gradient_boosting.py b/sklearn/ensemble/gradient_boosting.py
--- a/sklearn/ensemble/gradient_boosting.py
+++ b/sklearn/ensemble/gradient_boosting.py
@@ -1476,20 +1476,25 @@ def fit(self, X, y, sample_weight=None, monitor=None):
raw_predictions = np.zeros(shape=(X.shape[0],... | diff --git a/sklearn/ensemble/tests/test_gradient_boosting.py b/sklearn/ensemble/tests/test_gradient_boosting.py
--- a/sklearn/ensemble/tests/test_gradient_boosting.py
+++ b/sklearn/ensemble/tests/test_gradient_boosting.py
@@ -39,6 +39,9 @@
from sklearn.exceptions import DataConversionWarning
from sklearn.exceptions ... | GradientBoostingRegressor initial estimator does not play together with Pipeline
Using a pipeline as the initial estimator of GradientBoostingRegressor doesn't work due to incompatible signatures.
```python
import sklearn
import sklearn.pipeline
import sklearn.ensemble
import sklearn.decomposition
import sklearn.linea... | null | 2019-03-18T22:15:59Z | 0.21 | ["sklearn/ensemble/tests/test_gradient_boosting.py::test_gradient_boosting_with_init_pipeline"] | ["sklearn/ensemble/tests/test_gradient_boosting.py::test_boston[0.5-huber-False]", "sklearn/ensemble/tests/test_gradient_boosting.py::test_boston[0.5-huber-True]", "sklearn/ensemble/tests/test_gradient_boosting.py::test_boston[0.5-huber-auto]", "sklearn/ensemble/tests/test_gradient_boosting.py::test_boston[0.5-lad-Fals... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13496 | 3aefc834dce72e850bff48689bea3c7dff5f3fad | diff --git a/sklearn/ensemble/iforest.py b/sklearn/ensemble/iforest.py
--- a/sklearn/ensemble/iforest.py
+++ b/sklearn/ensemble/iforest.py
@@ -120,6 +120,12 @@ class IsolationForest(BaseBagging, OutlierMixin):
verbose : int, optional (default=0)
Controls the verbosity of the tree building process.
+ ... | diff --git a/sklearn/ensemble/tests/test_iforest.py b/sklearn/ensemble/tests/test_iforest.py
--- a/sklearn/ensemble/tests/test_iforest.py
+++ b/sklearn/ensemble/tests/test_iforest.py
@@ -295,6 +295,28 @@ def test_score_samples():
clf2.score_samples([[2., 2.]]))
+@pytest.mark.filterwarnings('... | Expose warm_start in Isolation forest
It seems to me that `sklearn.ensemble.IsolationForest` supports incremental addition of new trees with the `warm_start` parameter of its parent class, `sklearn.ensemble.BaseBagging`.
Even though this parameter is not exposed in `__init__()` , it gets inherited from `BaseBagging` a... | +1 to expose `warm_start` in `IsolationForest`, unless there was a good reason for not doing so in the first place. I could not find any related discussion in the IsolationForest PR #4163. ping @ngoix @agramfort?
no objection
>
PR welcome @petibear. Feel
free to ping me when it’s ready for reviews :).
OK, I'm working... | 2019-03-23T09:46:59Z | 0.21 | ["sklearn/ensemble/tests/test_iforest.py::test_iforest_warm_start"] | ["sklearn/ensemble/tests/test_iforest.py::test_behaviour_param", "sklearn/ensemble/tests/test_iforest.py::test_deprecation", "sklearn/ensemble/tests/test_iforest.py::test_iforest", "sklearn/ensemble/tests/test_iforest.py::test_iforest_average_path_length", "sklearn/ensemble/tests/test_iforest.py::test_iforest_chunks_wo... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13554 | c903d71c5b06aa4cf518de7e3676c207519e0295 | diff --git a/sklearn/metrics/pairwise.py b/sklearn/metrics/pairwise.py
--- a/sklearn/metrics/pairwise.py
+++ b/sklearn/metrics/pairwise.py
@@ -193,6 +193,7 @@ def euclidean_distances(X, Y=None, Y_norm_squared=None, squared=False,
Y_norm_squared : array-like, shape (n_samples_2, ), optional
Pre-computed do... | diff --git a/sklearn/metrics/tests/test_pairwise.py b/sklearn/metrics/tests/test_pairwise.py
--- a/sklearn/metrics/tests/test_pairwise.py
+++ b/sklearn/metrics/tests/test_pairwise.py
@@ -584,41 +584,115 @@ def test_pairwise_distances_chunked():
assert_raises(StopIteration, next, gen)
-def test_euclidean_distan... | Numerical precision of euclidean_distances with float32
<!-- Instructions For Filing a Bug: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#filing-bugs -->
#### Description
I noticed that sklearn.metrics.pairwise.pairwise_distances function agrees with np.linalg.norm when using np.float64 arra... | Same results with python 3.5 :
```
Darwin-15.6.0-x86_64-i386-64bit
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
NumPy 1.11.0
SciPy 0.18.1
Scikit-Learn 0.17.1
```
It happens only with euclidean distance and can be reproduced using directly `sklearn.metrics.pair... | 2019-04-01T14:41:03Z | 0.21 | ["sklearn/metrics/tests/test_pairwise.py::test_euclidean_distances[dense-dense-float32]", "sklearn/metrics/tests/test_pairwise.py::test_euclidean_distances[dense-sparse-float32]", "sklearn/metrics/tests/test_pairwise.py::test_euclidean_distances[sparse-dense-float32]", "sklearn/metrics/tests/test_pairwise.py::test_eucl... | ["sklearn/metrics/tests/test_pairwise.py::test_check_XB_returned", "sklearn/metrics/tests/test_pairwise.py::test_check_dense_matrices", "sklearn/metrics/tests/test_pairwise.py::test_check_different_dimensions", "sklearn/metrics/tests/test_pairwise.py::test_check_invalid_dimensions", "sklearn/metrics/tests/test_pairwise... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13584 | 0e3c1879b06d839171b7d0a607d71bbb19a966a9 | diff --git a/sklearn/utils/_pprint.py b/sklearn/utils/_pprint.py
--- a/sklearn/utils/_pprint.py
+++ b/sklearn/utils/_pprint.py
@@ -95,7 +95,7 @@ def _changed_params(estimator):
init_params = signature(init_func).parameters
init_params = {name: param.default for name, param in init_params.items()}
for k, ... | diff --git a/sklearn/utils/tests/test_pprint.py b/sklearn/utils/tests/test_pprint.py
--- a/sklearn/utils/tests/test_pprint.py
+++ b/sklearn/utils/tests/test_pprint.py
@@ -4,6 +4,7 @@
import numpy as np
from sklearn.utils._pprint import _EstimatorPrettyPrinter
+from sklearn.linear_model import LogisticRegressionCV
... | bug in print_changed_only in new repr: vector values
```python
import sklearn
import numpy as np
from sklearn.linear_model import LogisticRegressionCV
sklearn.set_config(print_changed_only=True)
print(LogisticRegressionCV(Cs=np.array([0.1, 1])))
```
> ValueError: The truth value of an array with more than one element i... | null | 2019-04-05T23:09:48Z | 0.21 | ["sklearn/utils/tests/test_pprint.py::test_changed_only", "sklearn/utils/tests/test_pprint.py::test_deeply_nested", "sklearn/utils/tests/test_pprint.py::test_gridsearch", "sklearn/utils/tests/test_pprint.py::test_gridsearch_pipeline", "sklearn/utils/tests/test_pprint.py::test_n_max_elements_to_show", "sklearn/utils/tes... | ["sklearn/utils/tests/test_pprint.py::test_basic", "sklearn/utils/tests/test_pprint.py::test_builtin_prettyprinter", "sklearn/utils/tests/test_pprint.py::test_length_constraint"] | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13641 | badaa153e67ffa56fb1a413b3b7b5b8507024291 | diff --git a/sklearn/feature_extraction/text.py b/sklearn/feature_extraction/text.py
--- a/sklearn/feature_extraction/text.py
+++ b/sklearn/feature_extraction/text.py
@@ -31,6 +31,7 @@
from ..utils.validation import check_is_fitted, check_array, FLOAT_DTYPES
from ..utils import _IS_32BIT
from ..utils.fixes import _a... | diff --git a/sklearn/feature_extraction/tests/test_text.py b/sklearn/feature_extraction/tests/test_text.py
--- a/sklearn/feature_extraction/tests/test_text.py
+++ b/sklearn/feature_extraction/tests/test_text.py
@@ -29,6 +29,7 @@
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_arra... | CountVectorizer with custom analyzer ignores input argument
Example:
``` py
cv = CountVectorizer(analyzer=lambda x: x.split(), input='filename')
cv.fit(['hello world']).vocabulary_
```
Same for `input="file"`. Not sure if this should be fixed or just documented; I don't like changing the behavior of the vectorizers y... | To be sure, the current docstring says:
```
If a callable is passed it is used to extract the sequence of features
out of the raw, unprocessed input.
```
"Unprocessed" seems to mean that even `input=` is ignored, but this is not obvious.
I'll readily agree that's the wrong behaviour even with that docstring.
On 20 ... | 2019-04-14T21:20:41Z | 0.21 | ["sklearn/feature_extraction/tests/test_text.py::test_callable_analyzer_change_behavior[file-<lambda>0-CountVectorizer]", "sklearn/feature_extraction/tests/test_text.py::test_callable_analyzer_change_behavior[file-<lambda>0-HashingVectorizer]", "sklearn/feature_extraction/tests/test_text.py::test_callable_analyzer_chan... | ["sklearn/feature_extraction/tests/test_text.py::test_callable_analyzer_reraise_error[CountVectorizer]", "sklearn/feature_extraction/tests/test_text.py::test_callable_analyzer_reraise_error[HashingVectorizer]", "sklearn/feature_extraction/tests/test_text.py::test_callable_analyzer_reraise_error[TfidfVectorizer]", "skle... | 7813f7efb5b2012412888b69e73d76f2df2b50b6 |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13828 | f23e92ed4cdc5a952331e597023bd2c9922e6f9d | diff --git a/sklearn/cluster/affinity_propagation_.py b/sklearn/cluster/affinity_propagation_.py
--- a/sklearn/cluster/affinity_propagation_.py
+++ b/sklearn/cluster/affinity_propagation_.py
@@ -364,7 +364,11 @@ def fit(self, X, y=None):
y : Ignored
"""
- X = check_array(X, accept_sparse='csr... | diff --git a/sklearn/cluster/tests/test_affinity_propagation.py b/sklearn/cluster/tests/test_affinity_propagation.py
--- a/sklearn/cluster/tests/test_affinity_propagation.py
+++ b/sklearn/cluster/tests/test_affinity_propagation.py
@@ -63,7 +63,8 @@ def test_affinity_propagation():
assert_raises(ValueError, affinit... | sklearn.cluster.AffinityPropagation doesn't support sparse affinity matrix
<!--
If your issue is a usage question, submit it here instead:
- StackOverflow with the scikit-learn tag: https://stackoverflow.com/questions/tagged/scikit-learn
- Mailing List: https://mail.python.org/mailman/listinfo/scikit-learn
For more inf... | Yes, it should be providing a better error message. A pull request doing so
is welcome.
I don't know affinity propagation well enough to comment on whether we
should support a sparse graph as we do with dbscan.. This is applicable
only when a sample's nearest neighbours are all that is required to cluster
the sample.
... | 2019-05-08T10:22:32Z | 0.22 | ["sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation"] | ["sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation_convergence_warning_dense_sparse[centers0]", "sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_propagation_convergence_warning_dense_sparse[centers1]", "sklearn/cluster/tests/test_affinity_propagation.py::test_affinity_prop... | 7e85a6d1f038bbb932b36f18d75df6be937ed00d |
scikit-learn/scikit-learn | scikit-learn__scikit-learn-13910 | eb93420e875ba14673157be7df305eb1fac7adce | diff --git a/sklearn/metrics/pairwise.py b/sklearn/metrics/pairwise.py
--- a/sklearn/metrics/pairwise.py
+++ b/sklearn/metrics/pairwise.py
@@ -283,7 +283,7 @@ def euclidean_distances(X, Y=None, Y_norm_squared=None, squared=False,
return distances if squared else np.sqrt(distances, out=distances)
-def _euclidea... | diff --git a/sklearn/metrics/tests/test_pairwise.py b/sklearn/metrics/tests/test_pairwise.py
--- a/sklearn/metrics/tests/test_pairwise.py
+++ b/sklearn/metrics/tests/test_pairwise.py
@@ -48,6 +48,7 @@
from sklearn.metrics.pairwise import paired_distances
from sklearn.metrics.pairwise import paired_euclidean_distances... | Untreated overflow (?) for float32 in euclidean_distances new in sklearn 21.1
#### Description
I am using euclidean distances in a project and after updating, the result is wrong for just one of several datasets. When comparing it to scipy.spatial.distance.cdist one can see that in version 21.1 it behaves substantially... | So it is because of the dtype, so it is probably some overflow.
It does not give any warning or error though, and this did not happen before.
[float32.pdf](https://github.com/scikit-learn/scikit-learn/files/3194307/float32.pdf)
```python
from sklearn.metrics.pairwise import euclidean_distances
import sklearn
from s... | 2019-05-20T08:47:11Z | 0.22 | ["sklearn/metrics/tests/test_pairwise.py::test_euclidean_distances_upcast[dense-dense-101]", "sklearn/metrics/tests/test_pairwise.py::test_euclidean_distances_upcast[dense-dense-5]", "sklearn/metrics/tests/test_pairwise.py::test_euclidean_distances_upcast[dense-dense-7]", "sklearn/metrics/tests/test_pairwise.py::test_e... | ["sklearn/metrics/tests/test_pairwise.py::test_check_XB_returned", "sklearn/metrics/tests/test_pairwise.py::test_check_dense_matrices", "sklearn/metrics/tests/test_pairwise.py::test_check_different_dimensions", "sklearn/metrics/tests/test_pairwise.py::test_check_invalid_dimensions", "sklearn/metrics/tests/test_pairwise... | 7e85a6d1f038bbb932b36f18d75df6be937ed00d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.