These are really hard words for me to write: D.C. Mayor Vincent C. Gray deserves a lot of credit for improving education in his city.

In 2011, as I was finishing a book about Michelle Rhee’s (interrupted) term as D.C. schools chancellor, I predicted that despite Chancellor Kaya Henderson’s best efforts, the city schools would enter a slow death spiral — the result of reform being undermined by Gray.

At the time, there was every reason to assume the worst. When Gray was chairman of the D.C. Council, he was Rhee’s biggest critic. When he ran for mayor, his biggest supporters were the teachers unions, especially the American Federation of Teachers, whose president, Randi Weingarten, so badly wanted to see Rhee get the boot that her union kicked in $1 million to oust former mayor Adrian Fenty, Rhee’s protector. Sure enough, after beating Fenty, Gray forced Rhee out.

Gray, I assumed, would pay back his funders and supporters by returning D.C. Public Schools (DCPS) to the pre-Rhee years, when it was a contender for the title of worst school district in the nation.

After assuming office, though, Gray did the unexpected: He left the Rhee reforms untouched. He not only embraced Henderson, he lifted not a finger to dismantle Rhee’s controversial plans, which included firing low-rated teachers and evaluating teachers partly based on how much their students learned. Why would Gray not do what his key backers most wanted? My cynical take was that the scandals that grew out of his campaign prevented him from taking on anything controversial.

But then Gray did the unexpected once again. He appointed one of Rhee’s top deputies, the talented Abigail Smith, as his deputy mayor for education. Now he had two of Rhee’s top aides, Henderson and Smith, holding the top education posts. Then we got the announcement that D.C. charter schools, which had been mostly blocked from taking over closed DCPS schools, suddenly had options for using those buildings. At that point, my “scandals” theory was looking shaky.

Now come this good-news test scores. True, the results must be placed in context. With urban school districts, good news one year has a tendency to become bad news the following year. Plus, the assessments that really matter are federal ones, which are both cheat-proof and comparable to other urban districts. We’ll see.

Keeping that in mind, however, there was certainly some good news this week, especially the boost in academic proficiency rates among low-income black and Latino kids in charter schools — schools that Gray, unlike some previous mayors, properly sees as giving D.C. parents important academic choices for their children.

So why did Gray stand by the much-reviled Rhee reforms that his supporters counted on him to dismantle? I don’t pretend to know anything about Gray. When I was researching the Rhee book, he refused an interview. But everything I’ve read about Gray leads me to believe that he is, through and through, a Ward 7 guy. And there in Ward 7 sits Sousa Middle School, a school that for years was properly regarded as a local and national disgrace.

Under the tough-love principal Rhee appointed, Sousa transformed itself into a showcase. You can walk through the school’s quiet hallways and see actual learning taking place. Gray may not have been a Rhee fan, but no real Ward 7 guy is going to deny that her reforms made a huge difference for the kids at Sousa. For the first time, they had a shot at life. Something that crazy lady was doing had to be right.

Richard Whitmire is the author of “The Bee Eater: Michelle Rhee Takes on the Nation’s Worst School District.”