« first day (4135 days earlier)      last day (1037 days later) » 

08:08
@AndrasDeak ¯\_(惄)_/¯
08:57
@AndrasDeak I try to keep the rodent away by using a stick, but then again I can make the stick go tick to the same effect
 
3 hours later…
11:38
@Aran-Fey Since I'm in the middle of documenting some async APIs... signatures are a mess. Specifically, automatic signatures often look like hell, but manually overwriting them only works in a limited way and tends to fail in obscure ways.
It looks like Sphinx tries to reconstruct name, parameters and return value by (regex?) matching its input. But that matching is rather brittle and there is no way to force a manual override.
Oh, I think I know what you mean. I think autodoc creates the signature as a string, since that's the only kind of input sphinx can work with, and then sphinx tries to parse it and figure out which class your type hint is referencing
Case in point, documenting an @decorator where one would want to omit the parameter (since it comes via @ ... def) seems to be outright impossible. :/
@Aran-Fey Jah! šŸ»
@MisterMiyagi sounds like something that ast should be used for, right?
Interesting point about decorators. I never thought about how sphinx renders those. Are you using an autodecorator directive for it?
@hugovdberg Documented signatures often enough aren't syntactically valid, so I'm not sure if it's not just trading one problem for another.
@Aran-Fey I've got an :decorator: directive (option? flag?) for function/method/class directives (statements?) via a plugin...
Basically, it adds an @ in the beginning.
11:48
You need a plugin for that? Crazy
@MisterMiyagi then I guess I don't exactly understand the problem you're facing ;-) what documented signature do you mean, that's not syntactically valid?
> The name is because [...] Iā€™m not very creative.
mood
@hugovdberg Well, if you just look at the standard library the conventional signature syntax is not valid Python.
As mentioned, for decorators there's the problem that they are used without any parameters ā€“ i.e. no "signature" so to speak.
I've also haven't figured out yet how (if?) one can refer to type variables of generic classes.
.. autoclass:: MyClass[R] failed because it assumed the generic part belonged to the name.
What blew my mind the first time I read about documentation syntax is that there's nothing specifically for referencing function parameters. Somehow everybody seems to be content with just making them italic?!
11:55
ah like that, but then that's mostly a problem if the signature is already converted to a string, not so much when reading the source code.
Is that how one is supposed to do it? I always single-`-quote them.
That's how I do it, too. But I think italics are more common.
Wait, single `? I think I do doubles
@hugovdberg Well, admittedly it has no problem reading this: async def foo(__iter: Union[Awaitable[AnyIterable[Awaitable[T]]], Awaitable[AnyIterable[T]], AnyIterable[Awaitable[T]], AnyIterable[T]]) -> AsyncIterator[T]
But humans do. :/
What do single `s even do?
How do you make a signature like that human-readable? :D
It seems like this replacement should actually allow you to annotate the ast ;-)
12:01
@Aran-Fey Apparently, it's interpreted-text. It looks nice enough, so I never cared what it actually means. šŸ¤·ā€ā™‚ļø
@Aran-Fey I currently use async for :T in any_iter(iter: (await) (async) iter (await) T). Might switch the "optional async" and such to use [] instead of ().
Huh, I didn't know you could do that without attaching a role to it
Hm, I should probably find out what the "default role" actually is...
@Aran-Fey perhaps using a type alias, which would make the source code perhaps somewhat more readable as well
This conversation is making me realize that I have a lot of work ahead of myself...
@MisterMiyagi Have you considered a question mark, like await? async? iter? I think that would be easier to decipher without having read an explanation of the syntax
@Aran-Fey we can wait a few days ;-)
12:19
"Please wait a few days. If it's not done by then, read this sign again."
@MisterMiyagi so you would actually want an extension of the type hinting system to allow Maybe[Awaitable,AnyIterable[Maybe[Awaitable,T]]] which would then be displayed as [await] iter [await] T?
12:43
Just introduced my first ever deque into production code \o/ It feels totally bizarre to me that I've never had cause to use them before, given that I've known about them since pretty much day 1, especially given all the server-y stuff I do. Huh
13:17
@Aran-Fey I haven't, but it looks simpler indeed.
@hugovdberg Nah, it's fine for the type hinting itself. Having such optional intermediate types is (hopefully) rare.
(There's also a can of worms that all the good names are taken.)
@roganjosh šŸ„³
@Aran-Fey That reminds me of my favourite sign that one of my uni housemates had. "The beatings will continue until morale improves"
13:51
cbg folks
Time for another installment of: guess the output. (use spoiler tags)
for i in range(5):
    try:
        i / 0
    except ZeroDivisionError:
        raise RuntimeError("Div by zero")
    finally:
        continue
print(i)
@MisterMiyagi aye
'Tis a tricky one, though.
Not if you assume an older Python version, then it's simply a SyntaxError
> A continue statement was illegal in the finally clause due to a problem with the implementation. In Python 3.8 this restriction was lifted.
TIL
Yam, another bytecode discussion honey trap... D:
14:22
another riddle: find the github repo starting from sphinx-doc.org/en/master/index.html
(ping misplaced though, sorry)
morning cabbages, folks
@roganjosh Ok.
Thanks for the advice
@MisterMiyagi this is what I was looking for github.com/sphinx-doc/sphinx/issues/8052
I noticed this site: python.tutorialink.com. This website is taking questions from Stack Overflow and they are just mentioning the source as Stack Overflow. They didn't provide a link to the original question in SO and didn't credit the author of the post. So, is it a violation of the CC BY licence?
@AndrasDeak that's easy. Click the "v: master" button, click "View" in the GitHub section, get the 404, click on the address bar, remove everything after the name of the repository. Boom, github.com/sphinx-doc/sphinx
14:28
hehe
I didn't even have JS enabled so I had no "v: master"
@roganjosh Sounds like a solid strategy!
What can we do with this question: stackoverflow.com/questions/9138112/… The title is highly misleading and pops up when searching for questions that actually have to do with looping over lists.
After reading through the history of the question a second time (half a year later), I think the original problem was that the asker had written len(x) == 2 when actually trying to search for sublists with length 3, so the question should have been closed as "typo". I'm puzzled how it received so many upvotes.
Probably from people looking for the title and being able to salvage something from it.
I'd say nuke the thing from orbit
(I was actually searching for a duplicate for stackoverflow.com/questions/71066874/…, if someone knows a good one... finding one is relatively hopeless due to questions such as above)
14:44
TBH those kinds of questions is what made me to cut down on answering on main to a minimum. No point in teaching people to walk when they cannot even crawl and still insist climbing Mount Everest...
Ha, I was actually a bit surprised in a good way, because when I see a JSON question I automatically assume the answer will be some variation of "use your brain"
"I have a dict full of lists. How can I access the first value in the 'foo' list?" Gee, I wonder. It's a mystery
It's certainly been a while since I've last seen a JSON question that was actually about JSON.
15:33
Has anyone else seen the moderately popular tweet that's like "my daughter is learning Python and she asked me why the computer is so picky about semicolons"
They had me right up until the last word
"Yeah sister, preach, louder for those in the back -- waaaaaait a minute"
The worst part was that it got thousands of upvotes
I wonder if every "my child did this thing which is both cute and indicative of wisdom beyond their years" tweet is like this, but I can't find the flaw unless it's in my field
@Kevin there was a follow-up to it - basically the OP probably made a typo, if they are to be believed
"Hang on, feldspar isn't indigenous to the American southwest, this calls into question this guy's nephew's entire anecdote"
If the follow up is "whoops, I meant 'colons', sorry", I'll go back to requesting sister to preach
On one hand, "it's a typo" is a lame excuse. On the other hand, semicolons in python?! Nobody can be that ignorant, surely?!
15:43
I find the idea of mixing up colons and semicolons implausible, but I also know that # is an octothorpe
Don't be silly, that's a hashtag
What I'm saying is that it's entirely possible that there are normal human beings out there for whom the distinction between : and ; being colons or semicolons just may not matter that much
The character ";" has more black pixels than the character ":", so surely the former is the full colon and the latter is the semi-colon
I'm also not ruling out the existence of unicorns and bigfoot
@Kevin I've heard more flimsy reasoning for other mistakes
@WayneWerner you mean the hashtag symbol?
15:46
I jest, but if I had surpeme cosmic power I probably would rewrite history so their names are the other way around.
Also I would pick more easily distinguishable names for "slash" and "backslash", and maybe nudge Ben Franklin into assigning negative charge to the other end of the kite
Also I wonder what those tiny metal shaped router reset devices are
I'd be tempted to go to 1797 and intercept the unwelcome visitor that interrupted the fragile creative flow of Samuel Taylor Coleridge while he penned Kubla Khan: or, A Vision in a Dream: A Fragment... But I've seen enough time travel movies to know that I will having have been the unwelome visitor the whole time.
Nice try spacetime, no self-fulfilling prophecies for me thanks
 
1 hour later…
17:19
a recent email: "Kevin, your appointment has been scheduled for @@APPOINTMENT_DATETIME@@. Please arrive on time, and bring one form of photo ID"
Looks like somebody's automated email system forgot to actually run their template engine
And we all laughed at the NHS in the UK using an old version of Excel, truncating rows. At least the people contacted would have been given an actual date!
hi. what's the term in pandas to group in 20 minutes like:
input:
2022-02-10 13:56:26+00:00 1.0
2022-02-10 13:54:26+00:00 4.0
2022-02-10 13:52:26+00:00 6.0
2022-02-10 13:50:26+00:00 8.0
2022-02-10 12:20:04+00:00 1.0
2022-02-10 12:18:04+00:00 5.0

desired output:
2022-02-10 13:50:26+00:00 19
2022-02-10 12:18:04+00:00 6
@Kevin which means "Kevin" is part of their template
17:35
That's what's surprising me the most. It put my name in correctly (along with some other details I didn't mention here), so the engine must be running. If it can't fetch the appointment datetime, I'd expect it to put "null" or something, rather than leak information about their template.
@chaim Why 13:56:26+00:00 and not 2022-02-10 13:50:26+00:00? There's a rule there
In any real dataset, you'd expect multiple overlapping timestamps so it's not at all clear to me how you picked the "nucleus"
Sorry, not overlapping timestamps. Overlapping 20 minute blocks, depending on where you start segmenting the data
Data is not regularly inserted, I would like to sum (group) all values that are less than 20 minutes away from the next together
So, you need to identify where there has been a break of more than 20 mins?
no, the other way, I would like to identify data that belong to a group
That's different to wanting to group data; you're looking for discontinuities (that probably isn't going to help as a search term)
17:44
this is irrigation data, If the gap between two measures is less than X minutes, it belongs to the same irrigation
Right ok, thanks. I was thinking I was losing my mind
I would like to group irrigations, that's it :) I've looked and used before the resampling methods, but those are based on regular intervals 00:20, 00:40...
I know I could do a kind of loop to iterate over them, but I'm quite sure there is a term for this...
I will look into cut as Kevin says
I'm working on it now
I'm not sure if I understand the desired logic... If you have measures from 12:00, 12:09, 12:18, and 12:27, how should they be grouped? Do they all go in one group, because there is no 20 minute gap between any adjacent measurements? Or should 12:27 get its own group, because it's more than 20 minutes after the first measurement?
@Kevin in that example all belong to the same group
17:50
Ok
df = pd.DataFrame([['2022-02-10 13:56:26+00:00', 1.0],
['2022-02-10 13:54:26+00:00', 4.0],
['2022-02-10 13:52:26+00:00', 6.0],
['2022-02-10 13:50:26+00:00', 8.0],
['2022-02-10 12:20:04+00:00', 1.0],
['2022-02-10 12:18:04+00:00', 5.0]], columns=['datetime', 'value'])

df['datetime'] = pd.to_datetime(df['datetime'])
df['group'] = np.where((df['datetime'].shift(1) - df['datetime']).dt.seconds > 1200, 1, 0).cumsum()
print(df.head(20))
I don't think it has a name
I think cut won't work here because it only understands how to work with bins of a constant size. You've got a constant-sized "discontinuity" of 20 minutes, but your bins can be arbitrarily large
roganjosh's approach looks good, but I wonder if there's a builtin way... I will peruse the documentation
I really doubt it. All that's missing now is an aggregation from my approach
I'm trying roganjosh approach on my df now
df = pd.DataFrame([['2022-02-10 13:56:26+00:00', 1.0],
['2022-02-10 13:54:26+00:00', 4.0],
['2022-02-10 13:52:26+00:00', 6.0],
['2022-02-10 13:50:26+00:00', 8.0],
['2022-02-10 12:20:04+00:00', 1.0],
['2022-02-10 12:18:04+00:00', 5.0]], columns=['datetime', 'value'])

df['datetime'] = pd.to_datetime(df['datetime'])
df['group'] = np.where((df['datetime'].shift(1) - df['datetime']).dt.seconds > 1200, 1, 0).cumsum()
df = df.groupby('group').agg({'datetime': 'max', 'value': 'sum'})
print(df.head(20))
18:01
On one hand, this seems like a fairly useful operation that people would need fairly frequently. On the other hand, I have a pretty bad track record for estimating how useful/frequent an algorithm is among a large user base.
I can't believe I'm posting code with that kind of alignment. I think deadlines have actually broken my OCD on getting things lined up
Let's say that whenever I think an algorithm is useful, I'm wrong 60% of the time. So me feeling like it's useful is actually a strong indication that it isn't useful
your approach seems right, thank you.
I'm having some troubles converting that to my df since mine uses an Datatimeindex but I should be able to solve it :)
Anyway. I wonder if diff could be used in place of shift, somehow. Saves you a subtraction in Python-space
Wait, why is the subtraction in python?
18:09
I just mean, there's a minus sign in the expression. I suppose that doesn't necessarily have any performance drawback.
You had me very worried there :D
I only want you to be a little worried. I will reduce my intensity by 80%.
I can't get the correct results without - but if you get your idea working then I'm more than happy to hear it. And especially interested in speed testing it
Alright, if I get a prototype working, I'll share it
18:41
pastebin.com/raw/vsEteRd4 I'm not enthused about the abs() call there, but I couldn't get timedeltas to work elegantly while they're negative
For example, pd.Timedelta("-2 minutes").seconds gives 86280, which seems a tad high
pd.Timedelta("-2 minutes").total_seconds() gives -120 as desired, but I don't know how to call a Timedelta method on a Series of Timedeltas
I guess I could have done df['group'] = (df['datetime'].diff() < pd.Timedelta("-20 min")).cumsum(), but I desire yet more elegance
jrh
jrh
cbg, does anybody know offhand if there's some kind of "Python Interpreter Cache" in Pipenv? I noticed that on one computer it seemed to store the path to a python interpreter when Pipenv was installed. Later on, we removed the interpreter from PATH (and as far as I can tell, any trace of anything that would shove it back in PATH). Typing python just did nothing. However Pipenv still helpfully "found" this interpreter somehow. I looked in AppData but didn't find anything.
What else was interesting, is that uninstalling that version of Python completely made it so that pythonfinder no longer found that version of Python, Pipenv still had the old path. Reinstalling pipenv at that point finally expunged it from the system. So to me that would indicate that both pythonfinder and Pipenv have their own cache... somewhere, even though I couldn't find any trace of it in either of their sources, except some kind of "implied" cache from click (which I also could not find).
It's unusual that typing python would do nothing. I'd expect it to say something like "'python' is not recognized as an internal or external command, operable program or batch file."
jrh
jrh
@Kevin That's what I meant by "nothing", yeah. Sorry if that was confusing.
Ok, that makes more sense
@Kevin mm. With my hacky first-pass on timings (I need to get timeit involved but I wanted to know first whether I was blown out of the water) I can get mixed results on who is fastest with this. In the general sense, it looks like you pip me more often than not, but not always
18:51
I think our complexities are the same, so yeah the difference won't be amazing
@jrh That does seem to imply that pipenv keeps a cache. I'm not so sure about pythonfinder. But even if there's only one cache among them, perhaps they share it.
jrh
jrh
@Kevin I think you are right about there being a cache, but if there were only one, why did their caches desync when pythonfinder "forgot" about the former python interpreter but Pipenv still stubbornly tried to use the now absent interpreter at its former path?
I will be honest I am not an expert at click, but it appears that there is some kind of "context" and "state" sharing, I attempted to find some kind of "nonvolatile storage" retained between command calls, but did not find any, but I would guess there is.
It is a long shot but I also checked the Registry (I can't imagine a cross platform tool would enjoy writing to the registry), did not find anything there. Also... I did find Pipenv's cache earlier, but it has no reference to python interpreters at all, it appears to only store recently installed packages
Likewise, I am not an expert. So if you find my ideas confusing, it might just be because I'm wrong
jrh
jrh
Wait....... is there a venv cache?? I just thought of that.
There's a tragic irony here. Virtual environments are supposed to encapsulate their state so it doesn't leak into your real environment and linger indefinitely. But the tool you're using to generate venvs is creating state in your real environment, and it's lingering indefinitely.
jrh
jrh
19:07
Yup. I realized I am reading things the author intended when I found terms thrown around in the source like "project" -- what is a "project"? That's not even documented.
I always found Python's packaging ecosystem to be one of the least Pythonic things about Python
jrh
jrh
Yeah. A lot of cases where Python could have learned from other languages but didn't, sadly. package-name and module_name will always be baked in to our lives I guess, because they never imagined that somebody would have a package that consists of more than one "word". A very silly judgement call, we all know the jokes about experts-exchange.
Language gets old, you either have a choice between descriptive, long names (add dashes), or you pick some word at random ("I'm going to call my ML analytics library airplane!"), or you abbreviate ("SCMLL4PBS: Super cool machine learning library for peanut butter sandwiches")
All of that's extra fun in a duck typed language, forget where the dash goes or leave out a letter, or misspell something, it just crashes.
I think IDEs can catch those kinds of mistakes. Not that I would know, I just use Notepad++ and live with the inevitability of surprise crashes
I can't say I understand any of these complaints
it's better not to think about packaging in python, just use it and do your job...its crazy, but no blames anyway.
19:18
To give an example, if you have def foobar(x): return maath.sqrt(2) + math.pi, and foobar doesn't get called until an hour into your program, then Python won't tell you there's anything wrong until an hour in. Compare to a stricter language, likely one with strong typing, which will refuse to compile until you fix that maath typo
I wonder if the tool black would complain, too.
jrh
jrh
@vaultah PEP8 talks about packages needing to have dashes (e.g., airplane-ml) but modules should use underscores (e.g., airplane_ml). It turns out that this is a lot more than just a suggestion though. You are forced to use dashes in the package names because PyPI will normalize underscores to dashes at the last minute, and you are forced to use underscores for the module names because you can't use dashes in identifiers
That brings about the pattern where users install airplane-ml and import airplane_ml, which... is not that big of a deal, honestly, but I kinda wish they went the opposite route and forced underscores in package names, then you could install and import airplane_ml. IIRC the BFDL's solution for that is "just have one word package names and don't use dashes", which leads to well... expertsexchange = "experts-exchange" or "expert s...." (something I dunno if I should say in chat)
`black` doesn't care about mistyped modules, but pylint does:
test.py:5:11: E0602: Undefined variable 'maath' (undefined-variable)
test.py:4:11: W0613: Unused argument 'x' (unused-argument)
Okay, I understand now but I don't agree :P
jrh
jrh
Interesting, so you like projects like 'poetry' that have names that don't describe what the project does at all?
Yeah. For example, I like BeautifulSoup
19:32
I do not think that package names must exactly describe what it is they do
jrh
jrh
Fair enough, I like C#'s verbose dlls personally, MyLibrary.Networking.dll or whatever
I also don't mind installing django-dynamic-fixture and importing it via import ddf, for example. It seems logical to me that package name can differ from the name of the module that gets installed
jrh
jrh
though sometimes libraries in C# also went a little overboard and you ended up with MyCompany.MyDepartment.MyFramework.MyLibrary.TCP.Networking.Classes
Proposal: projects don't get to have names anymore, they all just get their own GUID
Zero ambiguity, perfect consistency
jrh
jrh
@vaultah For a package that does one thing and one thing only though, it doesn't make a lot of sense. Not everything's got 8 modules to import.
that's a pretty minor nitpick though honestly
19:44
is there a way to fill datetimes in a pandas dataframe? I know there is a resample('H'), but in only works with middle rows, I need allday filled with 0

2022-02-10 08:00:00+00:00 20.0
2022-02-10 09:00:00+00:00 0.0
2022-02-10 10:00:00+00:00 20.0
perhaps just create a datetime df with all day and do a left join with your actual data
That will totally break the solution I gave earlier
Unless you're layering it on top, I guess. I'm kinda getting the sense that you have a scattergun to try get what you really want
jrh
jrh
I guess I'll have to try the Pipenv mailing list for the python interpreter path thing. Thanks anyway!
@roganjosh I think I'm ok, now I just want to fill with 0's in order to chart the data
You can use a resample and an interpolation like I did here
Although, maybe interpolation won't give you the zero values. Hmm
20:01
resampling doesnt work here as I need to fill the whole day, not just the middle rows
Please give me an MCVE. I converted your first post into actually-runnable code. I'm not prepared to do it a second time. I want something I can copy/paste and run
We're helping you here. The onus shouldn't be on us to build the examples to test. Indeed, just building the example gives you something to test with and maybe you'll find it yourself
yeah, I know, at first I was asking if someone know the method or the concept i need.
And now?
I'm trying the idea of @ParitoshSingh doing a left join, but I'm slow :)
None of us are in a rush :) Please take the time to formulate the issue and give us something to run. You'll find that it'll put you in a much better position to get answers
20:13
recbg, folks!
@ParitoshSingh why create a new dataframe and join instead of reindex(pd.date_range('2022-02-10', periods=24, freq='H')).fillna(0) to the required index?
20:28
Just tried the reindex, doesnt work as I assumed
https://dpaste.org/MGyF
sorry, it works, the head() method only showed some....blame me :)
well, actually not, the data is always 0 :)
I need a rest
20:47
It was because of timezones...working example at: dpaste.org/8Kh8
Thanks to all involved, this is enough for today for me :)
Anonymous
21:45
How to I reverse this, so I don't need the "not"?

if not (int(PAGES[1]/2) <= index <= int(PAGES[0]/2)):
Anonymous
It's a range of pages, for example page 20 -> page 30
if int(PAGES[1]/2 > index or index > int(PAGES[0]/2)):
Anonymous
I meant to write this:

if not int(PAGES[0]/2) <= index <= int(PAGES[1]/2):
Anonymous
But I guess your code will work! :D
How could it be any different? You have exclusive ranges (going to infinity)
21:50
IMHO the version with not is more readable, so I'd keep your original code
Anonymous
Yeah, I'll keep the not
23:56
cabbage
I answered a question within the last 24 hours, what an achievement

« first day (4135 days earlier)      last day (1037 days later) »