File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ Deprecations
45
45
46
46
Bug fixes
47
47
~~~~~~~~~
48
+
49
+ - Improve error message when using in :py:meth: `Dataset.drop_vars ` to state which variables can't be dropped. (:pull: `7518 `)
50
+ By `Tom Nicholas <https://github.com/TomNicholas >`_.
48
51
- Require to explicitly defining optional dimensions such as hue
49
52
and markersize for scatter plots. (:issue: `7314 `, :pull: `7277 `).
50
53
By `Jimmy Westling <https://github.com/illviljan >`_.
Original file line number Diff line number Diff line change @@ -5051,9 +5051,9 @@ def _assert_all_in_dataset(
5051
5051
if virtual_okay :
5052
5052
bad_names -= self .virtual_variables
5053
5053
if bad_names :
5054
+ ordered_bad_names = [name for name in names if name in bad_names ]
5054
5055
raise ValueError (
5055
- "One or more of the specified variables "
5056
- "cannot be found in this dataset"
5056
+ f"These variables cannot be found in this dataset: { ordered_bad_names } "
5057
5057
)
5058
5058
5059
5059
def drop_vars (
Original file line number Diff line number Diff line change @@ -2503,7 +2503,12 @@ def test_drop_variables(self) -> None:
2503
2503
actual = data .drop_vars (["time" ])
2504
2504
assert_identical (expected , actual )
2505
2505
2506
- with pytest .raises (ValueError , match = r"cannot be found" ):
2506
+ with pytest .raises (
2507
+ ValueError ,
2508
+ match = re .escape (
2509
+ "These variables cannot be found in this dataset: ['not_found_here']"
2510
+ ),
2511
+ ):
2507
2512
data .drop_vars ("not_found_here" )
2508
2513
2509
2514
actual = data .drop_vars ("not_found_here" , errors = "ignore" )
You can’t perform that action at this time.
0 commit comments