Let's consider the "black note" between G and A. If this note does not occur in a scale/key, but it nevertheless occurs in a composition based on that scale/key, what are the rules for rendering it G♯ or A♭ if, say, the piece was in C major? I know there are preferences for using the least amount of ink and showing note motion. For example, if the notes which preceded and succeeded it were both G, A♭ would be preferred because it shows the note on a higher line/space and (assuming no A appears later in the measure) a natural is not needed to cancel it. But let's say all things are equal. What rules then govern the spelling of the note?
I chose G♯/A♭ because it occurs as often in flat keys as it does in sharp keys (by contrast, B♭ occurs in every flat key while A♯ doesn't enter the picture until the key signature has 5 sharps) and I chose C major because it has no accidentals in its key signature.