Skip to content

Commit

Permalink
Fix slow object arrays indexing (#1122)
Browse files Browse the repository at this point in the history
* fixing #1121

* added changelog
  • Loading branch information
burnpanck authored and shoyer committed Nov 15, 2016
1 parent 0c5fa1e commit 565c9a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ Bug fixes
(:issue:`1116`).
By `Yves Delley <https://github.com/burnpanck>`_.

- Fixed sub-optimal performance in certain operations with object arrays (:issue:`1121`).
By `Yves Delley <https://github.com/burnpanck>`_.

.. _whats-new.0.8.2:

v0.8.2 (18 August 2016)
Expand Down
5 changes: 2 additions & 3 deletions xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ def is_valid_numpy_dtype(dtype):

def to_0d_object_array(value):
"""Given a value, wrap it in a 0-D numpy.ndarray with dtype=object."""
result = np.empty((1,), dtype=object)
result[:] = [value]
result.shape = ()
result = np.empty((), dtype=object)
result[()] = value
return result


Expand Down

0 comments on commit 565c9a3

Please sign in to comment.