« first day (4908 days earlier)      last day (38 days later) » 

12:30 AM
Well... thanks everybody... the solution was.........
Update Seaborn!
Weird!!
 
 
7 hours later…
7:32 AM
I find the failure of vertical farming really interesting. It's just such a no-brainer that our tech should win out over traditional farming and yet, no matter how explosive the gains in production density gets, it doesn't even come close to paying off and the cost profile is not what I expected. Tech can't just always win
I mean, it's not going to stop me jerry-rigging up some Arduinos and doing it right at some point in the garage. Obviously tech will win, they just all did it wrong :P
 
 
1 hour later…
8:47 AM
Does anyone know what logic ruff is employing with this change? The actual code is 3 indentation levels deep and I have a limit of 79 chars, which is all fine. But why does it want me to have the argument of "0" just hanging on its own line? I can add # noqa but I can't even fathom the logic of the rule it's applying
group["adjustment_qty_excl"] = (
    group["adjustment_qty_excl"].fillna(0)
)
# Goes to
group["adjustment_qty_excl"] = group["adjustment_qty_excl"].fillna(
    0
)
(Actually, # fmt:skip not noqa)
 
I guess it just tries to fit as much as possible into the first line? That's generally sensible and easier to code
 
Silly ruff, you still have the same line count. Grab a coffee or something
 
9:04 AM
black also had such problems in the beginning, though thankfully they've fixed the most annoying ones.
Spreading out code over bth the vertical and horizontal space that you use anyways usually looks better, but is more complicated to put into rules.
 
I'm happier knowing it's part of a dodgy heuristic vs. some codified rule which makes no sense
 
@PM2Ring Saved it for later, thanks <3
 
@MisterMiyagi Yikes, it seems like black handles that specific code the same way. It actually looks better with more indentation.
Also, 5 levels of indentation? Seriously? :P
 
Part of me wonders whether it's because I'm being extra old-skool with the 79 character limit while their heuristic is probably tested more against 100 or 120 characters
Or 88. Everyone seems to have their own, cool, indentation rules these days
 
90'ish is the new 80.
does the disco dance
 
9:19 AM
๐Ÿ•บ
 
That button is so worth it, isn't it? ๐Ÿ˜Ž
 
You've taught me to see the power of the button :P
Well, apparently I'm not quite 100% upgraded yet and still use text-based emojis
 
We're not old, just experienced. ;)
 
10:10 AM
@MisterMiyagi ah, I initially missed this. I don't think it's excessive?
def MyClass():
    def my_method(self):
        df = pd.DataFrame("<some_query_result>")
        grouped = df.groupby("<some_cols>")
        for key, group in grouped:
            group["adjustment_qty_excl"] = group["adjustment_qty_excl"].fillna(0)
 
Do you have a custom line length set? With black I definitely needed deeper nesting to trigger it.
 
79 is the character limit, which that last line steps over
But what I actually implemented is what I showed earlier, and I don't think the formatter should have any business touching it
group["adjustment_qty_excl"] = (
    group["adjustment_qty_excl"].fillna(0)
)
I have a ruler in VSCode so I could already see it would trigger a fault, and then brought it back in line by wrapping with brackets. Still, ruff/black get triggered by this and make things worse
 
why are you still using black, ruff is better! :P (already because of the simple fact that it lets you choose single quotes as the preferred quoting style)
 
That is ruff :P
Let me make an MCVE
import pandas as pd

def MyClass():
    def my_method(self):
        df = pd.DataFrame(
            {
                'a': [1, 1, 2],
                "adjustment_qty_excl": [4, 5, 6]
            }
        )
        grouped = df.groupby("a")
        for key, group in grouped():
            group["adjustment_qty_excl"] = (
                group["adjustment_qty_excl"].fillna(0)
        )
If you put ruff format on that file (with a char limit of 79), it'll convert that last line to the stupid one with the dangling "0" argument
The last ) should have been indented by 1 level, but it doesn't make any difference. Since I didn't hit the 79 character limit, I don't see why it feels the need to undo my own manual formatting
 
10:43 AM
@ThiefMaster because ruff casually changed the semantic meaning of my code. Canโ€™t think of a more severe no-no.
 
Is that with the zip(strict=True) argument or something else it injects?
 
11:09 AM
yeah, didn't keep using it afterwards.
 
I didn't think my observation would have such impact. It'd be worth raising that issue with them? I admit that it spooked me a bit because it invites the question of "what else is it doing?"
 
It's really the latter thought and not so much the specific change.
 
To be fair to them, I might have invited that change by taking a config from elsewhere (I basically copied Flask) so I might have cargo-culted it onto myself without realising. However, I never expected it to change function calls so now the burden is on me to stamp out every possible rule it might apply. There's also nothing I've seen that tells me that, had I started from scratch rather than copy someone else, that it wouldn't happen by default
Specifically, I took this
I think it comes from bugbear
 
11:28 AM
Yeah, I also run flake8-bugbear on my own code.
Using strict=True instead of nothing is actually ruff's documented, suggested fix.
 
What I mean, specifically, is if I had dropped this line I probably wouldn't get the auto-change to zip(). But it still leaves me wondering if there are other changes that could be happening
 
 
1 hour later…
I had a crazy idea for my programming language that could be genius or absolutely awful: Function names can be sentences
# Function definition
function create a symlink from source (FilePath) to destination (FilePath)
    ...  # Implementation here

# Function call
create a symlink from '/bin/foo' to '/usr/bin/foo'
Forget pseudocode, we're straight up writing english
 
create_a_symlink(from='/bin/foo', to='/usr/bin/foo')? :P
too bad Python snatched all the nice words. :(
 
On one hand, yes, it's kind of a pointless change. But on the other hand... have you ever seen code that actually looked like create_a_symlink(from='/bin/foo', to='/usr/bin/foo')? I haven't. The language has to put the programmer into the right mindset
 
1:22 PM
True. I'm just afraid that this mindest leads to LISP. :shudder:
 
I fear that ChatGPT has stolen Aran from us. It's basically a declarative style for a function name?
 
I played around with it a little bit, and to my surprise, it seems to lead to code that's easier to write than read. It's very verbose. You can't just glance at a piece of code and immediately know what it does, there are simply too many words
And there is very little structure. Syntax like create_a_symlink(from='/bin/foo', to='/usr/bin/foo') makes it easier to tell apart the individual bits and pieces (function name, parameters, etc)
Syntax highlighting might improve things, I guess
 
Trick question: How does nesting work?
 
What, specifically?
 
Say I define a path helper function base (FilePath) to target (FilePath) to get relative paths. As in '/bin/foo' to '/bin/bar' gets you '../bar'.
 
1:30 PM
@roganjosh Is it declarative? I'd say it's still imperative, just with more "natural" syntax
 
FWIW, if you are fine with simple pattern matching (and not all the funky reordering of natural languages) you could try building a toy by just slapping something like pyparsing in front of something that emits Python code.
 
I do think we have to move towards more declarative languages though. Humans often think in a declarative way, and having to translate everything into imperative style takes far too much effort and care (to avoid bugs) to be maintainable in the long term
 
The intent of the function naming certainly sounds declarative even if it's still imperative in its implementation.
@Aran-Fey I take the opposite view of this. If you take something like SQL, which might be a halfway-house for your idea, it takes a lot of energy to be sure it's doing what you think you told it to do, When you write a function with arguments in the current style, you should have to think about it upfront
 
@MisterMiyagi Are you asking how I would go about parsing nested/ambiguous function calls like create a symlink from '/bin/foo' to '/bin/bar' to '/usr/bin'? Honestly, I haven't thought about it yet. I'm still at the "decide if this is a good idea" stage
Generally speaking, I'm not too worried about such cases because it's unreadable code anyway. I would be perfectly fine with forcing the user to rewrite that code
 
I don't think it's a bad idea, it's just not something for big things.
AFAIK AppleScript was designed to be close to English, and also targeted at smaller automation tasks.
@MisterMiyagi Which isn't a bad feature, mind. Most tasks aren't big things, and many people shouldn't exactly handle big things.
 
1:43 PM
@Aran-Fey create a symlink from (select a file name like ".csv" from <input_directory>) to (select a file name like ".parquet from <other_dir>). Or create_simlink(select_dir_file(".csv"), select_dir_file(".parquet"))It's harder than I thought to write hypothetical code, but I think that's what's intended by "nested"
 
On the other hand, this can be a good way to force people to write multiple sentences.
 
They're not sentences, though, it's nested declarations. It'd be like I have both a chronic cough and momentary amnesia, where I keep interrupting my own flow of thought, switching to something entirely different, and then jumping back to what I was previously saying
 
The author of PERL actually has some nice writeups on this. The only problem is that the next step then was that $_ obviously means "it".
@roganjosh Well, perhaps they should be? Languages with statements for a similar design but don't make it quite as painful to use deeply nested expressions.
For the source, select a file name like ".csv" from <input_directory>. For the target, select a file name like ".parquet from <other_dir>. Create a symlink from source to target.
 
But that's just basically SQL, isn't it? Just now broadened out
 
Let's be real here, SQL is a lot uglier...
 
1:55 PM
lol
 
IMO it's only superficially similar to SQL. Like how nim is supposedly a "pythonic" language, but really it's C programming with python syntax. Sure SQL uses a lot of english words, but you'd never confuse SQL for a real sentence. That's just not how we think
(At least I don't. SQL feels like I have to turn my brain inside-out)
 
Oh gosh, I never understood why they marketed nim as Python like.
Totally raised the wrong expectations there.
 
My point is not to say that SQL does it right, but that your naming style basically devolves into that system once you have nested function calls. "Just typing English" gets thrown out of the window at that point, surely?
 
Not necessarily, I think. As long as the language gives you sufficient freedom, you'll find a way to express your thoughts in a natural way
For example, instead of create a symlink from (select a file name like ".csv" from <input_directory>) to (select a file name like ".parquet from <other_dir>) you could write something like create a symlink from a '.csv' file selected by the user to a '.parquet' file selected by the user. Or split it into 3 lines like Miyagi did earlier
 
Well, that works in the case that a) you anticipated exactly how I wanted to express that intention and named your functions appropriately or b) used an LLM to interpret the request
 
2:07 PM
I hear that natural language has a way to deal with this, such as subclauses and the like.
 
 
1 hour later…
3:35 PM
Cbg. Anyone knows this error?

raise TypeError(f"tz must be string or tzinfo subclass, not {tz!r}.")
TypeError: tz must be string or tzinfo subclass, not <matplotlib.category.UnitData object at 0x2b2be6bf08c0>.
ax = sns.histplot(l, kde=True, bins=10)
ax.set(xlabel='PERÍODO', ylabel='QTD. MAPAS TEC')
plt.savefig('HISTPLOT.pdf', bbox_inches='tight')
I'm just trying plot using seaborn code above.
lis a list of datetimes, generated this way:
l = []
for i in range(len(dates)):
l.append(datetime.datetime.strptime(dates[i], '%Y-%m-%d %H:%M'))

utc_timezone = pytz.utc

l = [dt.replace(tzinfo=utc_timezone) for dt in l]
See that I've tried to mess with time zone things, when that weird error started to appear
 
 
2 hours later…
5:56 PM
I don't know how to repro that and we have a formatting guide for chat @Marco
It doesn't make sense that you'd get an error after plotting the figure, where you add timezone data
 
6:12 PM
@roganjosh Ok, some things really weren't formatted, sorry
@roganjosh No. The complete relevant code is:
l = []
for i in range(len(dates)):
    l.append(datetime.datetime.strptime(dates[i], '%Y-%m-%d %H:%M'))

utc_timezone = pytz.utc

l = [dt.replace(tzinfo=utc_timezone) for dt in l]

ax = sns.histplot(l, kde=True, bins=10)
plt.savefig('HISTPLOT.pdf', bbox_inches='tight')
 
Again, the formatting is wrong and it's not an MCVE I can run locally because I don't know what dates is
 
tips: don't call any variable I or l in python (very ambiguous), and don't iterate over a range unless you really need to (almost never the case)
for that first loop using for d in dates: would make more sense
 
The two code samples are completely different. In the first case, it looks like the plot was made before the timezone addition, and in the second it's afterwards
 
@roganjosh I was just explaining some things before
Anyway, seems I've solved the problem
@ThiefMaster thanks for the tips!!!
@roganjosh I understand about the MCVE, sorry.
 
I'm glad you've solved it
Typing it out and having to abide by rules is actually a great way to debug code. Long live the rubber ruck
 
6:20 PM
Seems true
Complete actual code:
 
And the Oscar goes to......... mdates.date2num
@roganjosh ?
 
Come on. Also in the rules is that big blocks of code should be posted off-site and linked to here
 
What's considered big block of code?
How much lines?
 
It's literally in the rules. I try not to be too strict on that rule but what does anyone gain from a screen full of your working code, illustrating no problem but also nothing relevant to them?
 
6:27 PM
The worst part is it still wasn't working code
 
@roganjosh I've explained after showing the code. The solution was using mdates.date2num.
@Aran-Fey Of coure it works.
 
Oh really? Where is the dates variable defined that you print in line 11?
 
@Marco depends on the screen size, but to be on the safe side, I want to say 5 lines+ or so
 
@Aran-Fey Just some typos. Fixed: pastebin.com/h5CFLvPz.
Sorry.
@NordineLotfi Thank you very much!
@roganjosh The objective was to give feedback on the problem I was facing, and it could help other people who have the same problem.
 
@Aran-Fey I did that once. Usually when I'm testing I call the functions weird name, but if it's something that took time for me to make, or useful enough that I don't want to rewrite, I give it a meaningful name like that one
@Aran-Fey reminds me of this: github.com/Folds/english and here some example code: board.flatassembler.net/topic.php?t=18031
Funnily enough, it's severely undocumented even though it's supposed to be as verbose as English...
 
6:43 PM
I like the declaration syntax with the to, but a lot of that code is borderline incomprehensible to me
> reassign the string's first given the string's length plus 1.
???
 
yeah, there more weird example on the Quora page of the author: quora.com/profile/Gerry-Rzeppa there was also a wordpress blog with more examples but I can't find the link hmm
 
@Aran-Fey people don't think it be like it is, but it do
 
but then who was phone?
 
 
1 hour later…
8:06 PM
Are datetime objects much smaller (lighter) than strings?
 
No. They carry metadata
 
8:28 PM
Actually I could be wrong on that if it uses Unix time and wraps that int
 
8:40 PM
I think datetimes have a larger range than unix time
 
9:02 PM
@roganjosh Hmmm. Ok, thanks.
@roganjosh Right.
@Aran-Fey Hmmm, thanks.
 
9:13 PM
@roganjosh I think datetime can express some things that timestamps can't. Like leap seconds and all that fun stuff.
 
If I'm honest, it was a cover-my-backside comment because I couldn't imagine a datetime being cheaper in memory... but there's always a "what if..."
 
 
1 hour later…
10:24 PM
So let's go:
 
@Marco I did say 5 lines+ max. Here this isn't just about lines per code block, but per screens. On my end and probably other's people end, this is taking the entirety of my screen, if not more than half
would be better to post it on gist.github or pastebin
 
Ok, sorry and thanks
Here: https://pastebin.com/Yn8kEUi1.

myarray1.npy has 15,71 GB and myarray2.npy has 1,32 GB. Why? The size of myarray2 (length) is still a little larger than the size of myarray1 ( (488593, 576) versus (457509, 576) ).
myarray2 has, at the element level, datetimes and myarray1 has strings.
 
but how did you create those two arrays? can you show the code you used for doing that
 
10:39 PM
numpy probably stores unix timestamps internally and then converts them to datetimes when you access them
 
@NordineLotfi I can show you it: pastebin.com/mBXDscrt. The prints of myarray1[0], myarray1[0][0], myarray2[0] and myarray2[0][0].
@Aran-Fey So it's lightier than strings?
 
Yes
 
Oh
So muchhhhhhhhhhhhh lightier
But why?
I didn't understand the details.
 
A unix timestamp is just a number. Meanwhile, a datetime is a whole bunch of numbers plus a timezone
 
I mean the comparison between datetimes and strings.
chat.stackoverflow.com/transcript/message/57214849#57214849: complementing: both arrays store just year, month, day, hour and minute data.
 
10:51 PM
Umm, how do you know that? As far as I know, datetimes store more than that
 
chat.stackoverflow.com/transcript/message/57214857#57214857: complementing: and the same data pattern continues through both arrays.
To see the outputs.
 
Just because it only prints 5 numbers that doesn't mean that it only stores those 5 numbers
>>> datetime.datetime(2000, 9, 8, 7, 6)
datetime.datetime(2000, 9, 8, 7, 6)
>>> datetime.datetime(2000, 9, 8, 7, 6, 5)
datetime.datetime(2000, 9, 8, 7, 6, 5)
>>> datetime.datetime(2000, 9, 8, 7, 6, 5, 4)
datetime.datetime(2000, 9, 8, 7, 6, 5, 4)
 
Oh, ok, I'm just talking about the high level.
@Aran-Fey But I didn't understand your code example
 
Well, if you're concerned about memory usage then you should start talking about the low level
 
@Aran-Fey No problem
But the point is that datetimes are lighter in this case hahaha
So it doesn't make much difference to analyze the deeper levels
It makes sense to analyze in detail what a string is
 
10:58 PM
I've already explained why I think it consumes less memory. This is getting too tiresome for me, so I'm tuning out
 
@Marco it's only lighter if you don't store the full object, but instead the content within the parentheses: datetime.datetime(2000, 9, 8, 7, 6, 5) but instead you could store: (2000, 9, 8, 7, 6, 5)
 
@Aran-Fey You compared datetimes with timestamps, I didn't see a comparison between datetimes and strings. Unless when you commented about timestamp it means string.
@NordineLotfi Hmmm, interesting, so seems it's my case.
That's, I don't store the full object.
Well, no: one data example: datetime.datetime(2013, 8, 10, 18, 10).
chat.stackoverflow.com/transcript/message/57214896#57214896: but ok, I don't want you to get bored.
 

« first day (4908 days earlier)      last day (38 days later) »