@smci Thank you so much for rewriting my question I really appreciate your time. However, there is a small change that I will make on the question. I had a chat with my senior he has just given me the right steps I should follow for a correct answer. If you could please assist me in following those steps. I really appreciate your help.
> (Size Policy) If there is a QLayout that manages this widget's children, the size policy specified by that layout is used. If there is no such QLayout, the result of this function is used.
@smci the steps my senior asked to follow are 1) Find difference between date columns. 2) Set the threshold as its row target value. So the threshold changes for every row since target is different for every row. 3) Find the percentage difference between the difference values (step 1) and the target. 4) Percentage difference, should now be compared with new universal threshold that we will set now. However, we have to ensure that the threshold isn't too high or too low. Otherwise spikes in the data will not be observed. It should be in a range where some spikes should be seen.
@krijan This is confusing to keep restating the question so many times, and you already accepted an answer, but by the way no answers used Target because you didn't tell us how to use it. Ok so you're trying to heuristically find your 'threshold' (different value for each row), with this iterative process. I don't know what you mean by "2) Set the threshold as its row target value." but I think you mean "Initialize threshold to Target value for that row"
@smci Im so sorry, my senior is bugging me every now and then he himself is confusing me.
Correct thats what i mean, Set threshold to target value for that row.
However for very last step 4. This time We have to ensure that the new threshold we set is same for the whole table.
In terms of accepting the answer. That was the correct answer. However, my senior technically asked me to do it again, however using his steps (the steps i just gave) this time.
@krijan But stop saying "Set" when you mean "Initialize". "Set" means once and for all. "Initialize" tells us "here's an initial value, but we're going to change it later, possibly iteratively". Honestly I'm trying hard to follow, but it's hard. "4) Percentage difference, should now be compared with new universal threshold that we will set now.". Again, don't say "set", say "determine" or something...
Your definition of "threshold" and "spike" keeps going in circles: "spike" is any difference-in-values where deviation is >= (/<=) "threshold", and "threshold" is whatever value detects a lot of "spikes", but not too many. Please post us your updated data after doing [your above revised process]chat.stackoverflow.com/transcript/message/46743690#46743690, then let's figure out how to unwind your circular definition.
Do you want me to visually show you in table about how it should look?
because the data frame is the same.
when i say "spikes", i am trying to say that it is going above the threshold. (Thats why we take absolute of the difference column). When I say "Threshold", I am trying to say that its a value that detects if the comparison result is going above the value we set (Threshold). If the value is going above the threshold then its considered as a spike.
@smci Updated (Removed grammatical errors) 1) Find difference between date columns. (Absolute difference) 2) Initialize the threshold to Target value for that row 3) Find the percentage difference between the difference values (step 1) and the threshold. 4) Percentage difference, should now be compared with new universal threshold that we will determine now. However, we have to ensure that the threshold we initialize is not too high or too low. Otherwise spikes in the data will not be observed. It should be in a range where some spikes in data should be seen.
@ParitoshSingh @anky_91 1) Find difference between date columns. (Absolute difference) 2) Initialize the threshold to Target value for that row 3) Find the percentage difference between the difference values (step 1) and the threshold. 4) Percentage difference, should now be compared with new universal threshold that we will determine now. However, we have to ensure that the threshold we initialize is not too high or too low, also its same value for every row. Otherwise spikes in the data will not be observed. It should be in a range where some spikes in data should be seen.
@krijan Ok so you need to expand Step 4) "However, we have to ensure that the threshold we initialize is not too high or too low." into an iteration. Like 4a) Count FCount for given threshold. 4b) If FCount > ?, Threshold = Threshold * .9? 4c) If FCount < ?, Threshold = Threshold * 1.1?
@smci when i say not too high or too low. I mean, that suppose if we get percentage difference is 10%, 10%, 20%, 40%. If we determine our universal threshold to be example 2%. Then all the values are above it, hence all the values will be considered as spike. However if we set it as 12%. Then we will have 20%, and 40% as spike value. So, my point is, that 12% is a good value to be determine as threshold
I have a rest api exposed from flask. Now i want to use kerberos authentication for this rest api. I got a Flask-Kerberos library but not getting how it works,I got a service keytab file from the AD server(Is this kerberos env) also how to set up kerberos environment.
@roganjosh I want dict and set and friends to work normally - via a random salt. I want my own data structure to work deterministically - via a known salt.
@Kevin I would also love to have something like that. The other wish I had for python, assignment expressions, were granted. So the outlook isn't too bad :p
My birthplace was only like 50 km from the dutch border, after all.
@krijan So, here's the thing. you've gotten a lot of groundwork done for you, can you,by yourself,try and add the additional functionality? If we do all the work for you, what would you gain out of it? I highly encourage you to first 1: understand the current code and 2: see if you can add the additional logic required on your own. I'll give you a hint too. numpy arrays are really powerful, and allow comparisons between arrays as long as either the shapes match
For example:
import numpy as np
a = np.array([10, 20, 30, 20, 10])
a > 15 #works, as you know
array([False, True, True, True, False])
a > [5, 15, 25, 0, 0] #works too, as long as the shapes align!
array([ True, True, True, True, True])
Just try it first, if you get stuck then feel free to show what you tried and went wrong
does anyone use azure notebooks for jupyter? im having trouble that after successfully installing a package and trying to execute a command it comes back as NameError: name 'mypackage' is not defined
sys.exit? sure, sounds fine. though make sure you really need it. If you can refactor code to allow normal code flow without losing out on readibility, opt for that instead.
I think your problem is completely analogous to the discussion "should a function have multiple returns?", where function -> script and returns -> exits. I personally like this answer on the matter: stackoverflow.com/a/733858/962190
@Andy if the condition is fatal, you probably want to throw an actual exception. If the condition is not fatal, there really isn't much reason to abort the program at that point. All callers should be aware if a call can un-exceptionally end a program.
note that "orderly close down" is ill-defined for threaded and multi-process applications. sys.exit can fail to stop your application promptly in these cases.
hi, does anyone of you have experience with tensorflow-gpu in python? im currently training an object detection but it looks for me like the cpu is way more utilized then my gpu.
Okay, I’m apparently very rusty… My original timing (using a custom type) didn’t make sense here: stackoverflow.com/posts/57004399/revisions – Can anyone see what I am missing?
@MisterMiyagi I understood you can separately seed random.Random and it should have no effect on the sequence generated by $PYTHONHASHSEED and hence dict and set lookups.
I'm consuming data from rabbitmq and message push rate is nearly 50/s so i want to do two asyc tasks inside on_message callback.
1) send acknowledgement to rabbitmq
2) do a calculation and save in database ( non async )
How could I achieve this ?
def on_message(channel, body, envelope, prope...
@holdenweb because I need a stable hash for arbitrary Python objects. Not a randomly-salted hash for arbitrary Python objects, nor a stable hash of only bytes objects.
the rules for BINARY_ADD require checking the presence of RHS.__radd__, possibly the sub typing relation of RHS and LHS, and a pointer comparison of the return value against NotImplement
@underscore 50/s is pretty tame, Threads are probably a lot more appropriate for your use case
@krijan you keep coming back with this problem. Now you've posted at least three iterations of the same large message containing steps of what you have to do. Don't use this room as a short-cut to learning to do your job or as a short-cut to asking questions on main. If your problem needs half an hour to explain and people have to write your code for you: you're doing it wrong.
@piRSquared Nice work. Apparently the conventional solution is to generate a point inside a quadrilateral formed from two triangles. Then you only have two cases to deal with.
"left half of the quad" or "right half of the quad"
The article is frustratingly vague about how to transform one into the other
I was trying to come up with a function that flips or rotates points over the line y=-x, but only if they're on the left side of the line to begin with... (new_x, new_y) = (abs(x+y)-x, abs(x+y)-y) is the closest I got. (1,1) becomes (1,1) as desired, and (-1,-1) becomes (3,3) which is wrong but at least it's in the right quadrant
if the origin is the bottom right corner then you have to shift by (v1+v2)/2, then act with the matrix [[-1,0],[0,-1]] (i.e. just flip each x and y component) then shift back by -(v1+v2)/2
My holy grail is an approach that doesn't require me to identify outliers first. That's why I'm hung up on functions that don't do anything to points already inside the desired region
Oops, the equation I wrote above is backwards, I meant (new_x, new_y) = (abs(x+y)-y, abs(x+y)-x). Not that it matters for the two examples I gave.
I also have (new_x, new_y) = (x * abs(x+y) / (x+y), y * abs(x+y) / (x+y))???) written down on this cocktail napkin but I haven't investigated it very thoroughly yet
I derived it symbolically by putting an abs between two rotation matrices, so it's only wrong if I missed a sign somewhere in fifty lines of arithmetic
@MisterMiyagi I don't think so. x <-> y replacement should be on x=y
if you mean the two together, then maybe :P
I'm not good with point groups. A few weeks ago I had to look at the character table of a group in order to be convinced that S_6 is the same as C_3·i. Rookie mistake, right?
@Kevin (x, y) => (-x, -y) is a 180° rotation around the center. (x, y) => (y, x) is a reflection on x=y. (x, y) => (-y, -x) is a reflection around x=-y == y=-x.
I have created some environment variables on my host bash profile, which show up in python when I do os.environ.get(VAR_NAME) but they don't show when I put os.environ.get(VAR_NAME) statement in a script and run it via pycharm
@Muze I think I could ask this on the Space SE meta
@Muze But it would be a little bit risky, mods hate this. On the PSE, I would get a year long ban if I would do, but the Space Meta is not so vehement yet. The obvious cause of your suspension was a cross-site mod conspiracy.
@AndrasDeak He often posts LQ posts. These are downvoted, closed and deleted. He is often accessed by automatic Q/A bans. But there is no reason to punish him over these, his attitude clearly shows curiosity, a wish to learn, and a strong urge to keep the rules.
i have a sorted dataframe, and i'm trying to filter by condition and grab some specific indices: df[df['categorical']=='val'].index.values but when I use one of those indices in .iloc, it returns rows where df['categorical'] != 'val'
I believe you, although I'm not sure how skewing is useful. If you skew my unit rhombus into a rectangle, it will have width 1 and height sqrt(3)/2. So I don't think sampling the unit rhombus is the same as sampling the unit square.
You have a df, you sort it, and then you .iloc on it. I suspect it's just that you don't reset the index after sorting but we'll soon see. In any case, the example needs to only be representative
Anyway. I'm trying to decide whether it's possible to generate random points inside any simple polygon, if all you've got is an algorithm to generate random points inside an isosceles triangle. It seems simple in principle - decompose the polygon into triangles, then decompose each triangle into two isosceles triangles. My only concern is whether there will be a slight bias along the edges where two triangles meet.
If I understand my own code correctly, a generated point can lie on the edge of the equilateral triangle that's opposite the origin; but a generated point will never lie on either of the other two edges. So depending on how you divide the polygon, you might get internal edges that a point can never lie on, or edges that a point is twice as likely to lie on.
tri = make_tri(1, [.25, .5 * 3 ** .5]) #
lin = get_line(tri[1], tri[2]) # right side of triangle
con = get_converter(tri, lin)
plot_triangles(tri, con)
@Kevin If you are picking a random point in the 1 x sin(60°) rectangle, the right and top edges will be exclusive of your random function. The right edge would have mapped to the vertical centerline of the triangle, but that is okay because the left rectangle edge already maps to it. The top edge would have mapped to the bottom, but that too is already covered. The non-X-axis edges of your triangle will fall in the range returned by random, so your random picker will be inclusive of them.
So I think your random picker is inclusive of all the triangle edges (if I have guessed your approach is to pick a random in 1,sin(60°) and then map to itself if inside the triangle, or to its twin if outside)
my randoms are open on the right. Left edge only possible from first random. Cannot be reached from a converted point. ... in fact no edge can be reached from a converted point. Therefore it seems internal points are more likely
I'm guessing that you're saying "for a random number generator with unlimited precision, the odds of random() returning 0 is almost exactly 0%. So it doesn't really matter if the odds of that are doubled"
My company is starting to develop private packages that we will use internally. We are looking at ways to distribute these packages so that we can pip install them into projects. We've considered two options: installing directly from the libaries' git repos and setting up a PyPI-like repo.
We have a client that wants to do some of their own development on their project, so we need to allow 3rd parties to be able to install these packages without exposing any other code (such as that of other client projects). Any suggestions about where to look for information on either of these or other alternatives?
Neat! This method works easily for goofy triangles
tri = make_tri(1, [-.5, .5 * 3 ** .5]) #
lin = get_line(tri[1], tri[2]) # right side of triangle
con = get_converter(tri, lin)
plot_triangles(tri, con)
You can always host your own pypi server, my company has one with necessary access restrictions, we also have CI/CD which pushes whl files to this server whenever a build is made of said libraries
I like that rotation about the midpoint strategy, since reflection over the shared line only works for isosceles triangles
I initially chose reflection because I didn't want to have to calculate the midpoint, but in the end I need to calculate it anyway in order to get the right translations. So maybe I shouldn't have bothered.
@Code-Apprentice The server was already there before I came, but making your own whl files using setup.py and pushing those to pypi using twine via jenkins is pretty easy
we are a consulting firm. We build custom software for whomever pays us. Which typically means that they own it. At the same time, many of the systems we build are quite similar. Someone had the most brilliant idea of creating a base git repo that we fork. But now we are cleaning up the mess that caused because we want to maintain ownership of that base project but now its code is in a client project's repo.
@Kevin I'm not calculating a mid point. Let the left edge be A, The bottom edge B, and the right edge be C. The coords for the first vertex is (0, 0) so I can treat the point of the top vertex as a vector, in fact it's A. and the right vertex is the same as B. So if a point chosen is P then it is either P or A + B - P
I suspect this is possible by briefly converting each vertex to polar coordinates, then doing some trickery on the angular component, probably involving modulus, and then converting back to (x,y)
I don't know much about visual studio. Via command line... my best guess would be to start by maybe recloning the repository. But that would mean you'd lose all your local work.
@SamuelWakeman That sounds like the right solution to me.
Or are you saying you successfully created a local clone of the project, but when you make a change and commit it and push it, it doesn't affect the remote repository?
$ git push --set-upstream origin master
remote: Repository not found.
fatal: repository 'https://github.com/Lokesh-Eisen/manufacturingNetworkMVC.git/' not found
gonna try making it public briefly
$ git push --set-upstream origin master remote: Permission to Lokesh-Eisen/manufacturingNetworkMVC.git denied to Samuel-Wakeman. fatal: unable to access 'https://github.com/Lokesh-Eisen/manufacturingNetworkMVC.git/': The requested URL returned error: 403
There's a spiderman villain who was bitten by a radioactive spider and then his body melted into a million spiders that all host his consciousness in a telepathic hivemind. That guy is certainly a spidersman.
I'm just gonna say; you said it's your last day at the job, but I can access that repository and see all of the code. Are you aware that this is public?
Which I quite easily could have done. I don't actually know what the code does, but I could always have just grabbed it as soon as I realised you posted the URL here
but im just trying to get out of this job tbh. I'm a 21 year old intern still in college who got kind of manipulated when i took the job, and the boss is like go build amazon b2b2c by yourself, and I'm like ok ill try
@roganjosh right I'm saying I agree I should be more careful, but also anyone who knows how to code vaguely in asp.net could do what I did with that repo in under 3 hours
well maybe not vaguely
but if theyve been coding with it for a least 1-4 months 1 day
State of the art computer vision, digital newsletter distribution scalable into the tens of thousands, sentiment analysis of articles about publicly traded stocks... My bosses sure loved giving me pie in the sky objectives
Hi all, I'm looking for a resource that can help me understand how to create a Python package (something pip installable) that users will be able to evoke from the command line after installation. So pip install blargs && blargs would run __main__ inside of the blargs package
I know there's python -m but I don't want users to have to type the python command at all. I know this can be done but can't seem to figure out just how to set it up. Can one augment a user's path as a post install hook or something like that?
What a frustrating day. Trying to revisit my old code, it seems my old stack is basically alien after a couple of years; so many changes in the libraries. For some reason it reminds me of the old Jaffa cake advert where I've just watched everything disappear.
A recent now-deleted post on the main site asks how to print a triangle of numbers. Pretty standard stuff for a beginner exercise, except it took me five minutes to determine the pattern by which the numbers appear.
And before that, a minute to determine that there might be a pattern, rather than a keymash by the OP to produce approximately triangle-looking sample output
I don't think this is a very productive way to teach someone how to do for loops
I'm guessing that's the one I commented on. I also didn't see a pattern but I lose interest fast when there's no input from the poster, even just to say they don't see the pattern, so I moved on and didn't think too much about it