Skip to content

Some bug fixing in code#1

Open
CodingTumbleweed wants to merge 6 commits into
GuipengLi:masterfrom
CodingTumbleweed:master
Open

Some bug fixing in code#1
CodingTumbleweed wants to merge 6 commits into
GuipengLi:masterfrom
CodingTumbleweed:master

Conversation

@CodingTumbleweed
Copy link
Copy Markdown

Hi Guipeng Li, while running your code, I encountered some bugs in code about array indices being decimal or negative values and fixed them. Below I have mentioned the Bugs encountered (in bold) and the reason for why they are being generated:

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

This one is being generated because numpy.zeros() function, by default, returns floating point array instead of integer array and when its value gets passed as an index, exception is thrown e.g. In bord_rho[cl[i]] 'cl[i]' is an floating point value which is getting passed as an index to bord_rho array

index -1 is out of bounds for axis 0 with size 0

This gets generated when user clicks out of 1st sub-plot and cl array, initialized as np.zeros(ND)-1 is not changed as no clusters are assigned. Later on, when generating scatter plot on 3rd sub-plot, cmap[list(cl)] is called which result in above exception

Data points are invisible

When scatter plot is being generated with white colormap for data points i.e. scatter(rho, delta, alpha=0.6,c='white'), data points become invisible on white background

I have fixed these issues in my branch and was hoping that you could merge these changes into main branch.

Regards

…white data points on white background are not showing up
…clusters are assigned resulting in 'cl' array being full of -1 values which later cause an error on runtime.
@JackLiar
Copy link
Copy Markdown

Hello @CodingTumbleweed , I tried both Li's and yours code on windows 7 x64 Anaconda 5.1.0 Python3.6, and after it goes to dcplot.py, line 111: nID = input(),the whole python kernel just crushed. But on a Ubuntu codes get nothing wrong.

What reason do you think that might cause this?

@CodingTumbleweed
Copy link
Copy Markdown
Author

@Jackwzh . Hi Jack , Is the plot window not responding or does it crashes before even opening the plot window?

@JackLiar
Copy link
Copy Markdown

JackLiar commented Mar 13, 2018

not responding, but none of the three subfigures shows on the canvas

…number, which results in sda[position] throwing IndexError: : only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
@CodingTumbleweed
Copy link
Copy Markdown
Author

CodingTumbleweed commented Mar 14, 2018

@Jackwzh . Have you tried changing the default matplotlib Gui backend? I think it's Qt5 in your environment. It can be checked with %matplotlib command. Try running the code with TkAgg Backend i.e.

%matplotlib tk
import Dcluster as dcl
filein="test.dat"
dcl.run(fi=filein, sep='\t')

@JackLiar
Copy link
Copy Markdown

JackLiar commented Mar 15, 2018

@CodingTumbleweed It's the nID = input() code causes this problem.

On Windows, if user do not give any input from the console, the figure won't plot anything and keep in not responding situation.

After user inputs something from the console, figures will show on the canvas and everything goes well.

But there is another problem.

The while loop keeps asking inputs from console, so unless user input 'n', it will keep going in that way, and the figures will never show on the canvas.

… only after it's provided will canvas show final plotted result. Removed the while loop and 'nID = input()' code and replaced it's functionality by providing 'Save' button on plot
@CodingTumbleweed
Copy link
Copy Markdown
Author

@Jackwzh Thanks for pointing out the complete scenario. nID = input() along with while loop was indeed causing problem. I have fixed it and replaced user input functionality by providing Save button on plot.

@luisencalada
Copy link
Copy Markdown

Hello all! @Jackwzh I still have no data displayed on the figure? I already replaced the code as you mentioned. Do I need to do anythong else? Thanks in advance!!

@JackLiar
Copy link
Copy Markdown

JackLiar commented Jun 4, 2018

@luisencalada you can try CodingTumbleweed 's repo, I believe this repo has solved most of the problems I've ever met.

Without viewing your codes, I guess the cause of your problem might be the color of the scatter points is set to white, probably? If not so, you should post your codes or try the repo I mentioned above.

:)

Added Branch Author Name and Email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants