« first day (3902 days earlier)      last day (1029 days later) » 
01:00 - 23:0023:00 - 00:00

1:27 AM
Cabbage folks!
A[numpy.where(B)] = 0 will set all elements of A that correspond to elements of B that are non-zero to zero.
How about the complement, setting all elements of A that correspond to elements of B that are zero to zero?
A[numpy.where(B)] = 0 will set all elements of A that correspond to non-zero elements of B to zero.
How about the complement, setting all elements of A that correspond to zero elements of B to zero?
Sorry for double posting, the first version seem to be too complicated.
 
 
3 hours later…
4:05 AM
A[numpy.where(B == 0)] = 0 should work. Remember, it's just using booleans to figure out where to set the value. you could even write A[B == 0] = 0 and that should work i believe (untested)
 
@ParitoshSingh: OK. THank you!
 
4:20 AM
@ParitoshSingh: Are you familiar with OPENCV?
Is there any simpler method for the following parts?
############### MASK ###############
limit = 64  # more than this limit converted to 1
mask = cv.cvtColor(logo, cv.COLOR_BGR2GRAY)
mask = cv.threshold(mask, limit, 255, cv.THRESH_BINARY)[1]


############### TRIMMING LOGO ###############
logo[np.where(mask == 0)] = 0

############### TRIMMING ROI ###############
roi[np.where(mask != 0)] = 0

############### ATTACHING LOGO TO ROI ###############
roi += logo
 
Hey all - I know I've been very absent of late - wanted to drop in to let y'all know I signed a contract today, and say thanks, as this room has played a part in that happening. :)
11
 
4:56 AM
that's awesome, congrats!
 
5:32 AM
pineapple toonarmycaptain
 
6:10 AM
@TheShortestMustacheTheorem you don't need np.where. logo[mask == 0] = 0 and roi[mask != 0] = 0 is sufficient. But I think this would be sufficient for your needs: roi[mask != 0] = logo[mask != 0]
in straight opencv a common approach would be using bitwise operations: cv.bitwise_or(cv.bitwise_and(roi, mask), cv.bitwise_and(logo, cv.bitwise_not(mask)))
 
7:03 AM
@alkasm Excellent info. Thank you very much!!!!!
@alkasm: Referring to my code above, trimming logo with logo[mask==0]=0 is needed. If we don't do this trimming, there will be a chance of wrap around overflow in roi+=logo whenever the threshold limit is greater than 1.
 
Cabbage all
 
Cabbage !!!!!!!
 
@TheShortestMustacheTheorem what your nick reference
 
@XavierCombelle No reference, but pointer. :-)
Nothing. It is self-made theorem.
Is there any difference between the following?
    # A
    location = mask != 0
    roi[location] = logo[location]

    # B
    # roi[mask != 0] = logo[mask != 0]
I guess A is more efficient, right?
 
7:18 AM
yup
 
Or python is smart enough to cache the first mask!=0 in B.
 
Generally, it's incorrect to cache that. So Python doesn't.
 
OK. I will always use A. Thank you!
 
cbg-ning
 
7:40 AM
cbg @AndyK
 
@XavierCombelle o\
 
8:27 AM
cbg
 
cbg
 
cbg
@toonarmycaptain nice to hear, best of luck! =)
 
9:09 AM
cbg
 
cbg, I have a time string like '2021-06-23T12:00:00.000+0000' I want to get the time in this, how can I do that? datetime.fromisoformat('2021-06-23T12:00:00.000+0000').time() does not work ValueError: Invalid isoformat string
doing [:-5] works but I am not sure if that is right way
 
You can always use datetime.strptime for custom formats.
 
9:25 AM
thank you '%Y-%m-%dT%H:%M:%S.%f%z' worked with strptime
took me a while to realise that the T was actually supposed to be T
 
the T already implies +0000; it works if you trim that off
>>> datetime.fromisoformat('2021-06-23T12:00:00.000')
datetime.datetime(2021, 6, 23, 12, 0)
 
so I was right in doing [:-5] then :/, I have to understand datetime more
 
Cbg
Hey does somebody know if djangos orm has a cache? It shows me results which doesn't show up in the database
ok, nvm I looked at the auto id instead of my id
 
9:48 AM
I just saw an accepted answer with -38 votes 0_o
 
@tripleee however
>>> datetime.fromisoformat('2021-06-23\N{pile of poo}12:00:00.000')
datetime.datetime(2021, 6, 23, 12, 0)
 
10:06 AM
@AndrasDeak that's valuable! (-:
 
Undocumented file format adventures continue. I'm looking at a table which might be "data types" or perhaps "file types". One of the columns of the table contains binary data which I think might be each type's name, but encoded or encrypted or hashed in some way.
Each value in the column is either 19 or 35 bytes long, so they're probably a 3 byte header plus a 2^(4 or 5) payload.
Does encrypted data usually have a roughly even distribution of byte values? Because I don't have that here. If I put all the payloads into a counter, then frequencies of values range from 28 occurrences to 6.
 
10:22 AM
depends on the encryption; a good encryption algorithm would ensure that values are evenly distributed on average but if the sample size is small, you can't really rely on that
 
Makes sense yeah
 
by quick glance that doesn't look encrypted at all though, there seem to be structured patterns there
 
The first 3 bytes are definitely structured. The 35 byte rows have exactly one occurrence of each of 00 00 00 through 00 74 00.
 
So when you found that the file format you were reverse-engineering had a spec, you went ahead and found another file format that has no spec? :D
 
I basically went looking for trouble, yes
 
10:33 AM
How did you even identify the sections of 19/35 bytes?
 
Hello
Anyone now a good way to conver "[1,2,3]" to [1,2,3]?
 
hello
@ChrisP ast.literal_eval
 
Thanks
 
I knew I was looking at a table because the entire file format up until that point was a sequence of tables. Every table starts with a 32 bit int indicating the number of rows. Usually I could guess the length of a table row by looking for patterns of repeating values. Since the first ten rows here start with 00 FF FF, that was a good lead. It took a while to figure out that some rows have 16 more bytes than others.
 
I see
 
10:43 AM
Usually rows of variable width will start with a 32 bit int indicating its length, or end with a null byte, but neither of those appear to be the case here
I guess it's not "truly" dynamic since it's only one of two possible widths. As far as I know.
 
11:02 AM
Ah, I found a DenverCoder9 who was looking into this same format. He thinks it's a hash.
 
11:18 AM
@Kevin what are these files ?
@ChrisP I would check json
 
There's no extension name, but they're probably Unity game engine asset files.
Parsers exist, in varying levels of completeness and version compatibility. Not that I let that kind of thing get in the way of a good wheel-reinventing.
The DenverCoder I spoke of is github.com/HearthSim/UnityPack/tree/…
 
If it helps, there's also UnityEx
 
My objectives are 35% "play around with byte deserialization techniques" and 65% "actually get useful data out of this file" so I will eventually hit a point where I'm willing to use an external tool
 
 
2 hours later…
1:12 PM
cbg
I know theres most likely nothing I can do but hope server end works at another point but just incase anybody here knows a solution when receiving response_code 502 from request, is there any way that you can solve this?
 
I there anyone here to answer this question?
 
1:33 PM
@NirmaniWarakaulla I guess that's a no
 
Hello I have created a short url function which renders the short url like tinyurl to django templates. But when I copy and paste it on the address bar , it shows only slug part, and gives an error ServerNotFound at my app.
 
2:16 PM
is there an "in memory tempfile.TemporaryDirectory"? as in how one can use io.BytesIO to have a in memory file like object
 
BytesIO is already pretty file-like -- you can call read and write and seek on it, and such. Is there something in particular you want it to do, that it doesn't do?
 
TemporaryDirectory needs to allow you to create files and directories within it. Since BytesIO functions as an in-memory file, I'd recommend using a dictionary to be the 'in-memory' directory
 
ok, so I am extracting a zip file I download using requests to a temp directory, tempfile.TemporaryDirectory does what I want, but I can still open as long as the code is still within the context of with, so I am just looking if I can get away from that file IO part
@inspectorG4dget this is new to me, so keys as file names and values as the bytes?
but I dont think zipfile.ZipFile would let me do that
 
If you want to skip the fileIO part, then delete your code that opens a file in a temp directory, and replace it with a BytesIO.
 
@Kevin that is the context, hope that was clear
 
2:25 PM
I'm starting to smell an XY problem. What are you actually trying to do? You download a zip file, unzip it, read the contents of the unzip'd files... then?
 
I suspect I am misunderstanding the problem because the solution seems pretty straightforward to me
 
basically this with ZipFile(BytesIO(response.content)) as zfile, TemporaryDirectory() as tdir: zfile.extractall(tdir)
so I want to work with the files that go in tdir, am I making sense now?
 
Why extract the files at all if you don't need them to exist on disk? Just work directly with the ZipFile object
An in-memory zip file is probably as close to an in-memory directory as you can get
 
ok I didnt know I could directly work with files on zip
 
I think ZipFile.read is good for that
 
2:27 PM
Check out ZipFile.open
 
anyone have a good ansible resource for a n00b like me? I'm trying to populate a terraform file with creds from a config file, for which I'm told I need ansible
 
ok that should do it, thanks guys
 
in other news: how can I dark theme my chat?
 
I use an extension called Dark Reader, works on any site
 
ahh. Thanks
 
2:30 PM
I posted my custom dark style just yesterday, if you want to try it out
23 hours ago, by Aran-Fey
Wait, that's the outdated version. Latest version here
 
is there a screenshot of your dark mode?
 
i.stack.imgur.com/IWMgL.png mine does that ugly thing for my messages
 
Hmm, weird. Did you disable Dark Reader?
 
I mean that was with Dark Reader, not yours, sorry, my bad
 
2:37 PM
Ah, I see
 
silly question: how does one execute this userCSS on firefox?
 
@inspectorG4dget start from Aran's first link
it says "install as usercss"
there was some discussion afterward, read that too in case you're following my mistakes
 
@inspectorG4dget Install the Stylus extension, then follow these instructions
Don't make it obvious though. If they notice you tailing them, abort mission and proceed with plan B.
 
follow up question (instructions don't mention this): do I want to append or overwrite the style?
 
2:52 PM
I think you did something wrong. You clicked "import", right? That's for normal CSS styles; for userCSS you just paste it into the editor
> If you see a "Mozilla Format" section in the side bar, the editor is in the wrong mode! To fix this, open the editor from the manager; Click the "Back to manage" button, then read the next step on how to open the editor from the manager page.
^ That's your problem, I think
 
I didn't click on Import. I pasted it into that editor :S
 
Huh. Well, if the editor was empty beforehand it won't matter, but go with "overwrite" just in case I guess
 
aha! It works now. I'm sure I did something else wrong before, but it's fixed now (I had to delete the entry and restart from scratch). Thanks for the help, folks
 
3:19 PM
What a gem on todays HNQ: physics.stackexchange.com/questions/646858/… So the pair/antipair picture I thought of which didn't make sense at all is finally(to me) revealed to be wrong. The tunneling outside is well only slightly more understandable but at least now I have something new to think about
 
Interesting, it's the opposite for me. The pair/antipair explanation is more intuitive to me than the tunneling explanation.
 
No, the thing that bugged me the most is point 3 here: forbes.com/sites/startswithabang/2020/07/09/…
 
Blocked :-(
What I like about the wrong(?) conventional explanation is that it doesn't require any knowledge of quantum physics apart from "sometimes, quantum magic causes two opposite particles to manifest out of nothingness"
 
Yeah, and there are so many ads, it's barely worth it
that every quantum of emitted radiation must have a tremendous amount of energy: enough to escape from almost, but not quite, being swallowed by the black hole.
that's the disturbing problem with that analogy
I'm sure there is an equivalent disturbing problem with the tunneling example, but it's less evident for now :P
 
3:35 PM
We're talking about photons specifically here, right? I don't see how more energy helps it escape, since it will be traveling at c either way.
Surely a red photon and a blue photon draw the same curve through spacetime... Right?
(confidence: 60%)
 
@Kevin they do
but at that kind of space-time curvature a photon's "colour" is hardly meaningful
 
Sounds like the underlying physics is advanced enough that handwaving (or lies-to-children, if you will) can't give a description that's both palatable and accurate.
 
My gut says that I can't easily construct a classical model that matches what happens, because the quantum wossname is a very important factor that must not be neglected
Dang, beaten
 
I could see both "assume quantum gravity" and "radioactive decay of a black hole" on that Q&A which is a bit suspicious to me.
@Kevin it's not just the quantum. It's also the gravity.
It's not that terrible to explain to people about particles tunnelling across finite potential barriers. And that's very quantum.
Then again the real explanation there is "solve the Schrödinger equations and you'll see it clear as day", and the handwaving would be "well particles are a bit fuzzy so they can fuzz over the wall" which is perhaps barely more fulfilling than the Hawking radiation situation.
 
3:44 PM
I'm usually pretty well-served by imagining gravity using the "bowling balls on a rubber sheet" simplification. You can even reconcile "light goes in a straight line" and "gravity curves light" if you zoom in far enough
 
For what it's worth physicists have created an analogue of Hawking radiation in non-linear optical media using strong laser pulses. I wonder if some insight can be gained there, assuming the analogy is close enough to be of use.
The top answer on the dupe is more fulfilling physics.stackexchange.com/a/30601/124756
"Bogoliubov transformation" tells me "advanced quantum physics tool that gives you interpretable results but such that can be detached from reality".
For antiferromagnets you can rewrite the Hamiltonian to one that contains freely moving particles, which we think of as "antiferromagnons". They are fun and useful, but hard to tie to the original Hamiltonian, at least in my head.
 
4:17 PM
you can just ignore that last message for convenience
 
Currently four Wikipedia articles deep on the topic of quantum tunneling
 
@Kevin non-zero chance you might skip the rest?
 
The nonzeroiest
I'm willing to let go of all intuition that the universe is made of tiny spheres, but if the replacement is "here, do a lot of calculus", then it's a bad deal for me
en.wikipedia.org/wiki/Wave_function has like a hundred of those tall S'es that indicate integration
 
Ah yeah, the dreaded Meat Hook.
 
cbg
 
4:29 PM
The long boy of doom
 
I made a password manager where the password is stored in a db file, so the issue is that the user can choose any db file, and ofc there wont be the tables that I have created, maybe they could manipulate the table names too, what would be a way to make sure that the db files created within the app will be unique?
TBH, I am using db so that I can use SQL to query and make my life a bit easier.
 
Perhaps the db could contain part of a key that you use to encrypt and decrypt your data. If the user provides a different db, they won't have your key, so it won't de/encrypt your data properly.
I may be misunderstanding the proposed attack vector here
 
Not just the attack, I do not want the users to be able to choose their own made db. Only the db made with the help of the app
 
I am usually reluctant to question top-level requirements, but: why do you want that?
 
@CoolCloud What do you lose when your user does something dumb?
You can easily fingerprint your own DB to prevent against accidental imports of wrong files, but you can never protect against intentionally crafted files made to fool your code. So what are you trying to prevent here?
 
4:36 PM
I want to prevent accidental imports of wrong files
 
I'd say give it a unique file name + extension like cool-password-manager.password_database and be done with it
 
Darn, beaten. I was just about to say: accidental db mixup can be made less likely, but bad guys with sufficient determination can always craft an indistinguishable counterfeit
 
@Aran-Fey Then would I be able to use sqlite with it?
 
Yes, the file name doesn't matter
(and neither does the file extension)
 
I find that this is usually the case for most libraries that handle a specific file format
 
4:38 PM
@Aran-Fey Wow, never knew that, let me try it
But I'm kind of intrigued by the 'fingerprinting' that Andras was talking about
 
It's 2021 and we still have file extensions, like cavemen
 
Nah, I just meant something dumb like adding a field somewhere that identifies your format. Using filenames sounds great.
 
@CoolCloud Why do your users get separate dbs?
 
Okay I'll do it then, thanks :D
@roganjosh Well users can create password databases as they wish
 
I mildly prefer adding a field somewhere over using a meaningful filename, since we just finished talking about how nice it is when libraries don't care about filenames
 
4:41 PM
For what purpose? What is the application?
 
Admittedly, a password manager application isn't a library, so it's a little apples and oranges
 
@CoolCloud "I made a password manager..."?
 
@Kevin I don't think the app will refuse to read a file with the "wrong" extension? As far as I'm concerned, that's purely to help the users tell it apart from other db files
 
But you haven't tracked in what db they can store their password. The design doesn't make sense to me. You could have a single table for stored passwords against a user_id, and have another table that tracks the user_id logged into the password manager
Then you need 1 database, 2 tables, for the whole thing
 
@Aran-Fey Ah, I understand your proposal now. Makes sense.
But thanks to the uncertainty principle, I now have less understanding of my original interpretation of the proposal
 
4:46 PM
one heisenberg turns in a grave
 
[spins quantumly at N/2]
 
@roganjosh What I have right now is also 1 database with 2 tables, but the user can make how much ever database they want
 
No, I mean you, the application owner, can make 1 database with 2 tables that covers all people using your password manager
 
roganjosh is saying your passwords for all users could be stored in one table, eliminating the need for the users having their own databases
 
+1 did a better job than me of explaining the concept :)
 
4:53 PM
this does make me wonder how do other password managers do it. i've never really put much thought to it before
 
Ah well, I have not thought about it. I had very mere idea of how password managers work so I took an example of KeePass and then saw that we can make how much ever databases we want. This is something I might implement in the future updates
 
I completely understand users having their own databases. That's exactly what my GNU pass does.
Even if you have a central DB for some reason you should allow users to export/import, at which point you end up in the same place.
 
I would assume something similar to what I've suggested. I did consider that there was something security-related to splitting them into dbs, but I couldn't think of it
 
Why would I want to store my passwords on your server if I don't have to?
 
So the databases are local but the service is central?
 
4:55 PM
(Emphasis on "I". Many people prefer for password managers to Just Work.)
 
Cool Cloud, question: are you giving your app to the users, or is it expected to be a login type of deal. i think im seeing where the wires got crossed
 
((Until the service becomes non-free one day and you realize that migrating to another service is a lot of pain. Or the remote server is compromised and your passwords leak out.))
 
@ParitoshSingh I am giving the app to the users
 
if you're using keepass style of storage, the app is under the user's direct control, and it cant affect the servers or your system
if the storage is central on your machine/server, then you have to take control of where the databases inherently have to go
 
A login would require a server right? Which I am planning once I get a clear idea of how encryption works and how safe it can be on the server
@ParitoshSingh Yea the app is completely offline
 
4:58 PM
Ah, in that case, ignore what I was saying
 
If it was perhaps based on cloud, then I would just allow them to have a username and then master password and then all the details inside it, like Rogan said
 
@CoolCloud this part no longer makes sense to me then, if i go back and read the original question
if it's local to the user, and they want to overwrite an existing file for some reason, meh, their call. it's their system, right? in either case, i dont see why you want them to be able to modify table names though, but perhaps i haven't envisioned your goal here yet
@AndrasDeak ultimately it's a choice between convenience and security i suppose. i'm happy to see people move to any password manager rather than copying their passwords on every site they access :P
 
cbg
a = np.arange(60).reshape((3,4,5))#multiband raster
b = a[0,:,:] #a single band
c = b > 9
d = a[c] #mask with single band mask, doesn't work
#d = a[np.newaxis, c] #also won't work
I'm struggling. This is simple but not working
need to mask 3D array with 2D boolean array
 
what's the desired output?
 
a where c is true
 
5:09 PM
@ParitoshSingh Well yeah :D
 
but a is bigger than c. do you want c to just repeat to match a?
 
no a has one more axis
c.shape
(4, 5)
a.shape
(3, 4, 5)
 
yes, that's a more refined way of saying its bigger, but it's bigger :P
 
just want to mask on the second and third axis. Conceptually mask a multiband image with booleans the size of a single band. I can do it with np.where but though the fancy numpy indexing could handle this as well
 
I wonder if it would help to solve the problem with one fewer axis? mask a 2d array with a 1d boolean array. Then see if the solution generalizes to more dimensions
 
5:14 PM
Probably
 
knee jerk reaction: i think you're thinking of the problem in a manner that makes it harder to solve. if c was used to make another (3, 4, 5) array you could call it a day.
 
Yes. I want to ultimately do a[c] = (0,0,0) aka a nodata value
 
how about d = a[np.broadcast_to(c, a.shape)]
i didn't understand your last sentence either, sorry. could you explain it or perhaps just make an example of desired output?
 
that makes my d have a funny shape (30,0)
Yes one second
 
yes, d won't retain the shape of the original array because you're fundamentally subsetting it with bools. the fact that in this particular case you chose a subset that "would have" stayed in a nice structured shape is something numpy can't know, so in general numpy flattens on an indexing with a mask
you can always reshape to bring it back to whatever form you desire, but perhaps based on your desired output we could come up with a better way as well
 
5:20 PM
a = np.arange(60).reshape((3,4,5))#multiband raster
yy,xx = np.where(a[0,:,:] > 9)
for (x,y) in zip(xx,yy):
    a[:,y,x] = (0,0,0)
print(a)
This produces desired output but Andras says never use np.where so that's what brought this about
 
ah perfect
out = a.copy()

out[np.broadcast_to(c, out.shape)] = 0
never use np.where? i haven't heard that before, what's the reasoning? @ AD if you're here.
for what it's worth though, never use loops with numpy.
@Dodge could you link to the original conversation for this? was there a reason specified?
 
haha, well a quick search shows Andras has recommended np.where actually but I'll find where he said "anything is better than np.where" or something to that effeect
whats his number for searching chat
found it nm
 
to my knowledge, np.where should be vectorized but i'd love to be corrected if that's not the case.
 
Nov 12 '18 at 23:08, by Andras Deak
np.where is almost never the answer
 
ah okay. different context.
anyways yes, once you make your mask, just broadcast and use it, call it a day.
 
5:28 PM
You're allowed to employ "almost never" techniques if you have expended 99 units of effort looking for a better way
 
@ParitoshSingh Thanks!
 
The measurement of an effort unit is subjective, so you can stop once it feels kind of 99-ey
 
Kevin, getting out of bed feels 99-ey
 
Relatable, this is why my personal projects are barely-constrained chaos
 
anyone here got experience with terraform?
I'm trying to create an aws_db_instance with a security group so that I can access it only from an SSH'd EC2 instance. But I keep getting `InvalidParameterValue: Invalid security group`
 
5:40 PM
I feel now like I owe the room for helping me. I offer this: "What did the hamburger say when introducing his wife?"
Meet Patty!
 
10/10
whenever i read hamburger i am reminded of that one pink panther scene.
 
@Dodge I love this!
 
6:22 PM
@Dodge how about a[:, c] = 0?
np.broadcast_to is rarely the answer :P
 
ah yep, missed a trick there :P
got railroaded by my own earlier solution
 
What exactly is behind "np.where is rarely the answer"? (Not just in this instance). Is it a case that you could be avoiding reaching into a LAPACK algo or something?
 
No, you could be using masks like normal people
Of course it's largely subjective, but to me np.where has a clumsy API and it often ends up being slower than mask-based alternatives that I find more intuitive. You can also avoid warnings from unused items that way, see e.g. stackoverflow.com/questions/33248254/numpy-select-lazy-version/… (self-plug)
 
That's an interesting example, because it was a few weeks back where I asked about np.divide() to avoid division by zero issues
Which I'd find clearer than inverting masks. I guess it would come down to subjectivism... until I set a timer on it :)
 
I just noticed a bug in that answer, I'll have to fix that
and of course the question is a bit oversimplified
 
6:37 PM
I still find plenty of utility for np.where with things like:
self.route_df['abs_expected_dicrepancy'] = np.where(
        (self.route_df['abs_expected_dicrepancy'] < -1200)
         & (self.route_df['drop_number'] > 1),
        np.roll(self.route_df['abs_expected_dicrepancy'], -1),
        self.route_df['abs_expected_dicrepancy'])
 
yes, because you're used to pandas' bloat :P
there's no need to have 10 expressions on the right-hand side, each of which could raise an exception and you'd be stuck picking it apart to find out which one
it would probably occupy the same amount of lines
 
Yeah, I'm starting to see that
 
i've got an np.where in my code, that picks a variable name based on some criteria. np.where(criteria, name1, name2) kind of deal.
 
The mask approach would still work
 
i suppose i would rewrite it as out = name2.copy(); out[criteria] = name1[criteria] but to me, the np.where looks nicer
 
6:40 PM
I think I need to ruminate on np.where()
 
Although if I time the case in that example, where turns out to be 4 times faster than the mask
similar scaling too
I rarely have to use this pattern and I don't remember the situation in which where was slow. It's also possible that it's been sped up sometime in the past few years.
 
I did ask this here before but I guess the topic got changed, anyway could anyone explain how I would manually compile bootloader binaries stackoverflow.com/a/52054580/13382000
 
@AndrasDeak ~mask presumably takes another pass at the whole array?
 
it does, yes
It's also possible that what I remember was the one-arg form of where. I don't know.
 
In which case, I guess the 4 time speedup could be reduced to creating a single pass at ~mask instead of evaluating it twice in y[~mask] = 1 / x[~mask], and then it'll be 2 times faster for where? That'd reconcile my understanding. I'll test shortly
 
6:47 PM
no
I tried pre-defining ~mask, but that didn't change much.
 
Hmmm
 
but do play around with it
In [381]: def maskey(inp):
     ...:     out = np.empty_like(inp)
     ...:     mask = inp < 0.5  # make it more interesting
     ...:     out[mask] = inp[mask] + 1
     ...:     out[~mask] = 1 / inp[~mask]
     ...:     return out
     ...:
     ...: def wherey(inp):
     ...:     return np.where(inp < 0.5, inp + 1, 1 / inp)
     ...:
     ...: rng = np.random.default_rng()
     ...: inp = rng.random(10000)
     ...:
     ...: assert np.array_equal(wherey(inp), maskey(inp))
     ...: %timeit wherey(inp)
 
Ok, time to put dinner on and then get playing :)
 
If I change inp < 0.5 to inp < 0.001 (which is actually a lot closer to what the asker wanted) the difference comes way down. Which makes sense. The larger the imbalance between mask and ~mask, the more contiguous the "large" case is, and the smaller the "small" case is, so to speak. Whereas where will have to compute both result arrays no matter what.
(where is still faster)
 
Just a question of curiosity: Would anyone here consider a 200GBps network connection without firewall limitations not exceptional?
 
6:59 PM
What do you mean "without firewall limitations"? What's the context? Workplace?
 
"without firewall limitations" means there is no firewall in place between us and the destinations, so anything goes and there is no bottleneck from FW performance.
Context is that I am pondering whether my minions need a reality check on just what they get for free.
 
As an American, I only understand units of metaphorical measurement. How many Grand Theft Auto Fives per second is that?
 
Three nautical galons per square inch cubed, I guess.
 
to me, that's nothing short of a miracle.
actually...not even the speed, the firewall part. i'll take it any time of the day :P
 
Hmm, not bad assuming you're using sidereal hogsheads, rather than solar
 
7:06 PM
(but also the speed. sigh)
 
It doesn't link to the Steam servers, sadly. :(
 
i cant even fathom 200GBps. that's like effectively 200* 1gb movies per second or something
 
Twist: the bandwidth is excellent but the lag is abysmal, because it's TCP by horse-driven-carriage-full-of-SSDs
 
@MisterMiyagi lol, I even missed the G in GBps
 
@Kevin We're past the age of loading tapes on a truck.
 
7:07 PM
Slap the minions with a trout. Then again after a certain point it's hard to make use of that bandwidth.
 
You can get a hundred thousand Grand Theft Autos Five, but none of them will arrive until friday
 
They could try, I don't know, colliding heavy ions at relativistic speeds and livestreaming the data.
 
No one in their right mind would do that... *shifty eyes*
 
Attain absurdly good up/download ratios on p2p file sharing networks
Distributing Linux isos, of course. We would never transmit, say, Grand Theft Auto Five.
 
ofcourse
 
7:12 PM
Okay. If I'm not lurking here in the next days, it's because my trout slapping spree found a glorious end. Tally ho, chaps!
 
@AndrasDeak I mean, we had a livestream of people jumping over a puddle that drew crowds of thousands of viewers in the UK. I guess a livestream of particles colliding could be fun
I assume they rigged up a GoPro in the accelerator. If not; opportunity missed
 
Actually, at least with tokamaks you can do that. It looks pretty neat.
Of course tokamaks are not particle accelerators in the usual sense.
 
I wonder what the pulsation at the bottom was about. It looks like that became unstable and ultimately blew it (if I judge by eye)
 
that looked rather cool
 
@AndrasDeak That's... beautiful!
 
8:06 PM
@toonarmycaptain Awesome, I get the impression that's something you've been working toward for some time. Congrats!!
 
8:51 PM
Indeed, congrats toon :)
 
@Dodge @roganjosh Cheers :)
Yes, quite awhile.
 
A nice hurdle to cross! Did you have anything developer-y in the meantime or is this the big win?
 
 
1 hour later…
10:25 PM
Please help me decide if it is better to split this quesiton in two or not (Results with removed duplicates or not):

https://gist.github.com/qqgg231/ee4a9aa04bdda1f204b531169a89b97f
 
@KarolZlot hello. That's not exactly how you'd ask the questions, right?
 
hello, I am not sure what do you mean by this
 
I don't see how you would split that into 2 questions
 
If you ask your question on the main site like the way it is in that gist, you'll probably get downvoted and closed as "too broad". First comment will be "what have you tried so far?".
 
@TheShortestMustacheTheorem ah, indeed
 
10:31 PM
It might also be unclear to some.
 
Problem is I tried to find solution already, I found similar questions but no the same
 
@KarolZlot Have you considered writing your code, rather than finding an existing solution?
google-driven development will only take you so far
 
@TheShortestMustacheTheorem well, if you look at my code, I don't use +, so it's not necessary I think in my formulation?
 
That would be easy, but I probably won't write most efficient solution. This is my guess.
 
@KarolZlot so write an inefficient solution first
 
10:34 PM
Ok
good idea :)
 
Even rephrasing the question as "This is how I could do this, but I think it might be inefficient. Can I do something better?" should help a lot with the reception of your question
 
Follow-up questions you'll likely get:
1) Does the order of the list elements have to be preserved?
2) What kind of data do your dicts contain? (Is it hashable?)
3) How long are your lists?
 
@AndrasDeak Wow, that's helpful!
 
Questions I'm asking myself: Why the heck won't my code display a progress bar?
 
@Aran-Fey you forgot to iterate the tqdm? :P
it's either something very dumb or something very esoteric
 
10:38 PM
The problem is that there's a lot of stuff happening between the code that's responsible for downloading and the code that's responsible for showing the progress bar
 
Andras gets +1 on divination. The Room 6 Oracle has spoken; it could be anything on the spectrum of the possible
 
It's working fine for normal HTTP downloads with aiohttp, but when I let youtube-dl handle the downloading, no progress bar :|
 
I best go back to the playground because I still work with Futures sorry :/
 
@Aran-Fey hijacked stdout/stderr by youtube-dl?
 
Hmm, interesting idea
If I add a print to the progress reporting code, then it prints out just fine. So that doesn't seem to be it. Looks like I'll have to figure out a reasonable way to step through this multi-threaded and async mess with a debugger
 
10:46 PM
are you using async tqdm?
nevermind, you said aiohttp worked
 
async doesn't really affect tqdm, does it? For multi-threading, I made sure to call tqdm.get_lock()
 
I don't know, I just saw the existence of tqdm.github.io/docs/asyncio
 
Oh, I'm manually updating the bar with bar.n = completed and bar.refresh(), so tqdm doesn't really have to do anything async
 
you monster
 
You'd think a popular progress bar library would allow you to easily set the bar to a specific value, but no
 
10:54 PM
You'd think that a popular tower clock would allow you to easily set the time to a specific value, but no
 
@Aran-Fey not sure if this is your issue but a mistake I made here recently, pbar.update() takes in an amount to increment by, rather than the total
but it looks like you're not using update() so idk
 
Yeah, I can't use update() because of that
 
you can't get the size of a download chunk or something to increment with?
or even just check the prev bar.n? only asking because update() does a ton of stuff, so not sure if that stuff is all required to get it all to work right
 
01:00 - 23:0023:00 - 00:00

« first day (3902 days earlier)      last day (1029 days later) »