home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 472100381

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
472100381 MDExOlB1bGxSZXF1ZXN0MzAwNTc2Nzc4 3159 Initialize empty or full DataArray 23618263 closed 0     20 2019-07-24T06:21:50Z 2019-08-27T16:28:04Z 2019-08-26T20:36:36Z CONTRIBUTOR   0 pydata/xarray/pulls/3159

I attempted to implement what has been asked for in #277 as an effort to contribute to this project. This PR adds the ability to initialize a DataArray with a constant value, including np.nan. Also, if data = None then it is initialized as np.empty to take advantage of its speed for big arrays. ```python

foo = xr.DataArray(None, coords=[range(3), range(4)]) foo <xarray.DataArray (dim_0: 3, dim_1: 4)> array([[4.673257e-310, 0.000000e+000, 0.000000e+000, 0.000000e+000], [0.000000e+000, 0.000000e+000, 0.000000e+000, 0.000000e+000], [0.000000e+000, 0.000000e+000, 0.000000e+000, 0.000000e+000]]) Coordinates: * dim_0 (dim_0) int64 0 1 2 * dim_1 (dim_1) int64 0 1 2 3 ```

  • [x] Closes #878, #277
  • [x] Tests added
  • [x] Fully documented, including whats-new.rst for all changes and api.rst for new API

Regarding the tests, I am not sure how to test the creation of an empty DataArray with data=None since the values changes between calls of np.empty. This is the reason I only added the test for the constant value.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3159/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 pull

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 20 rows from issue in issue_comments
Powered by Datasette · Queries took 0.969ms · About: xarray-datasette