File tree 4 files changed +33
-4
lines changed
4 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,11 @@ Bug fixes
55
55
due to a ``datetime `` issue in NumPy (:issue: `2334 `).
56
56
By `Graham Inggs <https://github.com/ginggs >`_.
57
57
- Fixed bug in ``combine_by_coords() `` causing a `ValueError ` if the input had
58
- an unused dimension with coordinates which were not monotonic (:issue`3150`).
58
+ an unused dimension with coordinates which were not monotonic (:issue: `3150 `).
59
59
By `Tom Nicholas <http://github.com/TomNicholas >`_.
60
+ - Fixed crash when applying ``distributed.Client.compute() `` to a DataArray
61
+ (:issue: `3171 `). By `Guido Imperiale <https://github.com/crusaderky >`_.
62
+
60
63
61
64
.. _whats-new.0.12.3 :
62
65
Original file line number Diff line number Diff line change @@ -300,7 +300,7 @@ def _replace(
300
300
self ,
301
301
variable : Variable = None ,
302
302
coords = None ,
303
- name : Union [Hashable , None , ReprObject ] = __default ,
303
+ name : Optional [Hashable ] = __default ,
304
304
) -> 'DataArray' :
305
305
if variable is None :
306
306
variable = self .variable
@@ -313,7 +313,7 @@ def _replace(
313
313
def _replace_maybe_drop_dims (
314
314
self ,
315
315
variable : Variable ,
316
- name : Union [ str , None , utils . ReprObject ] = __default
316
+ name : Optional [ Hashable ] = __default
317
317
) -> 'DataArray' :
318
318
if variable .dims == self .dims and variable .shape == self .shape :
319
319
coords = self ._coords .copy ()
@@ -356,7 +356,7 @@ def _to_temp_dataset(self) -> Dataset:
356
356
def _from_temp_dataset (
357
357
self ,
358
358
dataset : Dataset ,
359
- name : Union [ Hashable , ReprObject ] = __default
359
+ name : Hashable = __default
360
360
) -> 'DataArray' :
361
361
variable = dataset ._variables .pop (_THIS_ARRAY )
362
362
coords = dataset ._variables
Original file line number Diff line number Diff line change @@ -462,12 +462,22 @@ def __repr__(self: Any) -> str:
462
462
class ReprObject :
463
463
"""Object that prints as the given value, for use with sentinel values.
464
464
"""
465
+ __slots__ = ('_value' , )
466
+
465
467
def __init__ (self , value : str ):
466
468
self ._value = value
467
469
468
470
def __repr__ (self ) -> str :
469
471
return self ._value
470
472
473
+ def __eq__ (self , other ) -> bool :
474
+ if isinstance (other , ReprObject ):
475
+ return self ._value == other ._value
476
+ return False
477
+
478
+ def __hash__ (self ) -> int :
479
+ return hash ((ReprObject , self ._value ))
480
+
471
481
472
482
@contextlib .contextmanager
473
483
def close_on_error (f ):
Original file line number Diff line number Diff line change 1
1
from collections import OrderedDict
2
2
from datetime import datetime
3
+ from typing import Hashable
3
4
4
5
import numpy as np
5
6
import pandas as pd
@@ -179,6 +180,21 @@ def test_sorted_keys_dict(self):
179
180
def test_repr_object ():
180
181
obj = utils .ReprObject ('foo' )
181
182
assert repr (obj ) == 'foo'
183
+ assert isinstance (obj , Hashable )
184
+ assert not isinstance (obj , str )
185
+
186
+
187
+ def test_repr_object_magic_methods ():
188
+ o1 = utils .ReprObject ('foo' )
189
+ o2 = utils .ReprObject ('foo' )
190
+ o3 = utils .ReprObject ('bar' )
191
+ o4 = 'foo'
192
+ assert o1 == o2
193
+ assert o1 != o3
194
+ assert o1 != o4
195
+ assert hash (o1 ) == hash (o2 )
196
+ assert hash (o1 ) != hash (o3 )
197
+ assert hash (o1 ) != hash (o4 )
182
198
183
199
184
200
def test_is_remote_uri ():
You can’t perform that action at this time.
0 commit comments