def root(n)
      raise ArgumentError, 'Cannot take the root of a temperature' if temperature?
      raise ArgumentError, 'Exponent must an Integer' unless n.is_a?(Integer)
      raise ArgumentError, '0th root undefined' if n.zero?
      return self if n == 1
      return root(n.abs).inverse if n < 0

      vec = unit_signature_vector
      vec = vec.map { |x| x % n }
      raise ArgumentError, 'Illegal root' unless vec.max.zero?
      num = @numerator.dup
      den = @denominator.dup

      @numerator.uniq.each do |item|
        x = num.find_all { |i| i == item }.size
        r = ((x / n) * (n - 1)).to_int
        r.times { num.delete_at(num.index(item)) }
      end

      @denominator.uniq.each do |item|
        x = den.find_all { |i| i == item }.size
        r = ((x / n) * (n - 1)).to_int
        r.times { den.delete_at(den.index(item)) }
      end
      RubyUnits::Unit.new(scalar: @scalar**Rational(1, n), numerator: num, denominator: den)
    end
def root(n)
      raise ArgumentError, 'Cannot take the root of a temperature' if temperature?
      raise ArgumentError, 'Exponent must an Integer' unless n.is_a?(Integer)
      raise ArgumentError, '0th root undefined' if n.zero?
      return self if n == 1
      return root(n.abs).inverse if n < 0

      vec = unit_signature_vector
      vec = vec.map { |x| x % n }
      raise ArgumentError, 'Illegal root' unless vec.max.zero?
      num = @numerator.dup
      den = @denominator.dup

      @numerator.uniq.each do |item|
        x = num.find_all { |i| i == item }.size
        r = ((x / n) * (n - 1)).to_int
        r.times { num.delete_at(num.index(item)) }
      end

      @denominator.uniq.each do |item|
        x = den.find_all { |i| i == item }.size
        r = ((x / n) * (n - 1)).to_int
        r.times { den.delete_at(den.index(item)) }
      end
      RubyUnits::Unit.new(scalar: @scalar**Rational(1, n), numerator: num, denominator: den)
    end
Calculates the n-th root of a unit
 if n < 0, returns 1/unit^(1/n)
 @param [Integer] n
 @return [Unit]
 @raise [ArgumentError] when attemptint to take the root of a temperature
 @raise [ArgumentError] when n is not an integer
 @raise [ArgumentError] when n is 0