Yes, gender is locked. Even if your test magikarp hatched into male, once you swap out to pokemon with a different gender ratio, the IV distribtution will still be the same, but the gender won't be guaranteed to be the same as your test magikarp, which is the reason magikarp is really just good...