list as input #13
Replies: 4 comments 2 replies
-
This is a good idea, should be possible to implement. Basically the user passes sequence-like or array-like input for value then a sequence or array with the same shape but filled with formatted strings will be returned. If the user passes in a pair of sequence-like or array-like then, if the two elements of the pair have the same shape, another sequenc/array of the same shape will be returned, again filled with formatted strings. At first I don't want to support sequences/arrays with different shapes (i.e. handling broadcasting). Some cases will be easy to implement, others (multi-dimensional numpy arrays) may or may not be easy to implement, I'll need to see. |
Beta Was this translation helpful? Give feedback.
-
A comment: I only plan to support this functionality through the A few questions:
Re 1.: My current strategy is to have
|
Beta Was this translation helpful? Give feedback.
-
@bytelinker After looking at this, I've come to the conclusion that it is a very interesting convenience feature, but it feels like I would have to make some slightly arbitrary choices for the implementation and I'm not sure if those choices are justified over having users handle the mapping over sequences/arrays themselves. Without numpy, users can map
With
In both cases, the work on the user is one or two lines. In the first example, the input could have been any iterable, but I had to make the choice to cast the generator resulting from The second example is ok since arrays are cast to arrays, but since vectorize will work over lists or tuples should we use the Again, I can see the convenience, it's just not 100% clear to how to make these choices for the end-user. Or phrased as a question: what specific list input feature would you find useful? |
Beta Was this translation helpful? Give feedback.
-
For now this discussion is resolved by #120. I've added examples to the documentation showing how I'm resistant to building something like this into For this issue I also want to emphasize that it's not clear exactly what interface would be desired for a feature that maps formatting over different collections. A function that accepts a list and returns a list would be easy to build in, but what if someone wants a function that accepts a tuple and returns a tuple? A dict and returns a dict? case-by-case examples like this could easily be built into |
Beta Was this translation helpful? Give feedback.
-
@jagerber48
Hello, data are often organised in pandas df, numy arrays and/or list.
It seems not be possible to use arrays and lists as input for the package.
sform = sciform.Formatter(precision=2, unicode_pm=True)
a_list = [1, 2, 3, 4, 5]
a_unc_list = [0.1, 0.2, 0.3, 0.4, 0.5]
result = sform(a_list, a_unc_list)
Regards
bytelinker
Beta Was this translation helpful? Give feedback.
All reactions