ZeroDivisionError: float division by zero
Closed this issue Β· 4 comments
Hi, I have this problem when I try to test JS code, for example:
$ multimetric test.js
source code
`//πππ§ππ πΈπππππππ£π πππππ« πΈππ¦ππππ - πππ§ππ.ππππππππ£π .π§ππππ«@ππ π£π£ππ π¦πππ§ππππ.πππ¦.ππ - ππππππππ π - ππππ
/*
Proposito: Esta funcion nos mostrara en consola la union de dos listas, a este proceso se le llama concataciΓ³n
Contrato: list -> list
Prototipo: concat(listaa, listab)
ejemplos: concat([],[]) -> []
concat([],[1, 2]) -> [1,2]
concat([3,5], []) -> [3,5]
*/
const {cons, first, rest, isEmpty, isList, length} = require('functional-light');
function concat(listaa,listab){
if(isEmpty(listaa)){
return listab;
}else if(isEmpty(listab)){
return listaa;
}else if(isEmpty(listaa) && isEmpty(listab)){
return [];
}else{
return cons(first(listaa),concat(rest(listaa),listab));
}
}
console.log(concat([],[]));
console.log(concat([],[1, 2]));
console.log(concat([3,5], []));
console.log(concat([1,2,true], ['FDP',3,8,2,7]));`
output:
Traceback (most recent call last):
File "/home/lstiven/Documents/multimetric/venv/bin/multimetric", line 8, in
sys.exit(main())
File "/home/lstiven/Documents/multimetric/venv/lib/python3.8/site-packages/multimetric/main.py", line 146, in main
_result["overall"].update(y.get_results_global([x[4] for x in results]))
File "/home/lstiven/Documents/multimetric/venv/lib/python3.8/site-packages/multimetric/cls/metric/comments.py", line 54, in get_results_global
MetricBaseComments.METRIC_COMMENT_RATIO: __comments * 100.0 / float(__overall)
ZeroDivisionError: float division by zero
What is the problem?
thanks for your time (sorry for my English)
The problem is that __overall
is zero in this case π - so much for the obvious... it's a bug and needs to be fixed. Will spin up a fix later that week
The problem is that
__overall
is zero in this case π - so much for the obvious... it's a bug and needs to be fixed. Will spin up a fix later that week
thanks for answering.
I noticed something and it may be relevant (I hope so), when the source code has special characteres like in the example code:
//πππ§ππ πΈπππππππ£π πππππ« πΈππ¦ππππ - πππ§ππ.ππππππππ£π .π§ππππ«@ππ π£π£ππ π¦πππ§ππππ.πππ¦.ππ - ππππππππ π - ππππ
or emojis, etc in the comments the error ocurrs. When source code is "clean"(in comments) no errors appear.
hmmm, so it might be an issue of character encoding... currently the lib does use chardet
for that, so likely all the character encoding shouldn't be the problem... anyway the issue should be fixed now
Again, thanks for answering and for your time, I am currently using your tool in a section of my degree work.