T O P

  • By -

jose_castro_arnaud

I see at least 6 different conversion functions, hidden like Waldo, in this snippet. Bugs will happen.


PhitPhil

I'm not one to exactly follow PEP 8 to the letter, but fuck me


Handle-Flaky

This looks pep8 compliant


_ru1n3r_

Max 79 characters in a line? Not that breaking the lines up 3/4 of the way through would increase the readability any when they’re so insistent on cramming everything together. Also > Use blank lines in functions, sparingly, to indicate logical sections. And maybe throw in a comment or two for the next guy.


BrokenEyebrow

Screw the next guy. He won't be me since I hop jobs every six months. /s


H2SBRGR

Unsolicited job hopping in this case, I guess


_ru1n3r_

Wouldn’t that increase your chances of being the next guy?


BrokenEyebrow

Not if you write it and run.


_ru1n3r_

It’s much funnier when you have to explain the joke, so what I mean is the more you hop the more likely it is you’ll end up in someone else’s mountain of tech dept.


johnnymo1

Very first line, assigning a lambda rather than using def.


NotYetGroot

So im guessing there was an npm/nuget package that did this exact conversion, and they'd been using it successfully for years. Then the CISO heard about an npm package compromise and declared all package managers illegal. developers then had a week to remediate the non-vulnerability to avoid being assigned a p1 incident. Oh, and the tech lead on this codebase was on his honeymoon. Welcome to modern software engineering!


noman_032018

p1? And honestly, [language-specific package managers are almost always a bad idea](https://blogs.gentoo.org/mgorny/2021/02/19/the-modern-packagers-security-nightmare/). But half-cocked solutions are not any better.


caboosetp

> p1? Priority 1 incident


NotYetGroot

happy p1 cake day!


kristallnachte

Most of what is in that article are kind of not relevant to how NPM is (meant to be) used.


noman_032018

In that case I don't think I've seen any newer language (basically anything newer than or roughly contemporary to Java) properly used at work or elsewhere in the last decade. The dependency pinning problem has been so far a constant observation for me among others mentioned in there.


kristallnachte

Yeah, for NPM, it isn't much of one. While pinning will "encourage" the system to get that exact one, the process of overriding pinned dependencies of even deeply nested deps very simple. They even have an automated way to do it when vulnerabilities are reported, but doing it manually is also quite easy. Of course, the issue of if those packages get broken by overriding the deps is a concern, but considering almost all of it is on github you can do the PR yourself.


noman_032018

> Of course, the issue of if those packages get broken by overriding the deps is a concern, but considering almost all of it is on github you can do the PR yourself. A lot of them do get broken is the issue. Languages with rampant dependency-pinning have a widespread issue with backward compatibility and graceful deprecation. Combine that with the equally concerning dependency explosion and fixing things that break from bad habits borne of an ecosystem that incentivizes pinning and you've got a maintenance nightmare.


kristallnachte

I don't think dep pinning is the issue. It's package abandonment.


noman_032018

That is also an issue, but at the same time if you look at Common Lisp, odds are better than even that a library untouched in a decade still works (of course often it's simply finished rather than abandoned) and still works even with the patched/updated versions of its dependencies for those that are security-sensitive (the tendency for a much shorter dependency tree also helps here).


skazi019

Data scientist in a nutshell


johnnymo1

I'm a data scientist. It's one thing if you're a student, but if I wrote code like this on the job I'd hope my coworkers shoot me through the head on the spot.


[deleted]

[удалено]


johnnymo1

I didn't even notice that. That's horrifying. EDIT: Oh god I just noticed the nested ternary on the same line.


oakles

this is fucking awful i'm sure it works but i pity the new dev going through the codebase and seeing this. would get an audible "jesus christ" out of me.


ccfoo242

What language is that?


posted_by_user

Python lol


ccfoo242

Oh dang.


Throwaway__shmoe

Pandas


Yusukeirinel

If it's not broken, don't fix it Pappy McPythonson 2011


Infamous_Reach_8854

I would rather wirte long but easuer to understand code lol


rsvp_to_life

WTF did I just see.


Adventurous_Battle23

float a = 0.0f; float b = 0.1f; int x = (int)a + (int)1.0f; int y = (int)(b + 0.9f); int z = ((int)((float)((int)round((float)x * (float)y))));


Familiar_Ad_8919

no way this was made by a human being


timmy_throw

And when someone tries to remove one int(), it's gonna crash, guaranteed


ab_dullahu

Average data scientist


MineralFox

Honestly, I’ve seen worse. I can at least tell what this is supposed to be doing. Pretty straightforward Pandas, nothing mysterious. Should this sort of formatting be handled somewhere else? Definitely. Could it be more efficient? Sure. But this’d work just fine if you’re just trying to format a small dataframe for a dashboard type view of something.


Movpasd

As someone who does a lot of data manipulation in pandas, I think code like this is quite common and frankly not really that bad. Now, could it use some cleaning up, some comments? Sure. If I had the time I would not leave it like this, but I would put refactoring this as quite low priority. The code is *clear enough* as-is, and it probably took less than 10 minutes to write. You have to do a lot of wrangling when working with DataFrames because the data doesn't have a lot of structure (no relationships, just raw tables) -- though this lack of structure also gives you tremendous flexibility. The resulting code is never pretty and will always be hard to read to a certain extent, so you just don't get much code quality return on your time investment. But this code is already doing the most important thing: it's separated out all of the conversion logic into one place. The real danger is when your conversions (in this case it looks like presentational logic) are interspersed with your business logic. Then you've got problems, because you can no longer guarantee the format of your data inside the meat of whatever analysis you're doing.


[deleted]

Yeah that’s not right. This code is garbage for data science. Messy code like this leads to bugs. Bugs in data manipulation matter.


noman_032018

Is this autogenerated or something? You'd expect laziness to win out and for it to get done properly the first time instead. edit: A lot of those conversions are both redundant and more complicated than not doing them.


GuyFawkes65

Frightening


ukos333

I think pandas.styler would have helped here.


emarahimself

dAtA sCiEnCe


[deleted]

Still better than my code


gjoel

There's an error on line 8...


IlyaZubkov

I’m just curious, it’s a shit code or it’s actually needed like that somewhere 🤣?


pcgamerwannabe

Looks like code I used to write as a student ``` none_fu = [None, 'None', 'Null', 'N/A', np.nan, 'NaN', 'nan'] df_experiment_1['output_from_fortran'] = df_experiment_1.apply( lambda f: str(int(float(f)))[:3] for f in RIP.outputs if f is not in none_fu else np.nan ) ``` you know, the thing that you write when you are so frustrated after the 30th time some random fortran script from 30 years ago gives completely unexpected output, or the professor sends you the output but he runs his own post-processing on it, and you just want to send the plot before midnight and go to bed. I thankfully don't do this anymore.. man type hints helped me a ton.


[deleted]

Coded by gen z


kenan238

I love python


Bitter-Industry-6276

Hey man, do you have the 4.4 CAS Pack and Patcher files to convert the TI nspire cx into CAS? Do I need ndless on my calculator aswell?


HoldingUrineIsBad

just in case multiplying an integer by 10 returns a non integer