dwavesystems / dwavesystems/dwave-optimization

Support scalar indices and values in `put()`

Open
#513 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
31
Forks
36
Avg merge
16h 55m
Merged PRs (30d)
8

Description

**Current Problem**
When using the mathematical function `put()` with a scalar index, a `.resize()` is required, like this:

```
modified_array = put(old_array, index.resize(1), new_value.resize(1))
```

**Proposed Solution**
It would be nice if scalar values were accepted for the `indices` and `values` arguments.

**Alternatives Considered**
If it's too hard or costs too much performance, documenting this case in the API reference would be helpful.

**Additional context**
Numpy does accept scalars in the corresponding function:
```
arr = np.arange(5)
np.put(arr, 0, 5)
print(arr)
# Outputs [5 1 2 3 4]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.