python
Came across this in a machine learning lib, trying to find out how particular recall and precision scores were calculated - made me laugh: `if x != 4: x = 4`
There was also a ` some_dict[key] if key in some_dict else default_value` , instead of ` some_dict.get(key, default_value)` , but I let that one slide.
No, there was a conditional check, but I wanted to keep it minimal. It also used a logger. Sorry for the confusion. (also, the more logic I include, the easier it is to deduce the author)
Maybe the author can’t guarantee the integrity of that list in future iterations and codes a redundant piece of logic, but it does ensure that candidate will be a part of that set no matter what.
Note that seemed fair this morning, particularly since this is a popular library and the author(s) might be on here as well: I really like the lib, it's fantastic. This just made me laugh.
146
u/tjf314 Apr 12 '22
eh this is average for code written by data scientists
21
u/Schreibtisch69 Apr 13 '22
ACHTUNG
3
u/MrHyderion Apr 13 '22
I find it interesting that the warning is always printed...
3
u/deceze Apr 13 '22
If only there was a data structure that could automagically deduplicate values… Oh well, maybe in the next version.
75
u/[deleted] Apr 12 '22
Maybe the author can’t guarantee the integrity of that list in future iterations and codes a redundant piece of logic, but it does ensure that candidate will be a part of that set no matter what.
Trying to understand why
19
u/ShadowArcher21 wicked Apr 12 '22
German ingenuity at it's peak
8
u/Masterpommel Apr 13 '22
A C H T U N G !
14
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Apr 12 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/prhbrt Apr 13 '22
Note that seemed fair this morning, particularly since this is a popular library and the author(s) might be on here as well: I really like the lib, it's fantastic. This just made me laugh.
1
u/christian-mann Apr 13 '22
Might have had some other code in that block originally, such as a log statement.
1
u/gngmntl Apr 16 '22
ACHTUNG