My Visual Studio keeps displaying the following warning (I think it's actually the Web Essentials plugin that produces it) but I'm not really clear why this is a problem? Can some explain please?
PS, Yes I understand what specificity is and how to calculate it, I just don't know why a specificity of 0,2,0 is a problem?
The above isn't the error message, it's standard hovering info when you move your mouse over a selector with WE. However, the problem you're facing is probably the same selector being specified twice in the same file.
Pekka's answer is practically correct, and probably the best way to think about the issue.
The starting point is 4 figures:
style id class element
0, 0, 0, 0
So in your case you have used 2 class names so its showing as 2 in the middle.
Related
I am trying to reduce CSS specificity in my project by using the stylelint selector-max-specificity and I have now set it to "0.2.0". The problem is that when I use wonderful-input::placeholder it doesn't throw me an error, even if it has 0,0,1 specificity, but when I use wonderful-input:focus::placeholder the specificity is increased to 0,1,1 and an error is thrown. The error that I get ofc is:
Expected ".input-basic__input--active:focus::placeholder" to have a
specificity no more than "0,2,0"
(selector-max-specificity)Stylelint(selector-max-specificity)
Does anyone know why I get the error and if I can decrease the specificity on this one?
I just don't understand why 0,0,1 doesn't and 0,1,1 does throw me an error! Thanks :D
Does anyone know why I get the error
Using this calculator you can see that the selector .input-basic__input--active:focus::placeholder has a specificity of 0,2,1, i.e. 2 (pseudo-)classes and 1 (pseudo-)element.
0,2,1 is greater than chosen max specificity of 0,2,0, and the rule correctly reports this.
You should increase your primary option to 0,2,1 if you want to use this selector.
the problem is that when I use wonderful-input::placeholder it doesn't throw me an error
The selector wonderful-input::placeholder has a specificity of 0,0,2, i.e. 2 (pseudo-)elements, which is lower than 0,2,0 so the rule allows it.
can I decrease the specificity on this one?
There is no way to decrease the specificity of the .input-basic__input--active:focus::placeholder selector and have it do the same thing: i.e. style the placeholder pseudo-element of focused elements that have the class input-basic__input--active.
I am trying to reduce CSS specificity in my project by using the stylelint selector-max-specificity
It's an admirable goal. You can also use the other selector-max-* rules, like selector-max-class, selector-max-combinators, selector-max-compound-selectors and so on, to help you do this.
Trying to validate our CSS files , when running tests the Jigsaw tool says some of our 0 values do not have units , but we cannot find what line of CSS they're referring to.
CSS URL : https://ik.imagekit.io/mqpttb8ig/cv-16-2-2021_eL_A9soPu.css
Can someone please let me know which 0 value is preventing validation here?
Regards,
Paul
There are quite a few 0 values in your file—across margin, padding, and outline properties—but they are fine, 0 values do not need units to be appended to them.
On another note, there are way too many important flags and magic numbers—I’d worry about them more.
I have a component that includes np.sqrt(1-x). This works fine for normal operation, since all inputs will strictly be between 0 and 1. However, when checking partials and providing an input array that goes all the way up to 1, the finite differencer will step past 1, and break the component. The inputs shouldn't be less than 0 either, so simply switching the direction of the finite difference wouldn't work.
The workaround is just using np.linspace(0, 0.99, 400) instead of np.linspace(0, 1, 400).
Is it possible to set allowable bounds for the finite differencing?
As of V3.1 there isn't a way to set bounds like that. Just make sure that you test the derivatives around a more well posed point, like around 0.5.
If you're having trouble getting things to work in the optimization context, since you might bump into both bounds ... well, thats why analytic derivatives are better :)
I have question that comes from a algorithms book I'm reading and I am stumped on how to solve it (it's been a long time since I've done log or exponent math). The problem is as follows:
Suppose we are comparing implementations of insertion sort and merge sort on the same
machine. For inputs of size n, insertion sort runs in 8n^2 steps, while merge sort runs in 64n log n steps. For which values of n does insertion sort beat merge sort?
Log is base 2. I've started out trying to solve for equality, but get stuck around n = 8 log n.
I would like the answer to discuss how to solve this mathematically (brute force with excel not admissible sorry ;) ). Any links to the description of log math would be very helpful in my understanding your answer as well.
Thank you in advance!
http://www.wolframalpha.com/input/?i=solve%288+log%282%2Cn%29%3Dn%2Cn%29
(edited since old link stopped working)
Your best bet is to use Newton;s method.
http://en.wikipedia.org/wiki/Newton%27s_method
One technique to solving this would be to simply grab a graphing calculator and graph both functions (see the Wolfram link in another answer). Find the intersection that interests you (in case there are multiple intersections, as there are in your example).
In any case, there isn't a simple expression to solve n = 8 log₂ n (as far as I know). It may be simpler to rephrase the question as: "Find a zero of f(n) = n - 8 log₂ n". First, find a region containing the intersection you're interested in, and keep shrinking that region. For instance, suppose you know your target n is greater than 42, but less than 44. f(42) is less than 0, and f(44) is greater than 0. Try f(43). It's less than 0, so try 43.5. It's still less than 0, so try 43.75. It's greater than 0, so try 43.625. It's greater than 0, so keep going down, and so on. This technique is called binary search.
Sorry, that's just a variation of "brute force with excel" :-)
Edit:
For the fun of it, I made a spreadsheet that solves this problem with binary search: binary‑search.xls . The binary search logic is in the second data column, and I just auto-extended that.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In trying to solve a particular Project Euler question, I ran into difficulties with a particular mathematical formula. According to this web page (http://www.mathpages.com/home/kmath093.htm), the formula for determining the probability for rolling a sum, T, on a number of dice, n, each with number of sides, s, each numbered 1 to s, can be given as follows:
alt text http://www.freeimagehosting.net/uploads/8294d47194.gif
After I started getting nonsensical answers in my program, I started stepping through, and tried this for some specific values. In particular, I decided to try the formula for a sum T=20, for n=9 dice, each with s=4 sides. As the sum of 9 4-sided dice should give a bell-like curve of results, ranging from 4 to 36, a sum of 20 seems like it should be fairly (relatively speaking) likely. Dropping the values into the formula, I got:
alt text http://www.freeimagehosting.net/uploads/8e7b339e32.gif
Since j runs from 0 to 7, we must add over all j...but for most of these values, the result is 0, because at least one the choose formulae results are 0. The only values for j that seem to return non-0 results are 3 and 4. Dropping 3 and 4 into this formula, I got
alt text http://www.freeimagehosting.net/uploads/490f943fa5.gif
Which, when simplified, seemed to go to:
alt text http://www.freeimagehosting.net/uploads/603ca84541.gif
which eventually simplifies down to ~30.75. Now, as a probability, of course, 30.75 is way off...the probability must be between 0 and 1, so something has gone terribly wrong. But I'm not clear what it is.
Could I misunderstanding the formula? Very possible, though I'm not clear at all where the breakdown would be occuring. Could it be transcribed wrong on the web page? Also possible, but I've found it difficult to find another version of it online to check it against. Could I be just making a silly math error? Also possible...though my program comes up with a similar value, so I think it's more likely that I'm misunderstanding something.
Any hints?
(I would post this on MathOverflow.com, but I don't think it even comes close to being the kind of "postgraduate-level" mathematics that is required to survive there.)
Also: I definitely do not want the answer to the Project Euler question, and I suspect that other people that my stumble across this would feel the same way. I'm just trying to figure out where my math skills are breaking down.
According to mathworld (formula 9 is the relevant one), the formula from your source is wrong.
The correct formula is supposed to be n choose j, not n choose T. That'll really reduce the size of the values within the summation.
The mathworld formula uses k instead of j and p instead of T:
Take a look at article in wikipedia - Dice.
The formula here looks almost similar, but have one difference. I think it will solve your problem.
I'm going to have to show my ignorance here.... Isn't 9 choose 20 = 0? More generally, isn't n choose T going to always be 0 since T>=n? Perhaps I'm reading this formula incorrectly (I'm not a math expert), but looking at de Moive's work, I'm not sure how this formula was derived; it seems slightly off. You might try working up from Moive's original math, page 39, in the lemma.