Electrically charged particles in a topologically complicated four-dimensional space-time can be assigned consistent complex wave-functions provided the background electro-magnetic fields satisfy `Dirac quantisation conditions' that may differ depending on whether the wave-function is scalar or spinor in nature. A test of 'electromagnetic duality' is that a generalised 'partition function' transforms nicely under the action of the full modular group. This test is passed only if both sorts of background electromagnetic field are included in the partition function sums. The argument brings into play a rich mathematical structure and raises a number of new questions.