home / github / commits

Menu
  • GraphQL API
  • Search all tables

commits: 52ee95f8ae6b9631ac381b5b889de47e41f2440e

This data as json

sha message author_date committer_date raw_author raw_committer repo author committer
52ee95f8ae6b9631ac381b5b889de47e41f2440e Add broadcast function to the API This is a renaming and update of the existing `xray.broadcast_arrays` function, which now works properly in the light of GH648. Examples -------- Broadcast two data arrays against one another to fill out their dimensions: >>> a = xray.DataArray([1, 2, 3], dims='x') >>> b = xray.DataArray([5, 6], dims='y') >>> a <xray.DataArray (x: 3)> array([1, 2, 3]) Coordinates: * x (x) int64 0 1 2 >>> b <xray.DataArray (y: 2)> array([5, 6]) Coordinates: * y (y) int64 0 1 >>> a2, b2 = xray.broadcast(a, b) >>> a2 <xray.DataArray (x: 3, y: 2)> array([[1, 1], [2, 2], [3, 3]]) Coordinates: * x (x) int64 0 1 2 * y (y) int64 0 1 >>> b2 <xray.DataArray (x: 3, y: 2)> array([[5, 6], [5, 6], [5, 6]]) Coordinates: * y (y) int64 0 1 * x (x) int64 0 1 2 Fill out the dimensions of all data variables in a dataset: >>> ds = xray.Dataset({'a': a, 'b': b}) >>> ds2, = xray.broadcast(ds) # use tuple unpacking to extract one dataset >>> ds2 <xray.Dataset> Dimensions: (x: 3, y: 2) Coordinates: * x (x) int64 0 1 2 * y (y) int64 0 1 Data variables: a (x, y) int64 1 1 2 2 3 3 b (x, y) int64 5 6 5 6 5 6 2016-01-01T21:38:11Z 2016-01-01T21:38:11Z 7ac163783245dbec82e06aac57b56992d3cf2b72 7ac163783245dbec82e06aac57b56992d3cf2b72 13221727 1217238 1217238
Powered by Datasette · Queries took 0.802ms · About: xarray-datasette