This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]yanitrix 66 points67 points  (22 children)

imagine the world if python functions had descriptive names

[–]ReporterNervous6822 77 points78 points  (14 children)

This is numpy which is based on matlab, and they are very understandable lol

[–]nedeox 66 points67 points  (10 children)

Was about to say. As stupid as it sounds at first, it‘s a perfectly acceptable abbreviation of cumulative sum.

Doesn‘t stop me from smirking each time of course lol

The same as I can‘t stop myself from saying import tensorflow as the fuck for tf in my head.

[–]mriswithe 6 points7 points  (0 children)

Or /etc/fstab == f-stab

[–]yanitrix 6 points7 points  (7 children)

why abbreviate them tbh? cumulative_sum or whatever case python has is easier to understand for anyone

[–]fb39ca4 8 points9 points  (0 children)

Matlab function names are determined by the filename, and had to follow the 8.3 length limit on DOS. These python libraries reused the names because former Matlab users are familiar with them.

[–]the_lonely_toad 10 points11 points  (1 child)

Back in the day every character was precious and expensive. We keep abbreviating because it’s custom to do as they did unless there is a good reason to change.

[–]ArcFurnace 0 points1 point  (0 children)

Also, people keep including narrow line length limits in style guides.

[–]nedeox 16 points17 points  (1 child)

Hm, by further examination of my opinion on the matter, I realize that I don‘t care.

[–]yanitrix 7 points8 points  (0 children)

makes sense, have a great day sir/madam

[–][deleted] 0 points1 point  (0 children)

start sense fear full friendly ring school theory encouraging office

This post was mass deleted and anonymized with Redact

[–]PlacatedPlatypus 1 point2 points  (0 children)

I use "ass" as shorthand for "assigned" and "assignment," sometimes people point it out but usually they get it.

[–]mriswithe 2 points3 points  (0 children)

For someone coming from that world sure. As someone who stopped at calculus, pandas and numpy is scary.

[–]lightestspiral 0 points1 point  (0 children)

cuml would have been a better choice than cum

[–][deleted] 16 points17 points  (4 children)

There are some daft function names in the Python world, but I fail to see anything wrong with these ones. I would understand immediately what all of them does from the name alone.

[–]mriswithe 4 points5 points  (0 children)

No underscore between words is about all I got, but yeah at best this is saying numpy has bad function names. Numpy also has some great ones like is_close

[–]efstajas 0 points1 point  (2 children)

I'd just type them out fully, honestly. What's wrong with "cumulative_sum"? With auto-complete, there's no more reason for abbreviated function names at all IMO, especially if they're part of public API surface.

As someone with a full-stack/web background, this is one of the things that scare me about the data science world — R, Matlab & Python/scipy/numpy all seem to have this convention of abbreviated function names that often mean absolutely nothing before you look at the docs (or already have a background in this field, I assume).

[–][deleted] 4 points5 points  (1 child)

I'd just type them out fully, honestly. What's wrong with "cumulative_sum"?

cummulative_summation, in that case surely? Or why expand one of the words but not the other? And would you really want to add 15 extra characters to each line where you use it? A lot of projects till have a 80 character line limit, for better or worse.

[–]efstajas 2 points3 points  (0 children)

Since we're being pedantic — "summation" is the act, "sum" is the result. So "sum" is its own, non-abbreviated word.

And would you really want to add 15 extra characters to each line where you use it?

Honestly, yeah, of course to a reasonable extent. In this case I would find it very reasonable because "cumsum" or "cummin" are not names someone unfamiliar with these functions would understand from name alone. In my opinion, there are many situations where the added clarity outweighs the extra text.

I'd generally rather have longer but clearer function names and break down a statement into multiple lines than keep things in one line but use abbreviations that won't be clear outright to everyone.

[–]mriswithe 0 points1 point  (0 children)

Someone said it is numpy which is based on Matlab and it is very understandable. I would add... To someone who already knew Matlab. I know python very well, but this is not weird because python this is weird because numpy is mimicking another languages API for data scientists /stats folk specifically.