« first day (4493 days earlier)      last day (438 days later) » 

2:26 AM
Question on NP and axis.. I have 120 images that are each 512x512 pixels in size
images.shape # (512, 512, 120)
I want to get the max value for each of the 120 images. But, when I change the axis in image.max I don't get the right size
images.max(axis=0).shape # (512, 120)
images.max(axis=1).shape # (512, 120)
images.max(axis=2).shape # (512, 512)
Is there a way to get the max per 512x512 image? Of course I could just loop over it and get the max but that doesn't seem efficient
[images[:,:,frame].max() for frame in range(0,120)] # would work, but not using NP efficiently?
 
 
4 hours later…
6:19 AM
I was just skimming the wiki and found this page listing which Python version a particular feature was introduced. I was going to add a link to my page that has text search for changes in Python versions 3.7-3.11, but it seems I don't have sufficient privs.
 
 
2 hours later…
8:41 AM
Good cabbage everyone
 
9:34 AM
How's the Eternal September treating everyone?
 
9:51 AM
@MitchellvanZuylen try images.max(axis=(0, 1)). Side note: you'd probably want to have the batch dimension first (on construction) for performance unless your array is F-contiguous.
 
@OldTinfoil So-so. For the last few days, I've constantly been feeling tired and hungry. Got some kind of illness coming up, I guess? Other than that though, I have no complaints
 
10:47 AM
@OldTinfoil it's September already?
 
== English == === Etymology === Before the Internet became mainstream in the mid-1990s, Usenet was largely restricted to colleges and universities, meaning that September (the start of the academic year) represented the largest annual influx of new users. Around 1993, commercial ISPs began offering Usenet access to their userbases, leading to a large amount of new posters with little idea of netiquette joining year-round. From the perspective of experienced Usenet users, the influx of new users in September 1993 never ended. === Proper noun === Eternal September (Internet slang, histo...
 
11:06 AM
@Aqua4 Yeah, just showing my age here
@Aran-Fey Sorry to hear that man. Here's hoping its all minor (The one good thing about the covid years is that I was never healthier)
 
hehe, I see...
 
11:20 AM
And here I thought it meant "winter"/"cold weather"
 
how to handle overthinking ?
 
11:36 AM
I'm an expert in overthinking! Which means I'd also like to know the answer
 
11:50 AM
practice, practice, practice
 
@matszwecja what to practice?
 
whatever you are overthinking about
 
take a deep breath in, hold, take deep breath out ....
 
12:51 PM
Overthinking can be caused by a desire to find a perfect solution. But it is written: perfect is the enemy of the good. You don't need to invent a cool O(log n) algorithm if your existing O(n) solution already works and runs fast enough on sane inputs.
Sometimes it is even possible to compromise on correctness, not just efficiency. Last week I was working on a tool that would take a screenshot of each of my three monitors. I hardcoded in the dimensions and pixel density of the monitors, because it's a huge pain in the butt to get that information from the windows API. So my program will break if I try to use it on any other computer. But that doesn't matter to me.
I think it is useful to have a clear idea of what your goal is. My goal was "get screenshots of the monitors attached to this computer". Then when I started thinking about how to generalize the program to work for all kinds of monitors, it was easy for me to notice that my thinking was outside of the scope of the goal.
(I kept working on it for a while anyway, because I was having fun, but I digress)
 
@Kevin well i am not overthinking about the efficiency of a project but rather doing things the right way, so it can be scaleable and useful in long term. issue is just at present with tight timeline, things seems not right way only just patch after patch to solve the issue at present, and let see futre thing at that time. all i prefer is keep things simple and more generic
 
"scaleable" -- yes, this seems to be a common one. I've seen quite a few people looking to design a website that will probably get a hundred visitors a year, and they ask questions about handling 100,000 simultaneous visitors.
 
Premature optimisation is the devil
 
as an example, in fintech lets say a generic order system, where basic order record should be in one place for all product, but in my case every product has it's own order system with single table containing all data in one single row (there are empty fields also and offline sale data is inconsitant)
, currently records are low and system usage is less, so things are douable, but now if order placing is increase 10x or 100x then Boom, for every record fetching new session is made and so on and so on .. so this make me think a lot
@OldTinfoil well not into optimization part yet, just working for 10x load
 
Do you know exactly what the 10x load requirements will look like?
 
1:06 PM
I think there is an art to choosing a design that works for the short-term goal, but can be easily extended later to satisfy new requirements that will come up later. This is a very challenging part of the job.
 
^ This. Solve the actual problem in front of you. Test it. Document it. Make it available to stakeholders.
 
Does the 10x or 100x traffic really need to be handled by the same system? It can be viable to allocate 30% of time to a small prototype and reserve 70% of time for a follow up system, instead of trying to go for an out-of-the-box solution at 100% of time.
 
@OldTinfoil 1000 new order transaction to 10000
 
In my screenshot program, I put the dimensions of my monitors in a constant, defined at the top of the file. Just in case I do decide that I want it to work on other computers. If I was 100% adamant about supporting exactly and only my current setup, I could have easily hardcoded the values inline.
 
@sahasrara62 Cool, so what's the CPU/RAM/disk usage for 1000 look like? Will this usage be between certain hours, will there be bottlenecks for users etc?
 
1:14 PM
@OldTinfoil for exisiting one, 0 test, no documentation, one who develope knows it, fintech field is new to me, so a lot of rules which not documented in firm, can't modify the records to keep atomicity
 
The program still only works on my computer, and I would need to do substantial work to extend it, but there's a little bit of groundwork there.
 
@sahasrara62 So the problem in front of you is that it's not documented and you don't know it. Solve that problem first
 
@OldTinfoil ec2, dont know exact specification, i have asked the people to do documentation, but got refused by saying "will increase work", system i am familiar now, just documentation regarding business logic, what a product and archecture, plus no code review
 
Right - so if you don't know, all you can do is to overthink it because there is no lower bound to say "this is good, ticks all the boxes needed by stakeholders". Therein is the problem
Personally, when I catch myself overthinking I know I need to narrow the scope of what I'm working on because the edges/API/"outside edge" of my system is indescribably fuzzy.
 
Fuzzy APIs is familiar territory for me. In such cases, I try to observe the behavior of the system and make reasonable guesses about how it works. I accept the near-inevitability that v1.0 of my program will crash when it trips over something I wasn't aware of. I don't feel guilty or foolish when that happens. It's a happy occasion -- now I can improve the program, and my understanding of the system.
Of course, this approach may not be appropriate, depending on your industry. I can afford to have daily crashes in production, because my users will just shrug and say "I'll come back tomorrow". If you're in fintech, maybe a crash in production will lose your company a million dollars.
 
1:28 PM
@Kevin IT's a startup, but yeah crash/latency/wrong result will make bad impact on us
 
And in that case, it's more important for them to have fully described the problem you need to fix / task that needs to be taken / etc. You're a programmer, you don't know the business logic (necessarily, you might know the business logic for all I know)
If they refuse to give you one, throw your own one together so that you can point to it and say, "you signed off on this. This is what I was attempting to accomplish and I have succeeded. I am mighty"
For one project, all I have is a hastily scribbled a4. When my (annoying) stakeholder complains about a weird edge case that I "should have known about", I point to the a4 I have on the wall and tell him that I designed exactly to spec and if he wants it to be "bomb-proof", he needs to provide an insight into the issues we are likely to face
 
@OldTinfoil yeah this is happening this way for now, but applying patches to patches if something went wrong feels unethical
 
Okay, be back in a bit. Meeting time
 
It's not unethical if that's what the business asked for. They wanted code that satisfies use cases A and B. You gave it to them. Now they want to satisfy use case C. You'll give that to them. If they ask for A and B and then blame you when the result doesn't satisfy A, B, C, and D, then it's them that is acting unethical.
Now, choosing a design that doesn't become a huge mess when you add C and D and E to it in rapid succession... That's a whole other challenge
 
chosing design is becoming mess and doing these all A, B,C,D in samll time frame and makeing it in production live become a mess for me now,
 
1:43 PM
Relatable ;_;
 
1:54 PM
Speaking of messes, I'm porting some batch scripts to powershell, and I could solve this one pesky encoding issue by pushing back some of the work into batch, within the powershell script
 
 
3 hours later…
4:54 PM
i save stuff i do with my program by pickling a list of objects, and unpickling it whenever I start the program again
but sometimes I make very small changes to the parent class of theses objects
is there any generalized method for dealing with this event?
 
the general approach is: don't depend on pickling, instead design a data format that describes the data you actually care about
this is still not foolproof, but nothing is
 
ok i see, so I should write some sort of outputter that saves the state of my program and an interpreter that can build objects from this output, right?
 
5:10 PM
Pretty much
Another approach is to write a migration tool that takes a list of objects from the old version, and converts them to a list of objects in the new version.
 
also, cabbage to ya'll
do we even use the salad language around here any more?
 
I've been known to lob a tomato and/or yam
 
5:41 PM
@Code-Apprentice Cabbage! (there, see?)
 
6:07 PM
Okay, here's something truly novel: stackoverflow.com/questions/75339464
 
hello
 
6:23 PM
duplicate, now that it's been cleared up; see comments stackoverflow.com/questions/75338765
 
7:03 PM
@PaulMcG \o/
 
7:37 PM
any clue why pdb is raising an exception, while running the program normally doesn't?
 
pdb must be executing code that the normal program isn't
 
hello
has anyone worked with celery and supervisor with django
 
Greetings
No
 
7:53 PM
I can't get it to work for hours now
 
Are you getting an error message?
 
 
2 hours later…
10:11 PM
Is it safe to raise the same exception instance twice?
 
 
1 hour later…
11:13 PM
@Aran-Fey in what situations, and "safe" how?
In except and finally? And what could go wrong?
 
Basically I ask because I don't know how tracebacks work. At what point does the exception get the call stack associated with it? If I have two different raise statements raising the same exception instance, will I get an incorrect stack trace?
 
You mean creating exc = ValueError('potato') and passing that around, with raise exc in, say, a different function?
I'll be honest: I have no idea, but I'd be super surprised if this was bound to definition time. The magic has to be due to raise. That would explain why all the traceback.print_exc() etc. stuff only work when there's an active exception being handled etc.
I'm not sure how reraising an exception behaves though
 
I have a class and the error is part of the object's state. Once an error happened, all further calls will raise the same error again
def read(self, size: int = -1) -> bytes:
    if self._error is not None:
        raise self._error

    data = self._process.stdout.read(size)

    if size < 0 or not data:
        self._wait_for_process_to_exit()

        if self._error is not None:
            raise self._error

    return data
 
you keep doing weird stuff
 
That's me!
 
11:31 PM
so you're reusing your errors? Nice
 
Errors don't grow on trees after all
 
I guess this is useful in a threading setup. If one thread encounter an error that the other thread is likely to encounter down the line, caching it or reraising it could somehow be an improvement? I don't know on which levels, though (verbosity?)
 
> This function returns the old-style representation of the handled exception. If an exception e is currently handled (so exception() would return e), exc_info() returns the tuple (type(e), e, e.__traceback__). That is, a tuple containing the type of the exception (a subclass of BaseException), the exception itself, and a traceback object which typically encapsulates the call stack at the point where the exception last occurred.
[...]
Changed in version 3.11: The type and traceback fields are now derived from the value (the exception instance), so when an exception is modified while it is b
Nothing conclusive, but this smells like the exception knows about its traceback, but at the same time it has no issues updating that info when reraised.
 
Yeeaaahh, modifying an exception sounds way more crazy than what I'm doing
 
Can't you just test this by creating an exception and letting it be raised and caught from two different functions?
or are you worried that you'd miss something
@Aran-Fey I bet the modifying part has to do with exception groups
 
11:41 PM
That, plus I figured it's an interesting topic to talk about ¯\_(ツ)_/¯
Exception groups were added in 3.11? That would explain the changed behavior, then, yeah
 
yup
> The add_note() method is added to BaseException. It can be used to enrich exceptions with context information that is not available at the time when the exception is raised. The added notes appear in the default traceback.
 
funny, I was about to mention this too. related: stackoverflow.com/a/75102505/12349101
 
> Created: 20-Dec-2021
This is what happens when you write PEPs in the christmas spirit...
 
Turns out that re-raising an exception makes its stack trace grow
>>> raise err
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <module>
  [Previous line repeated 4 more times]
 
11:49 PM
I guess that's why some people just modify the exception instead
 

« first day (4493 days earlier)      last day (438 days later) »