MAINT: Move _get_median into sparsefuncs to avoid circular imports