- Notifications
You must be signed in to change notification settings - Fork42
Fix overlapping crossbars#87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
pedroilidio commentedApr 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Some further details about the solution. The goal of the function is to plot in different levels the crossbars that intersect with each other. The problem was caused by how we were calculating the intersections between crossbars (merely saying that they intersect if they have a point in common):
Now, the function considers that two crossbars intersectif their intervals between their minimum and maximum ranks intersect (the ranks are the positions ploted in the x axis). The line below evaluates if two crossbarsdo not intersect:
Furthermore, I replaced the iterative algorithm to find the crossbar levels: scikit-posthocs/scikit_posthocs/_plotting.py Lines 531 to 543 in98665e2
The function now generates a crossbar-crossbar adjacency matrix called scikit-posthocs/scikit_posthocs/_plotting.py Lines 544 to 545 indb276c7
Given Edits: Adjust lines displayed. |
maximtrp commentedApr 16, 2025
Thank you! I'm gonna review all the related code in your pull request and this package |
pedroilidio commentedApr 17, 2025
Wait, I've found two other bugs in this implementation. I'll check if they are also in the master branch, open issues if they do, and add the fixes to this PR. Bug 1: Crossbars are repeated importnumpyasnpimportmatplotlib.pyplotaspltfrompandasimportDataFrame,Seriesfromscikit_posthocsimportcritical_difference_diagramn=10rng=np.random.default_rng(0)rank_values=rng.uniform(size=n)index=np.arange(n).astype(str)ranks=Series(rank_values,index=index)sig_array=np.zeros((n,n),dtype=bool)values=rng.integers(0,2,size=(n* (n-1))//2,dtype=bool)triu=np.triu_indices(n,k=1)sig_array[triu]=sig_array.T[triu]=valuessig_matrix=DataFrame(sig_array,index=index,columns=index)output=critical_difference_diagram(ranks,sig_matrix,crossbar_props={"marker":"s","linestyle":":","alpha":.5})plt.savefig("test.png") |
maximtrp commentedApr 17, 2025
@pedroilidio Yeah, thank you! I was about to write that we need as many tests as possible. Can this functionality be covered by them more carefully? |
pedroilidio commentedApr 17, 2025
Indeed,@maximtrp, I'll add as many tests for the CDDs as I can :) |
pedroilidio commentedApr 17, 2025
I apologize, I was quite wronghere:
The maximal cliques approach does not ensure different crossbars at each level. This is more complicated: it's a graph coloring problem in the complement graph of the crossbar graph ( I'll revert back to the greedy approach we were using. Another (maybe overkill) option: I could adapt the implementation ofNetworkX's approach in a separate module, avoiding to add NetworkX as a new dependency. I could do the same for the maximal cliques function I needed to implement for the CDDs. |
Pointed out here:maximtrp#87 (comment)And also inmaximtrp#89.
pedroilidio commentedApr 17, 2025
It looks better now, but it suspiciously changed from my previous figure (pairs of points are gone). I will write several tests in a further commit. importnumpyasnpimportmatplotlib.pyplotaspltfrompandasimportDataFrame,Seriesfromscikit_posthocsimportcritical_difference_diagramn=10rng=np.random.default_rng(0)rank_values=rng.uniform(size=n)index=np.arange(n).astype(str)ranks=Series(rank_values,index=index)triu=np.triu_indices(n,k=1)values=rng.integers(0,2,size=len(triu[0]),dtype=np.int8)sig_array=np.ones((n,n),dtype=np.int8)sig_array[triu]=sig_array.T[triu]=valuessig_matrix=DataFrame(sig_array,index=index,columns=index)plt.figure(figsize=(5,3))output=critical_difference_diagram(ranks,sig_matrix,crossbar_props={"marker":"s","linestyle":":","alpha":.3})plt.tight_layout()plt.savefig("fixed.png") |
maximtrp commentedApr 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thank you once again! Now not all tests are passed 👇 |
pedroilidio commentedApr 18, 2025
Thanks for following this thread,@maximtrp! I'll be busier for some days, so I'll get back to working on this at the end of the next week. For now I'll convert the PR to a draft PR until it's ready for merging. Next steps are:
|


Three main points are relevant in this PR:
ItfixesCrossbars can overlap in Critical Difference Diagrams #86.
I also modified the
sign_arrayfunction, since I was again running into#82. The modification dispenses the epsilon added byUpdate _plotting.py #81 and discussed in#82. Please let me know if this is incorrect. I made sure the copy problem pointed out by#77 remains solved.To ensure these problems do not come up in the future I added unit tests based on#86 and#82.