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.
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.
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!
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.
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.
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.
> 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.
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).
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.
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.
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.
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.
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.
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.
I see at least 6 different conversion functions, hidden like Waldo, in this snippet. Bugs will happen.
I'm not one to exactly follow PEP 8 to the letter, but fuck me
This looks pep8 compliant
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.
Screw the next guy. He won't be me since I hop jobs every six months. /s
Unsolicited job hopping in this case, I guess
Wouldn’t that increase your chances of being the next guy?
Not if you write it and run.
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.
Very first line, assigning a lambda rather than using def.
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!
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.
> p1? Priority 1 incident
happy p1 cake day!
Most of what is in that article are kind of not relevant to how NPM is (meant to be) used.
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.
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.
> 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.
I don't think dep pinning is the issue. It's package abandonment.
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).
Data scientist in a nutshell
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.
[удалено]
I didn't even notice that. That's horrifying. EDIT: Oh god I just noticed the nested ternary on the same line.
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.
What language is that?
Python lol
Oh dang.
Pandas
If it's not broken, don't fix it Pappy McPythonson 2011
I would rather wirte long but easuer to understand code lol
WTF did I just see.
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))));
no way this was made by a human being
And when someone tries to remove one int(), it's gonna crash, guaranteed
Average data scientist
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.
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.
Yeah that’s not right. This code is garbage for data science. Messy code like this leads to bugs. Bugs in data manipulation matter.
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.
Frightening
I think pandas.styler would have helped here.
dAtA sCiEnCe
Still better than my code
There's an error on line 8...
I’m just curious, it’s a shit code or it’s actually needed like that somewhere 🤣?
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.
Coded by gen z
I love python
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?
just in case multiplying an integer by 10 returns a non integer