issue_comments: 549084085
This data as json
| 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/pull/3262#issuecomment-549084085 | https://api.github.com/repos/pydata/xarray/issues/3262 | 549084085 | MDEyOklzc3VlQ29tbWVudDU0OTA4NDA4NQ== | 1217238 | 2019-11-02T21:46:32Z | 2019-11-02T21:46:32Z | MEMBER | One missing part of the algorithm I wrote in https://github.com/pydata/xarray/pull/3262#issuecomment-525154116 was looping over all index/weight combinations. I recently wrote a version of this for another project that might be a good starting point here: ```python def prod(items): out = 1 for item in items: out *= item return out def index_by_linear_interpolation(array, float_indices): all_indices_and_weights = [] for origin in float_indices: lower = np.floor(origin) upper = np.ceil(origin) l_index = xlower.astype(np.int32) u_index = upper.astype(np.int32) l_weight = origin - lower u_weight = 1 - l_weight all_indices_and_weights.append( ((l_index, l_weight), (u_index, u_weight)) ) out = 0 for items in itertools.product(all_indices_and_weights): indices, weights = zip(items) indices = tuple(index % size for index, size in zip(indices, array.shape)) out += prod(weights) * array[indices] return out ``` |
{
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
} |
484863660 |