Comments (5)
In short, there are not provisions for this in the top level API. However, the data structures used for the extraction preserve the indices as a hash:
Lines 224 to 232 in 32602e7
The key would be to modify this function here:
Lines 242 to 264 in 32602e7
The ind
parameter, I believe is exactly what you would want. You can just push that to the array as a tuple or whatever is suitable.
It should be possible to add as a feature here. Unfortunately I am quite busy with other projects so I cannot do it myself. I am happy to advise where I can and review any PRs. Though we should probably create a non-API breaking way to do this. There is an example of adding a new algorithm in #56 that is non-breaking (though that algorithm is broke, I think, it has been a while :).
from contour.jl.
Thank you for the detailed response! Is it reasonable to modify ContourLevel{T}
to add another field indices
, i.e.
struct ContourLevel{T}
level::T
lines::Vector{Curve2{T}}
indices::Vector{Int64}
end
with a function
indices(cl::ContourLevel) = cl.indices
To mimic how lines
works? Or is this considered breaking? I'll have some time to work on this over the weekend so hopefully I can come up with something that doesn't break the API, it seems straightforward enough I hope.
P.S. I'm very new to collaborating with other people on stuff so bear with me.
from contour.jl.
I would consider modifying ContourLevel
to be breaking (this is user facing). We could add a new ContourLevelIndexed
with what you proposed. However since chase!
is internal we can modify that with extra parameters to track if we want to push the indices or not.
from contour.jl.
Sorry for the trivial questions but this is a learning moment for me. Why is adding a field to a user facing structure considered breaking? I can understand renaming or removing fields of course, but what's wrong with adding fields?
As for chase!
, are you suggesting we modify the definition of chase from
Line 242 in 32602e7
to add two new parameters
function chase!(cells, curve, x, y, z, h, start, entry_edge, xi_range, yi_range, save_ind, ind_arr, ::Type{VT}) where VT
where save_ind
is a boolean flag and ind_arr
is an array to store the indices. Then we can simply modify this part:
Line 257 in 32602e7
to something like
ind, entry_edge = advance_edge(ind, exit_edge)
if save_ind
push!(ind_arr, ind)
end
Is this what you're suggesting? I'm not sure how to make ind_arr
user accessible, and defining a second type, ContourLevelIndexed
seems cumbersome.
I don't have access to a computer with Julia at the moment but I'll try to play around with this as soon as I do. I'm just stuck theory crafting till then.
from contour.jl.
I appreciate the questions, so no worries. Adding a field may seem non-breaking in the Julia ecosystem. There may be macros or memory assumptions about the layout of data that may make it breaking. Similarly we are going to use more memory in this approach and the algo will likely be slower, so it is a good idea to keep it as a different algorithm. This is me being over conservative to avoid any regressions or upstream issues.
The approach seems about right. If we setup a different type assuming the entry point will be something like contour(x,y,x,ContourIndexed())
. We can duck type and save_ind
is not needed. E.g. check the type of ind_arr
if it is not Nothing
means we can save. This means that branch should be elided for the default algorithm during compilation.
I may have some time next weekend to work on this. Also feel free to ping me on the Julia slack if you are there.
from contour.jl.
Related Issues (20)
- Upgrade error HOT 5
- Broken on Julia 0.4 HOT 5
- Ambiguity warnings on 0.4
- Broken on 0.4 master HOT 5
- Build contours from irregular and unsorted data HOT 1
- Contour not finding all branches of multi-branch contours HOT 2
- Provide a type-agnostic API and document it HOT 10
- Disable CI builds on OSX?
- Help wanted! HOT 6
- Error tagging new release
- accept non-float z
- Performance Improvements and New Algorithms HOT 3
- display() error HOT 1
- Tests depend on hasing algorithm in Base HOT 2
- TagBot trigger issue HOT 15
- Contour line from specific point HOT 2
- v0.6.0 Documentation Updates
- `contour` fails on arrays of integers HOT 2
- Contours of discntinuous data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contour.jl.