Currently, .view() returns two very different dtypes; "plain" dtypes / simple arrays in the case of simple storages, and structured types / View arrays in the case of accumulator storages. This makes it impossible to ducktype on the view. How about if it always returns a structured dtype? That is, a new View (SimpleView, for example) would be added:
@fields("value")
class SimpleView(View):
...
This way, if you want the histogram value, h.view().value works on simple storages too now, and therefore all storages that have the concept of value provide a .value. A single-field structured dtype is identical in memory to a simple dtype.
If you wanted to provide a simple output array of values, a .values() or .value()` method could be added to histogram (see the various cross-library protocol discussions). Or, you could require this as part of the Protocol (not as ideal for other libraries, but possible).
TLDR, values = h.view() is replaced by values = h.view().value, so now that works across all storage types.
@HDembinski, thoughts?
Currently,
.view()returns two very different dtypes; "plain" dtypes / simple arrays in the case of simple storages, and structured types / View arrays in the case of accumulator storages. This makes it impossible to ducktype on the view. How about if it always returns a structured dtype? That is, a new View (SimpleView, for example) would be added:This way, if you want the histogram value,
h.view().valueworks on simple storages too now, and therefore all storages that have the concept of value provide a.value. A single-field structured dtype is identical in memory to a simple dtype.If you wanted to provide a simple output array of values, a
.values() or.value()` method could be added to histogram (see the various cross-library protocol discussions). Or, you could require this as part of the Protocol (not as ideal for other libraries, but possible).TLDR,
values = h.view()is replaced byvalues = h.view().value, so now that works across all storage types.@HDembinski, thoughts?