You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before I start a fork/pull request, I just wanted to see interest in this idea,
We can index a 2d array with ints, or use the parse_range on a string. Can we allow this to be done automatically if i1 is a string?
function array2d.default_range (t,i1,j1,i2,j2)
-- my patch
if (type(i1) == 'string') and not (j1 or i2 or j2) then
i1, j1, i2, j2 = array2d.parse_range(i1)
end
--
local nr, nc = array2d.size(t)
i1 = norm_value(i1 or 1, nr)
j1 = norm_value(j1 or 1, nc)
i2 = norm_value(i2 or nr, nr)
j2 = norm_value(j2 or nc, nc)
return i1,j1,i2,j2
end
Additionally, I would like to add another flavor of string indexing: numpy-like indexing. I have the method worked out and would like to implement it. Currently, I cannot patch the array2d.default_range (after loading penlight that is, without modifying the source code) because the usage of default_range uses the local function default_range.. which begs the question, why does array2d.default_range exist then? I propose that we remove the local default_range and instead use the module function array2d.default_range for all uses.
The text was updated successfully, but these errors were encountered:
Before I start a fork/pull request, I just wanted to see interest in this idea,
We can index a 2d array with ints, or use the parse_range on a string. Can we allow this to be done automatically if i1 is a string?
Additionally, I would like to add another flavor of string indexing: numpy-like indexing. I have the method worked out and would like to implement it. Currently, I cannot patch the
array2d.default_range
(after loading penlight that is, without modifying the source code) because the usage ofdefault_range
uses the local functiondefault_range
.. which begs the question, why doesarray2d.default_range
exist then? I propose that we remove the localdefault_range
and instead use the module functionarray2d.default_range
for all uses.The text was updated successfully, but these errors were encountered: