Proof of concept for a powerful bh107 module#622
Proof of concept for a powerful bh107 module#622dionhaefner wants to merge 2 commits intobh107:masterfrom
Conversation
|
To-do:
This list of functions should be about everything we can reasonably support. Bohrium is a high-performance tool, so I don't really see a place for (1) stuff that is notoriously hard to parallelize (full sorts), (2) IO tools (loadtxt and friends), (3) advanced index tricks (unary where, einsum, argpartition, indices), or is (4) just too fringe (pad, piecewise, heaviside, packbits, date stuff). This is not to say that all of these features need to be part of this PR, just brainstorming on my side. |
|
👋 @madsbk, do you have an opinion on methods on >>> a = bh107.array([1, 2, 3])
>>> a.sum()
6As I see it, they often make for a slick interface without the need to even import the module where the array comes from. However, I see some problems with that:
I see three different ways forward:
I quite like 1, but happy to hear your input. |
|
Agree, I also like option 1 the best. |
The idea is that there should be 2 modes of using
bh107:1. Implicitly through NumPy
(via
__array_function__,__array_ufunc__,__array_interface__, requires recent NumPy)Example usage:
The behavior of some of the more problematic implicit conversions could be controlled by an environment variable:
Other possible values for
BH107_ON_NUMPY_CONVERSIONwould then beignoreandraise.2. Explicitly
Guaranteed to have no NumPy interactions, but is restricted to the functions we implement.
Examples:
(best used with
BH107_ON_NUMPY_CONVERSION=raise).What is the gain compared to
bohrium?bh107.BhArraydoes not subclassnp.ndarray, so it cannot be passed to C APIs without explicit conversion to NumPy, so no more corruption (fingers crossed)dir(bh107)Happy for any comments / API suggestions.