shashi / FileTrees.jl

Parallel computing with a tree of files metaphor
http://shashi.biz/FileTrees.jl
Other
88 stars 6 forks source link

mapmatches #36

Open ym-han opened 3 years ago

ym-han commented 3 years ago

The docs at http://shashi.biz/FileTrees.jl/patterns/ mention the function mapmatches, but that doesn't actually seem to be available. But I could be missing something really simple.

DrChainsaw commented 3 years ago

Can't find it either.

@sashi, should it be in there? From the description it seems a bit similar to mapsubtrees but I can't tell for sure if it should do the same thing.

sashi commented 3 years ago

@DrChainsaw wrong sashi, was it supposed to be for @shashi ?

DrChainsaw commented 3 years ago

Uups, forgot that there are more than three people using this platform :)

singularitti commented 1 year ago

Any updates?

DrChainsaw commented 1 year ago

Did mapsubtrees(f, t, p) or mapvalues(f, t[p]) work for you?

Unfortunately I don't have access to the docsite so I won't be able to push updates to it. This should maybe be fixed in the long run. It has been less of an issue than it might seem since the package has a pretty stable API.

shashi commented 1 year ago

How do I give you access to the docsite? I thought it's just a branch here?

singularitti commented 1 year ago

Did mapsubtrees(f, t, p) or mapvalues(f, t[p]) work for you?

I am sorry, but as far as I understand, mapsubtrees returns FileTrees, right? What I need is "applying f to every match". And mapmatches seems to accept more types. I currently cannot run mapsubtrees since the example in the doc is not a valid Julia example:

t = maketree("dir"=>([string(j)=>[(name=string(i), value=(i,j)]
                        for i=1:2] for j=1:3]

t1 = mapsubtrees("*") do subtree
    reducevalues(vcat, subtree)
end
DrChainsaw commented 1 year ago

@shashi : Not sure either what is needed. Whenever I push the doc job fails. Unfortunately the logs have expired but I'm pretty certain it is some kind of "unauthenticated" failure. Perhaps it is just some secret that needs to be configured.

Currently the docs seem to be hosted in some domain which has your name in it (http://shashi.biz/). Perhaps things will just work if I point to the github pages. Let me know if this is ok with you.

@singularitti

I am sorry, but as far as I understand, mapsubtrees returns FileTrees, right?

Yes, all map functions return a FileTree.

What I need is "applying f to every match".

This is exactly what the map-functions do. You need to select the appropriate map function depending on what you want f to have as input:

Both map and mapvalues work on the entire tree they are given, so there is no need for them to have a pattern argument. Just apply it to the tree before providing it (e.g. mapvalues(f, mytree[r"somepattern"]))).

the example in the doc is not a valid Julia example

Uuups! This needs to be fixed of course.

Here is a valid example in the meantime:

julia> t = maketree("dir"=>([string(j)=>[(name=string(i), value=(i,j))  for i=1:2] for j=1:3]))
dir/
├─ 1/
│  ├─ 1 (Tuple{Int64, Int64})
│  └─ 2 (Tuple{Int64, Int64})
├─ 2/
│  ├─ 1 (Tuple{Int64, Int64})
│  └─ 2 (Tuple{Int64, Int64})
└─ 3/
   ├─ 1 (Tuple{Int64, Int64})
   └─ 2 (Tuple{Int64, Int64})

julia> mapsubtrees(t, r"[1,3]") do st
       reducevalues(vcat, st)
       end
dir/
├─ 1/ (2-element Vector{Tuple{Int64, Int64}})
├─ 2/
│  ├─ 1 (Tuple{Int64, Int64})
│  └─ 2 (Tuple{Int64, Int64})
└─ 3/ (2-element Vector{Tuple{Int64, Int64}})
shashi commented 1 year ago

Currently the docs seem to be hosted in some domain which has your name in it (http://shashi.biz/).

that's just because shashi.github.io is aliased to shashi.biz... It would be possible to serve it on a different domain though.

shashi commented 1 year ago

I think the way Franklin works has changed. Need to update the github action.