html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/2377#issuecomment-415074188,https://api.github.com/repos/pydata/xarray/issues/2377,415074188,MDEyOklzc3VlQ29tbWVudDQxNTA3NDE4OA==,1217238,2018-08-22T15:29:38Z,2018-08-22T15:29:38Z,MEMBER,"An simpler example: ```python-traceback In [7]: xarray.DataArray(numpy.ma.masked) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in () ----> 1 xarray.DataArray(numpy.ma.masked) ~/dev/xarray/xarray/core/dataarray.py in __init__(self, data, coords, dims, name, attrs, encoding, fastpath) 224 encoding = getattr(data, 'encoding', None) 225 --> 226 data = as_compatible_data(data) 227 coords, dims = _infer_coords_and_dims(data.shape, coords, dims) 228 variable = Variable(dims, data, attrs, encoding, fastpath=True) ~/dev/xarray/xarray/core/variable.py in as_compatible_data(data, fastpath) 180 dtype, fill_value = dtypes.maybe_promote(data.dtype) 181 data = np.asarray(data, dtype=dtype) --> 182 data[mask] = fill_value 183 else: 184 data = np.asarray(data) ValueError: assignment destination is read-only ``` I think we could fix this by using `xarray.core.duck_array_ops.where_method(data, ~mask)` in `as_compatible_data()`, which should handle scalars properly.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,352999600