« first day (3900 days earlier)      last day (1031 days later) » 

3:06 AM
cbg
 
3:27 AM
whats the best way to count the number of 15 minutes intervals in a hour,between two 24 hour times?
where the 15 minutes intervals can only start form 00,15,30 or 45
 
3:59 AM
@AndrasDeak sorry for the late response! thank you so much, sounds logic (I'm new into this). for some reason I'm getting an error, probably an overlook on the array edge as you mention maybe (?) will look deeper into it. thaanks
@MikeDriscoll thank you! usually I find pillow very useful! even though haven't been able to figure out how to paste one image centered on the x,y point over another image using pillow, I know I could paste one image over another in a coordinate using pillow but unsure how to center the image on that point
 
 
3 hours later…
6:39 AM
Cabbage, I have a quick question, is it good practice to type annotate every variable declaration in a code or is it enough only at the function definition?
in the following code, should I type annotate line 3 or not
class Stack:
    def __init__(self, size: int = 100):
        self.__stack: list = []
 
7:29 AM
I'm not gonna say you "should", but there are definitely reasons to annotate it
 
ok got it, it just felt like C having to declare variables with a type
 
Usually, I only annotate when the type cannot be inferred (by both humans and type checkers).
In your case, I would annotate it even stronger – it's not clear whether [] is a list[int], a list[str], a list[Frame], or whatever else gets put on the stack.
That it's a list is already apparent.
 
7:45 AM
Technically the type can never be inferred. Maybe anything with a pop() method is valid there, who knows?
 
There is probably some deep, fundamental truth in there. If a function returns a tree but there is no-one there to hear it, did it actually return a tree?
 
 
1 hour later…
9:06 AM
Now I know why quantum computing is necessary. Both returning and not returning a tree.
 
Hello
In PyQt5 i have i QDialog that it's opens with .exec() instead of .show().
I use the exec method, to freeze the function until Dialog is closed.

The problem is that in with this Dialog I may open another QDialog.
The new QDialog is opens but the Dialog focus doesn't change if i click inside the new QDialog.

What can i do?
 
@AndrasDeak Now I need an excuse paper to call dibs on the name "Qee". :/
 
The new QDialog is open with exec() method too.
 
9:29 AM
cbg
 
I can't reproduce the issue with a minimal reproducable example
 
@ChrisP then your example is not reproducible
try putting back things until it breaks
 
Ok, i have found it.
 
great
 
In the second QDialog i used show() instead of exec()
 
 
1 hour later…
10:58 AM
and this is why MCVEs are great
 
11:44 AM
@MisterMiyagi thank you, this makes me understanding the need for typing a bit more
also I am not sure if anyone here remembers my earlier question which had a raise and return in a function, the answer according to my professor was Union[NoReturn, str], just wanted to let you guys now :)
 
 
3 hours later…
2:16 PM
@Alice Just let me say... Your professor is wrong.
 
this is why I stay away from typing
 
2:46 PM
in libraries typing is great because it lets IDEs and editors provide much more useful autocompletion
 
In this case, I'd say the issue is with the function, not the typing.
 
there is a SO question if I understand this correctly stackoverflow.com/questions/44282268/…
 
Come to think of it, combining a type hint to say "a function never returns" with a return type hint is kind of wicked.
 
what she mentioned does not throw a mypy error though for the code in the question Union[NoReturn, bool]
 
But there's no reason to pick Union[NoReturn, bool] over bool. It doesn't add any information.
Any function can throw an exception. What are you gonna do, add a Union[NoReturn, everywhere?
 
2:56 PM
I can never wrap my head around typing, let alone exceptions in them
but it is really useful as pointed out in libraries, but I only use libraries not write them ;)
 
 
1 hour later…
4:02 PM
hi everyone, can anyone help me with this? pastebin.com/U6EjuF29
 
if you are doing this for your job, your job is already a lot cooler than mine
 
knee jerk reaction: how big is your real df? you could probably just iterate and do a simple solution if it's small
 
its not that small :( (around 1.5 M rows) @ParitoshSingh
 
i think the problem is that your output essentially seems sequential in nature. i can't think of a clean way to vectorize this unless you're okay with binning into fixed frequency intervals instead, but that would give incorrect answers for situations where a user opened the app at 3 minutes in, and say, 7 minutes in. (a 5 minute frequency binning would count this as 2 separate logins if the bins started at 0 so to speak)
 
4:24 PM
Its ok if the final order of user ids are not as I have shown in that MCVE @ParitoshSingh
as long as the correct number is returned thats fine
 
yeah i just meant you probably need to iterate for this
 
yeah I guess thats ok unless someone has a better solution @ParitoshSingh
 
something like this should do the trick.
 
thanks a lot!, this was one hell of a problem to solve :) @ParitoshSingh
May I also ask how I can get as stronger as you in solving these types of problems?
 
4:39 PM
hm..i suppose one tip i can give: don't worry about efficiency upfront for problems that seem tricky. solve it first, then deal with it later
 
great, thanks!
 
Is there any problem with me or this documentation supposed to be for python, is actually in c++
 
laurel
haven't you heard, this is the new update of python, just released yesterday, pythonC++, they updated their docs real quick
 
Damn I missed it :P
Py++ seemed better
 
4:58 PM
what is this process called? [1, 1, 1, 2, 2, 1, 2, 2] -> [1, 2, 1, 2], grouping similar values
 
grouping sounds fine to me
(take a look at itertools groupby if you need to do this)
 
yeah I am looking at a pandas way for what you solved
 
ah. you can make a key that works with a pandas groupby if you wanted to use a pandas groupby
say, using a diff and a cumsum
 
will look into that
what I essentially want is [g for g, v in groupby([1, 1, 1, 2, 2, 1, 2, 2])] but without the loop
 
5:17 PM
then you dont need the cumsum either, just the diff would do
sec, i'll give an example
import pandas as pd

s = pd.Series([1, 1, 1, 2, 2, 1, 2, 2] )

idx = (s.diff().fillna(1) != 0) # if you wanted to do an actual pandas groupby, this should be fillna(0)
s[idx]
 
let me try this one min
I have no idea what I just cargo culted
test_df.groupby(test_df['user_id'])['app_open_time'].apply(lambda x:x.diff().fillna(pd.Timedelta(seconds=0)).dt.seconds.ne(60 * 5).sum()) but seems to give the same output
 
cabbage
 
you're doing a ne against 300. you'll find this doesn't logically solve the problem, just happens to give the right answer for this test case.
 
I just added in what you said and I am not sure if this just happens to work or not
300 seconds is 5 minutes right?
 
5:27 PM
yes. it's the ne that's the issue. it's just a simple comparison against 300
 
I guess ne does a vectorized companion
 
it does. but what is it comparing?
 
x.diff().fillna(pd.Timedelta(seconds=0)).dt.seconds series?
 
what is ne
 
not equal?
 
5:28 PM
yep.
 
ahh
 
so your code is asking "if the diff is not equal to 300"
 
got it
well I will stop at this, if you want to take a shot, one of my previous attempt wa using x.diff().fillna(pd.Timedelta(seconds=0)).dt.seconds.le(60*5) to get values less than 300
 
the problem with comparing against 300 is that 300 is the "offset" from the login, it doesn't make sense to just compare against it directly in any manner.
 
yeah, would need a df for that, but too late to think laurel
 
 
2 hours later…
7:06 PM
recbg
 
 
4 hours later…
11:20 PM
Habanero!!!
I wonder why numpy.zeros and Mat::zeros have different width-height format. It is confusing when I have to translate one code to the other one as follows.
img = numpy.zeros((3, 2), dtype=numpy.uint8)
# Mat img = Mat::zeros(Size(2,3), CV_8U);
 
What is Mat? Eigen?
 
Mat is the opencv Matrix
 
ah
Are you sure those two lines correspond to one another?
 
I don't understand why didn't python just wrap the existing Mat rather than using numpy.
 
The main reason for such transposes is row-major vs. column-major memory layout, but C and numpy both use row-major by default (insofar as C has multidimensional arrays).
@TheShortestMustacheTheorem probably because the existing Mat doesn't exist
 
11:25 PM
@AndrasDeak OpenCV code base is in C++ I think. The python version came later.
 
the only convenient thing about openCV is that it uses numpy arrays
 
@AndrasDeak Sorry, numpy is not a wrapper of some C++ libraries?
 
I found a youtube video in which someone displayed a static image with a while loop as follows. I wonder what is the benefit of this technique.
import cv2 as cv
img = cv.imread("family.jpg")

cv.namedWindow("img", cv.WINDOW_NORMAL)
while True:
    cv.imshow("img", img)
    key = cv.waitKey(1)
    if key == ord("x") or key == ord("X"):
        break
 
Are you sure they know what they are doing?
 
11:31 PM
@AndrasDeak I don't know.
But there is a good reason for this, to avoid too many global variables when using trackbar for example.
I have an example with C++ as follows.
 
no
this is the python room
 
The python version has not been translated yet. :-)
 
potential springs to life wherever we look
 
there is nothing new under the sun
Thank you very much Andras Deak. I am leaving for work. :-)
 

« first day (3900 days earlier)      last day (1031 days later) »