« first day (3499 days earlier)      last day (1446 days later) » 

12:13 AM
Thanks a lot !! it works.
 
no problem
 
12:37 AM
hey folks
hows everyones quarantines :P
 
@JoranBeasley hey. It's probably been a while, since we ask not to post fresh questions here to prevent fragmentation of information
 
yeah i know ... :P you can delete ... I would make sure to reflect any answers ... I know the rules ... 2 days :(
 
 
5 hours later…
6:03 AM
@Aran-Fey fwiw, it's jack diederich's counterexamples of where a class would have been useful in his stop writing classes talk.
 
6:21 AM
Oho, I don't believe I've ever watched long enough to see that part
 
6:32 AM
I have an if some_condition: continue in my code where coverage.py claims that the continue is never executed, even though it is. What's the recommended way to deal with that? Do I just ignore it and accept the <100% coverage result?
 
7:19 AM
@Aran-Fey I've found coverage to be very reliable and most importantly deterministic. I'd check whether the test that covers the line is actually run.
do you have branch coverage switched on?
 
not unless it's on per default
If I add a statement before the continue then it's correctly marked as executed
 
Is it normal that coverage.py crashes when a .coverage file already exists and then you run it with different options? Trying to run it with branch coverage throws CoverageException: Can't add arcs to existing line data
 
the peephole optimizer might eat the continue
 
WONTFIX :(
With branch coverage enabled it claims that my if never evaluated to true, which is quite clearly a lie
 
7:30 AM
CANTFIX would be more appropriate
 
guess I'll just have to live with my 95%
 
@Wildcard Python’s super() considered super! has some viable examples for cooperative inheritance via super.
 
wim
7:50 AM
I've seen that too, annoying - this is indeed due to peephole optimizer
@Aran-Fey not normal
 
@Aran-Fey # pragma: no cover should be ok on such a line
 
wim
it's safe to just rm the .coverage file if you see weird stuff
 
Is there a reason not to delete it before every run?
 
wim
no, but you shouldn't need to either..
I never even see them, globally gitignored
 
8:14 AM
Are there any official docs for the TKInter methods? I can't find my way around in the python.org tkinter docs.
 
freaking Windows Update keeps rebooting while I am working
 
@user2357112supportsMonica yup... that's a well known and "loved" Windows :p
 
It seems like even if I hit the "Another time" button, it reboots at the same time with no warning anyway.
 
@MisterMiyagi I don't think so. The official docs for tkinter are pretty useless. tkinter.ttk has decent docs though
 
8:28 AM
@MisterMiyagi when it comes to tkinter... effbot's stuff is the most useful (effbot.org/tkinterbook)
 
I've bunch of lines, and I am aware of a fact that each line must be an edge of atleast one(probably atmost 2) polygon, other than that the interior angle of polygon is always 90 degree. My question is how to find those polygon? [Line is represented by its starting and ending point]
( + It seems to me that this is probably quite common question, which suggests me that there has to be some efficient or simple algorithm for this, I tried rewording my question on internet, I didn't get any relevant result)
 
Sounds like you are just looking for lines with common start/end points?
Is that bunch of lines just an unsorted collection, or are they organised in some way?
 
These lines are either horizontal or vertical. the polygon would be only formed by end points(or starting point, lines are symmetric) of the the line.
@MisterMiyagi I didn't get that, I can organize(sort?) them.
 
8:44 AM
I'm basically asking whether these are already sorted or otherwise organized efficiently.
Frankly, I don't quite get what your question is.
 
Sounds like a task for a graph algorithm.
Looks like googling "find faces of planar graph" turns up useful results.
 
Okay, I can reword that:
I have some vertical and horizontal two dimensional lines stored as a tuple of point: (starting point, ending point), each of these lines is known to be an edge of atleast one polygon(here polygon has more than 3 sides, and all interior angle are right angles and these polygons do not contain any other polygon inside, niether they have finite intersection area(they might share an edge, though).
from niether they have finite intersection area , I mean these polygons do not overlap.
 
Seems like you should first organize these lines into a connectedness graph (if a and b share a point, they are connected) and then look for cycles.
 
That's the problem: how to look for cycles?. The only possible approach seems to is to use nested for loops(which works if the polygons are only rectangles)
 
8:59 AM
Graph cycle detection algorithms are well-researched. Most graph libraries should have some builtin, e.g. networkx' simple_cycles looks like what you need.
 
Cool, thanks.
 
That's probably not quite right. If you have two squares sharing an edge, forming a rectangle, then the rectangle is one of the graph's simple cycles.
It sounds like the desired output here would include both squares, but not the rectangle.
 
I guess the 90° condition should be used for connectedness as well.
Two lines with the same orientation should never be counted as connected, even if they share points.
That should avoid such cases.
 
9:22 AM
Put 5 squares together in a cross and the cross still gets counted.
 
rotational sense
+90 or -90 degrees all the way. Or: cycles of length 4
Probably the latter
 
Not sure whether it is possible to exclude such constructs outright, then. Might need removing superstructures after finding cycles.
@AndrasDeak From the vague description, I assume L-shapes and such are allowed as well.
 
> and all interior angle are right angles
=> rectangle
270-degree angle is not right
 
That sounds like it could have just been misuse of terminology.
 
Well it's probably some crap code challenge site
Or a bad rewording by Ajay, which would be a paddling
 
10:19 AM
# ## 12 Exam training 4
# The function below should accept one argument, a list with strings

# The function should return a dictionary with as keys the length of strings and as values
# sorted lists with the strings with the length equal to the key

# For example, the function call:
# main(["ab", "abc", "ad"])
# should return {2: ["ab", "ad"], 3: ["abc"]}

def main(list_1):
    # Correct the lines below so that the function does what it is supposed
    # to do.
    pass
not related to the site - but some student that's contacted me with help on better ways of doing what they've done
so they've already attempted everything themselves and are asking other questions... nice guy btw
I have an immediate "go-to" for that... (if you're not allowed imports)
 
I have a list like [(0,), (1,), (2,), (3,), (0,1)], why does the comma appear for tuples containing singleton elements
 
@kauray because there's no other way to denote a single-element tuple
 
oh
 
(3) is just 3, an int. (3,) is a tuple.
 
so u mean (5) wouldnt represent a tuple
oh okay got iy
 
10:25 AM
note that the comma is more important than the parentheses when it comes to tuples
tup = 3,  # is a tuple
(but in most contexts you need the parentheses)
 
thanks
 
no problem
 
@AndrasDeak that's always a gotcha :)
I can't be the only person that's left a trailing , and then weird things happen :p
 
10:54 AM
Good Guy Steam decided to update while I was tethered to my phone's 4G. Thanks, Steam!
Scenario: a user registered today starts their question with "I'm <op_name_here>. Not really a python guy. Trying to learn according to my needs." The question guidelines would suggest that I edit this out, but I know it will make them feel at least a little uncomfortable to see the more-clinical side of the site. Is there up-to-date guidance on what we should do with this? I remember debates about removing "thanks" in the past
 
I'd probably wait until they have an answer and then edit it out
 
Huh, I hadn't considered that angle. That seems the most pragmatic in terms of satisfying the ethos they want to push for the site. A new addition to my tab management issues :P
 
11:15 AM
just don't edit once it's closed...
 
Closed? What is "closed"? It's ripe for answering!
 
11:48 AM
@JoshPilkington sticking with the name change?
 
@JonClements I'm not liking it one bit but I should probably stick it out. I've never liked a single haircut I've had, and especially not the process of having it cut, but I just come to forget about it
 
um okay.. if it's making you not happy, I can reverse it
 
notgnikliP hsoJ. Catchy.
 
I just can't work out whether the consistency of my "brand" was important. roganjosh turns up on a thread and you go "oh god, not him again" was important vs. the obvious confusion it keeps causing people
 
I have no preference
if you want it reset back to roganjosh I'll do that
 
11:54 AM
No evil genie potential, tsk
 
(or anything else you fancy - "I really love the puppy dude" would work) :p
but I'd only only do that once
 
My balance would swing towards it being reverted but I know that real names have weight in mod elections (I certainly won't be running but it obviously has some impact to users)
@JonClements My thinking is a compromise; go back to being roganjosh and putting that on my profile for the faffing it's caused. I don't wanna go back-and-forth, though, so I'll mull it over for half an hour or so?
 
@JoshPilkington we have plenty of mods using pseudonyms. Very good ones too.
and especially on the broader network
hence
15 hours ago, by Andras Deak
You don't really need your name for accountability. Then again nutjobs can find you from your profile anyway.
on non-techie sites most of the mods are pseudonymous I think
 
12:12 PM
I agree. I think I'll just continue to accept that people think I'm called Rogan or that I'm from a country that I'm not (not that it offends me but it does make me think I'm misleading people if they read into the name)
 
it's really all up to you :)
spice it up (no pun intended) with joshrogan :P
now with the added benefit of not being your name and yet losing your brand
 
@JonClements send me back please, almighty puppy who is awesome and great and nice
@AndrasDeak that pun was totally intended :P
 
@Josh for the record then - you wish your username to be "roganjosh"?
 
yes please
 
two ticks then
done
 
12:21 PM
Thank you, sir :)
@JonClements as promised
:P
 
Yeah that puppy dude mod is great
 
@roganjosh lol
just remove that - no need to have that there at all
 
12:36 PM
@JonClements Done :) Just don't say I didn't follow through on my promise :P
 
everyone loves a cute puppy though, so it's understandable :p
 
1:31 PM
Number of times this year I have looked up how to convert gifs to webms, only to give up after discovering it takes more than a single command to an application I have already installed: 3
 
I don't understand how with statements without as work
What they do
Example
with tf.variable_scope('global_step'):
            self.global_step_tensor = tf.Variable(0, trainable=False, name='global_step')
 
I'm not entirely sure what that's doing, but it's most likely a terrible use of a context manager
 
it appears to modify tf for the duration of the scope
 
What happens in a with block if you don't define the expression as?
 
Not necessarily terrible, it does save user from having to deal with try... finally clauses.
 
1:38 PM
Using with without as is not unusual. You do this with threading.Lock's for example.
 
if the return value is not bounded it is not exported to the current scope
 
Context managers are useful even if they don't implement anything other than __enter__ and __exit__. In other words, it still does something at the beginning and the end of the with block.
 
It just means that the context manager itself is not needed in the body of the with.
 
@JohnnyApplesauce with calls __enter__ and then __exit__... what those methods do is up to the person who implemented them
a good use for an __exit__ method could be to close a file
 
1:41 PM
@JohnnyApplesauce the same like in a with block that does use an as assignment, minus the assignment.
 
another good use of an as-less with:
with pytest.raises(AttributeError):
    my_method_that_should_throw_an_attribute_error()
 
One example of a simple context manager that is more likely to appear in with ...: than with ... as ...: is contextlib.redirect_stdout. It changes the destination of output written by the print() function (et al). There's no point using as with it, because most builtins that write to stdout are functions, not methods
 
@AndrasDeak just seen my first example of this in the wild :)
 
Hello everyone!
 
1:55 PM
Hello!
 
I ran into a wall trying to work something out on heroku and python... anyone can lend a hand?
 
@TPguru Hello :) Provided that you follow the room rules you should just ask your question
People will help out if and when they can, so you might not get immediate responses
 
If this is about Heroku: how to install python dependency within app folder, it looks like you are still getting some activity on the main site.
 
kevin, yes...
 
I agree with Chris that it may be helpful for us to know which library specifically you're modifying. I believe you when you say that you've successfully modified the library locally, but having more detail may still shed some light
 
2:01 PM
i changed javascript on streamlit
but i have other libraries i changed stuff and wanted to learn to be able to do whenever needed
so i dont think the specific library is that relevant
 
I have no idea what the "best practice" is for modifying libraries in heroku deployments, but perhaps you could locate the site packages directory, which may be where the js file is stored, and modify it there
 
Kevin, i read if i do that it will work for a minute, but it is not permanent by virtue of how the dynos work
 
I notice that the accepted answer there suggests creating your own fork of the library, same as Chris
 
I am having a hard time visualizing the steps... thats the issue... I am a deep back end guy deployment makes me feel dumb lol
 
Lazy solution: every time your script starts up, the very first thing it does is to check if the js file is modified, and if not, then modify it
 
2:09 PM
Ok, good idea
 
Possible roadblock: if you're using a framework whose entry point executes after you import streamlit, then the js file may already be cached in process memory, and editing the file at that point might not do anything
 
can i just copy and paste the library folder to the main app folder? what is the roadblock there?
 
1) Some libraries only work if they're in the site-packages directory, if they make unfounded assumptions about the structure of the directory they live in. 2) libraries you paste into the main app folder will only be importable by scripts in the main app folder, and not by scripts in any subdirectories of the main app folder.
3) users and future maintainers will have a better idea of who to go to when something goes wrong, if all of your project's requirements are actually listed in requirements.txt
 
2 and 3 are not relevant in my case
1 might be a roadbloack
 
Thorough testing should help there
 
2:52 PM
Well that is odd. Spyder has been crashing a lot recently and finally gave me the first BSOD on this laptop. I tried all the fixes plus upgrading, and nada, so I decided to just uninstall to try again. During doing that, it's telling me that mkl and sqlite (and others) will be upgraded by performing the uninstall. I'm not sure I like the IDE fixing versions for me :/
Though I suppose it runs in the base environment so it won't impact on any virtualenvs. Still seems odd that the IDE would dictate what versions of certain libraries I have
 
It's just a little too integrated into your dev environment, there
 
Indeed :)
 
Tired of editor overreach? try Notepad++™! It's barely smart enough to know to highlight else:, so there's no way it's going to figure out pip uninstall. Call now, and pay only zero installments of $0.00.
 
VSCode is my new baby. I just haven't got it to the "see SO question --> jump to editor" state. It's so much easier in Spyder, at least in my workflow
 
alt tab?
or did spyder take that too?
 
3:07 PM
It just doesn't feel natural is all. Considering I now can't seem to reinstall Spyder, it might have to be the new me :P
 
we can ask the puppy to reset you
 
It's gone from an identity crisis to a full-blown catastrophe!
 
The lesser known mod power of remote access into users' machines for the purposes of installing development software. It's all perfectly legal, if you read the EULA.
 
That's so easy to exploit, it'd be rude not to. Someone needs to sit and figure out why setuptools is upsetting conda for no reason I can discern. I promise to watch the screen and see how it's fixed...
 
you need 20k rep to see the actual fix
 
3:13 PM
Even better. Now they just go to fixing it for me and I have an excuse for sitting in the garden for a bit because I have nothing to learn
 
Tend to your potatoes. Boil 'em, mash 'em, stick 'em in a stew.
 
They are... precious... to me
Ok. It seems I have actually also managed to totally bork conda with my "fix"
 
hey guys how do i column concatenate a 10x10 matrix (2d array) .i have to convert the 2d array (matrix) into a 1d array(vector). how can i be sure of what method i used does column concatenation?
 
I read an argument online that potatoes couldn't have possibly existed in Middle Earth because it takes place in prehistoric europe and potatoes existed only in the Americas until the 1500s
 
@KhwajaHussamQuasmi arr.T.ravel() should do it I think
 
3:20 PM
@AndrasDeak are u sure it would be column concatenation? i already did used ravel
 
>>> arr = np.random.rand(2, 3)  # array with row-major memory layout
>>> arr
array([[0.49440787, 0.84966521, 0.853528  ],
       [0.1193751 , 0.41530204, 0.6361949 ]])
>>> arr.T.ravel()
array([0.49440787, 0.1193751 , 0.84966521, 0.41530204, 0.853528  ,
       0.6361949 ])
>>> arr2 = arr.copy(order='F')  # array with column-major memory layout
>>> arr2
array([[0.49440787, 0.84966521, 0.853528  ],
       [0.1193751 , 0.41530204, 0.6361949 ]])
>>> arr2.T.ravel()
array([0.49440787, 0.1193751 , 0.84966521, 0.41530204, 0.853528  ,
@KhwajaHussamQuasmi that's why you need the transpose
 
@AndrasDeak thank you so much :D
 
No problem. You could also use .reshape(-1) instead of ravel, but that will not create a copy. It needs the transpose all the same, as it consumes items row-wise.
 
Perhaps JRR would employ his most powerful get-out-of-jail-free card: "that kind of seeming inconsistency is because the fictional author of LOTR is translating the fictional Red Book of Westmarch from Westron into English. There's no English word for the now-extinct tuber that hobbits loved to boil and mash and stick in stews, so my self-insert used the closest approximation available, 'potato'"
 
And please only star things that might be interesting for a broader audience, since we all share the same starboard :)
 
3:24 PM
@AndrasDeak will do bro
 
thanks
 
"If the book seems badly written, it's my character's fault, not mine :^)"
Perhaps this also explains the orc's cry of "looks like meat's back on the menu, boys" despite there presumably being no restaraunts in Mordor
 
@Kevin do we know for a fact that the elves didn't take all the taters with them when they left?
 
If so, rude
 
probably got tired of all the lembas and it's a long trip to the Blessed Realm
 
3:28 PM
@Kevin pubs can serve food too. They exist. Are they not allowed menus?
 
So perhaps the elves drove potatoes to extinction in prehistoric Europe, and they would have also done so in America, but they couldn't reach it in their boats, which ignore the curvature of the earth and travel along a plane tangent to Britain.
 
Maybe they were ahead of the curve with orc gastropubs. Their absence from the screenplay doesn't mean they don't exist
 
Geometry exercise. The elves wish to sail along the plane tangent to Britain until they are directly above the American shoreline. Potato-killing commandos will then airdrop down, and fulfill their grim task. From what altitude will they drop?
 
R * (1-cos(phi)) where phi is the angle from Britain to the shoreline (and R~6400 km)
or, no, but close
R*(1/cos(phi) - 1) or something
 
Angle not necessarily accurate
 
3:39 PM
 
Essay question. Would mithril make effective material for a space shuttle heat ablation shield? Explain why or why not.
 
I could've shown off knowing that 1/cos is called the secant
@Kevin I'm pretty sure dragon breath is a decent model for re-entry. For the larger and more powerful kinds of dragons at least.
 
Let's see... Plymouth is at 41.95833 N 70.66778 W, and London is 52ish N* 0 W, so the angle between them is... Carry the two...
 
need a geodetic
 
(*Rough estimate from looking at a globe because Wikipedia doesn't say and I can't be bothered to google it more than once)
Well we know at least that it's more than 70 degrees, so we're past the right end of your graph
 
3:47 PM
 
What unit is the Y axis? Earth radii?
 
Dimensionless, see the legend. Needs to be multiplied by Earth's radius.
 
Ok
 
I could only compute the precise angle by taking the vector pointing to Plymouth, rotating that around the x axis by -52 degrees, and then converting back to angles
 
The moon is 60 earth radii away, so 2ish is relatively tame. I was worried the commandos would fall into the sun's gravity well.
 
3:50 PM
or if I'm being less dumb, just take the vectors pointing to London and Plymouth and compute their angle from your favourite dot
@Kevin your drawing is pretty much 60 degrees
 
I chose it mostly because of the aesthetic quality of a 30-60-90 triangle
 
I'm just saying that "roughly two" is visible in your drawing
 
True
 
Although I guess that's not too fair. What's visible is "roughly 1" for 60 degrees which is exact
 
In any case I have to retract my assertion that the angle is at least 70 just because that's what the difference in longitude is. As a counterexample, consider that the angle between 89 N 70 W and 89 N 0 W must be quite small.
 
3:54 PM
One could claim that "70 degrees is close to 60 and 2 is ballpark 1" but this is a slippery slope when the function diverges at 90 degrees
 
And the angle between 90 N x W and 90 N y W is zero for all sane xes and ys
 
@Kevin OK, so you should compute the angle from the corresponding vectors
 
I'll do that after lunch
 
just don't forget to convert latitude to polar angle
 
@Kevin You mean ones that are completely Cartesian on a plane? Fine, except...real life.
 
3:58 PM
I mean ones on an ideal spherical planet
 
even non-spherical ones, assuming latitude makes sense
even with insane xes and ys (as long as they are real)
 
Yeah, any surface where all longitudinal lines converge on a single point should do
Earth qualifies by definition unless they're doing something wacky with... Leap Feet, or something
 
Not even an hour away from chat and there's been potato-killing marauders airdropping in on a trans-Atlantic Elven mission. Nice
 
"90 N <whatever> W actually comprises a ring ten feet around the geometric north pole", explains the hypothetical measurement standards bureaucrat, "because mapping the north pole to NaN is the only thing keeping all the adjacent countries from fighting a war to put a flag there. They can't claim territory that's out of bounds"
 
That's... oddly logical. Therefore, no bureaucrat said it, ever
 
4:25 PM
it seems to go through waves of conda update conda is a fix with many thumbs-up, to it being a terrible idea and everyone piling on with thumbs-down for the exact same suggestion. I'm glad there's consensus.
 
Morning cabbage
 
4:43 PM
Ah, chepner has given me a giggle with this
 
wim
5:09 PM
ah the true use of community wiki. troll posts.
 
Eh, I think it illustrated the point pretty well
It would be less troll-y, though, if he hadn't switched to CW and just stuck to his guns. He did that after I'd linked it here
 
Hey everyone
 
Hi
 
wim
speaking of conda - what is the big gain over just using venv+pip
 
cbg
@roganjosh wow
 
wim
5:20 PM
someone clever registered 0.30000000000000004.com that you can use to drop on floating point questions
 
thats news
 
@wim That you can get the scientific stack installed on Windows. There's tonnes of stuff that I just pip install anyway because it doesn't exist in conda. But it does help if I need to update pandas, for example, and that has a new numpy requirement
They kinda insinuate that if you use conda that you can't default to pip. Well, I'll go on record of calling bull because I've not had an issue to date on maybe 40/50 libraries that I installed externally from the Anaconda distro. <now waits for the impending catastrophic failure>
 
wim
wait, you can't just pip install pandas and numpy on windows? 🤯
 
In the past, it was a real pain. Hence why the unofficial binaries even exist. I haven't tested it in a few years, I just default to Anaconda
 
5:43 PM
 
What do you think we should do about this question Check if something is (not) in a list in Python? I see several options: 1) close it as a duplicate of Fastest way to check if a value exists in a list; 2) rename it to "Check if a tuple is (not) in a list" and link it somehow to How to check whether a tuple exists in a Python list?; 3) close it as "Needs debugging details".
 
@Georgy How to check whether a tuple exists in a Python list? is awful because it doesn't even use tuples. So I'd suggest option 2 with the renaming and then dupe the aforementioned question to that. We'll see what others say
 
wim
6:06 PM
4) leave it alone
there is usually not much point to go closing 2012 answers
why did coldspeed answer that in 2019? weird
 
seems like no MCVE or no repro to me...
@wim it may have been discussed here because you commented on it
 
I'd normally agree with "leave it alone" but the question I linked doesn't even pose the problem that the title suggest
 
viewed 1.1m times, so I guess people looking for the title find the answers useful
 
wim
yep
 
sad
 
wim
6:10 PM
could be worse
the answer is short, correct, and accepted
 
@Georgy I agree we should leave it alone
 
That's my duplicate profile , the answerer was me, don't use that profile very much
 
wim
U10 is your sock?!
 
@anky can you clarify which profile you mean?
 
hehe Kidding,, have fun all.. happy weekend
 
wim
6:15 PM
lol
 
....
 
:D sorry again
 
<tries to rebuild from the Earth-shattering revelation. Weeps>
 
hahaha... glad it helped josh
 
Mann, if that's helping, I'd hate to see you be destructive :P
 
@JonClements Was turning off my "stop cheating" bots but caught this as I was: if that's from my course they were just suppose to build an itemset lattice (most used a Ngram or MapReduce like algorithm to build but no specific requirements). Grading was pretty open as the class consists of everything from math majors (use functional) to Software Engineer majors (OOP w/nested loops).
The idea was related to a biotech project (this was iteration 2-ish) of a DNA sequence matching project (you could use imports but not scikit or pandas - yes: numpy).
 
numpy is all anyone would need ;)
 
wim
@AndrasDeak 👋
oh boy, love this one
[list_to_search_in.index(i) for i in list_from_which_to_search if i in list_to_search_in]
why is Python so slowwwwww :D
 
@AndrasDeak some of the OOP people make full graphing classes for this (which wasn't a bad idea with later parts of the project but way overkill for this part itself)
 
@wim oof
but it's "faster because it's a list comprehension"
 
wim
6:35 PM
yes all C speed and one-line too!
if you write all on one line there is no chance for the GIL to slow you down!
 
6:58 PM
to whom it may concern: pypy and aarch64 numpy "nightly" builds are now available
 
@wim I'm looking at dis.dis('[item for item in range(10)]') and it breaks the listcomp down separately. I was just curious whether any part of it can "steal" the GIL and 2 LOAD_CONST 1 ('<listcomp>') appears to be a single op-code, which gets further broken-down. I can't pretend to understand dis.dis well, but the fact that the "parent" has to be broken down, does that mean that the list comp does actually enjoy a bit more control over the GIL?
 
wim
no
there's nothing atomic about a list comp, other threads can jump in within the iteration
 
7:28 PM
Hello guys....
 
@JohnDoe please don't ask for help here with your fresh questions on the main site, as per our rules.
 
 
2 hours later…
9:31 PM
Lately when I look at my code I often don't think "this is a mess" anymore. I'm a little worried, to be honest. Can't tell if my code is actually improving or if I'm just getting used to my garbage
5
 
probably both
the real test is to come back in three months and evaluate
 
hi guys. could anyone guide me on how to normalize an image vectors array?
v = ccAr[:, 1] # ccAr[:, -1] for the last column
ccAr[:, 1] = (v - v.min()) / (v.max() - v.min())

#ccAr = ccAr.astype('float32')
#ccAr /= 255.0
i tried these two methods but got errors
 
problem is that I still have so much old code lying around, I'm losing track of what I wrote when
I've got code from last week next to code from 7 years ago
 
9:50 PM
@KhwajaHussamQuasmi what kind of errors?
And where are those errors coming from?
 
:49389510  i did a mistake was treating it as a 2d array :/ can't believe i did that
v = ccAr
ccAr = (v - v.min()) / (v.max() - v.min())

my question now is the vectors are from an image pil array. is this method correct as my range is from 0-255
 
@KhwajaHussamQuasmi this will normalize your array no matter what the values are. Meaning the output array will be between 0 and 1.
But this kind of "normalization" will mess with your image, so make sure what you're doing makes sense. This depends on what you're doing with it afterward. I suspect some machine learning...
 
@AndrasDeak is there a method in which i dont get my outputs in float?
@AndrasDeak yes it is. im making a FACE RECOGNITION system using linear regression
 
@KhwajaHussamQuasmi "normalization" inherently gives you non-integer results. You can convert back to an uint8 afterward if you want that: (ccAr * 255).round().astype(uint8)
this will scale back your [0, 1] range to [0, 255]
 
@AndrasDeak what should i do then its my first machine learning project in python
 
9:58 PM
sorry for the pings with the edits, I just confused myself for a bit
@KhwajaHussamQuasmi I don't know what you should do because 1. I don't know what problem you're facing and 2. I don't know any machine learning
 
@AndrasDeak no worries bro. thanks for the help i really appreciate it
@AndrasDeak could u tell me a better normalization way?
 
There is no "better normalization way", there's just normalization. Why are you looking for a better way?
 
@AndrasDeak above you said "this kind of normalization" would mess my image. I thought maybe theres a better method for normalization
 
@KhwajaHussamQuasmi Ah, I see, sorry. I just meant that stretching data in an image by forcing the darkest colour to be black and the lightest colour to be white (which is what normalization does) will distort your image. But I see this often in ML so it might be normal. And my point is about normalization in general
so you needn't worry about this too much
 
@AndrasDeak thanks man. i was kinda lost my cool their. im pretty close to my deadline
i kinda*
 
10:09 PM
note that you can edit/delete messages in chat for 2 minutes
 
user10984358
11:03 PM
@smci sorry I haven't been in chat since then, but I ended up understanding and using the erat3 function in stackoverflow.com/a/3796442/10984358, there were test cases upto 10**6 and my previous lru_based approach was clearly not suitable, some sieve approaches I tried were getting MemoryError due to the sieve list being used
 
11:42 PM
@PYN please don't ask for help here with your fresh questions on the main site, as per our rules.
 
PYN
sure, @AndrasDeak. Thanks for the suggestion
 

« first day (3499 days earlier)      last day (1446 days later) »