Energy measurement from position eigenstate Given that the eigenstates of the position operator can be written as $\delta(x-x')$, and suppose we measure a particle in an infinite potential with walls at $x=0$ and $x=L$. I measure the particle to be in the position $x=L/2$, so the particle is in the eigenstate $ |x \rangle = \delta(x-L/2)$. Suppose now that I want to measure the energy of the particle. The eigenstates of the energy operator are given by:
$$ |\psi_n\rangle = \sqrt{\frac{2}{L}}\sin \left( \frac{n\pi x}{L} \right) $$
In order to measure energy I understand that I have to expand the original eigenstate in terms of the new energy eigenstates:
$$
|x\rangle = \sum|\psi_n\rangle\langle\psi_n|x\rangle
$$
where the probability of collapse into the eigenstate is given by:
$$
P_n = |\langle\psi_n|x\rangle|^2
$$
But now I sort of run into an issue. Sure then, I can say that:
$$
\langle\psi_n|x\rangle = \int \sqrt{\frac{2}{L}}\sin \left( \frac{n\pi x}{L} \right)\delta(x-L/2)dx
$$
and since
$$
\int \delta(x-x')f(x)dx = f(x')
$$
I can say
$$
\langle\psi_n|x\rangle = \sqrt{\frac{2}{L}}\sin \left( \frac{n\pi }{2} \right)
$$
and,
$$
P_n=|\langle\psi_n|x\rangle|^2 = \frac{2}{L}\sin^2 \left( \frac{n\pi}{2} \right)
$$
I know that this means that all odd values of n are equally probably and all even values are not possible, but probability is supposed to be dimensionless, so what's happened here? What rookie error have I made?
 A: The formula
$$
 P_n = |\langle\psi_n|\psi\rangle|^2
$$
assumes that the pre-measurement state $|\psi\rangle$ and the observable's eigenstates $|\psi_n\rangle$ are both normalized to be unit state-vectors. In other words, the formula for arbitrary non-zero state-vectors is
$$
 P_n = \frac{|\langle\psi_n|\psi\rangle|^2}{
  \langle\psi_n|\psi_n\rangle\,\langle\psi|\psi\rangle}.
$$
Notice that this expression for $P_n$ is dimensionless by construction.
The problem with the case described in the OP is that $|x\rangle=\delta(x-L/2)$ is not normalizable: it does not belong to the Hilbert space, so it can't be used for the pre-measurement state $|\psi\rangle$.
That's not a problem in principle, because real position-measurments don't have infinite precision, so the state after a real position-measurement would not be $|x\rangle$. It would be some normalizable state-vector $|\psi\rangle$ whose corresponding wavefunction is sharply concentrated near a particular position, but with a non-zero width that makes it normalizable.
A: The problem, as formed, is malformed and meaningless, as it is obviously dimensionally inconsistent, as pointed out in my comments. Nevertheless, there is method in its madness: it has, of course, a good point, and can be redeemed/salvaged  by tweaking it into something more meaningful.
First, recall the $\delta$-function is but the vanishing-width limit of the Gaussian,
$$
\delta(x)= \lim_{a\to 0}\frac{1}{a\sqrt{\pi}} e^{-x^2/a^2}.
$$
Note $a$ has dimensions of length, so the above has dimensions of inverse length: a warning sign.
Since the integral of this is 1, but the integral of its square is singular, 
you'd better not use this as a wavefunction! 
If you wanted a wavefunction peaking at 0, you might as well call the above a probability density, instead, and take your wavefunction as its square root, before taking the limit,
$$
\psi_a(x)=\langle x|\psi\rangle = \frac{1}{\sqrt{a}~\pi^{1/4}}e^{-x^2/2a^2},
$$
obviously normalized, and with the right dimensions.
In your case, you center it at L/2, so it is 
$$
\psi_a(x)=\langle x|\psi_a\rangle = \frac{1}{\sqrt{a}~\pi^{1/4}}\exp \left ({-\frac{(x-L/2)^2}{2a^2}}\right ) ,
$$
so that 
$$
P_n= |\langle \psi_n|\psi_a\rangle      |^2 ,
$$
with 
$$
\langle \psi_n| \psi_a\rangle=\frac{\sqrt{2}}{\sqrt{aL}~\pi^{1/4}}\int_0^L dx ~ \sin (n\pi x/L)~e^{-\frac{(x-L/2)^2}{2a^2}} ,
$$
now dimensionless.
From the symmetry of the integral, you exclude even values for n, as you did, and shift and rescale variables to 
$$
\langle \psi_n| \psi_a\rangle=\frac{\sqrt{2a}}{\sqrt{L}~\pi^{1/4}}\int_{-L/2a}^{L/2a} dy ~ \sin (n\pi (ya/L +1/2))~e^{-y^2/2} .
$$ 
You note that in the $a\to 0$ limit, this is independent of n, but, of course, the normalization is comeasurately going to 0, as it should, given equipartition to an infinity of equal modes. 
