Description
I have noticed that there has been a lot discussion about null of none value in toml, i.e. #30 #802 , but I have a question in my case.
In my case, users will set parameters to crop an image (top, bottom, left, right). If they don't want to crop that side, it seems that setting it to None is the best choice. To simplify the example, I will use a 1D image to illustrate it.
>>> import numpy as np
>>> a = np.arange(10) # 1D image
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a[1:] # Only crop the left by one pixel, do not crop the right side
array([1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a[1:None] # None can be the paramter
array([1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a[1:0] # Cannot use 0
array([], dtype=int32)
>>> a[1:-1] # Cannot use -1, because the last element is lost
array([1, 2, 3, 4, 5, 6, 7, 8])
>>> a[1:np.inf] # Cannot use inf, since it is not an integer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__ method
In the above case, if we can have a toml such as
[config]
crop = [1, none]
it will allow users easily to set no crop for the right side of image. 0, -1, and inf does not work for this case. Value 10
works for this case, but that means users have to know the image size which may be different every time. This is not convenient.
If none
is not allowed in toml, is there a good way to solve my question? Appreciated.