<commit_before>module Bonz
  module MatGeneralMixin
    extend self

    def included(mod)
      mod.include(InstanceMethods)
      mod.extend(ClassMethods)
    end

    module InstanceMethods
      # @see fill
      def fill_points(value, points)
        copy.fill_points!(value, points)
      end

      # @see fill!
      def fill_points!(value, points)
        points.each { |p| self[p.y, p.x] = value }
        self
      end

      # Convert to single channel. If already single channel, return :self:.
      # Assumes any 3- or 4-channel image is BGR(A) (not HSV).
      def to_gray
        case channel
        when 1 then self
        when 3 then self.BGR2GRAY
        when 4 then self.BGRA2GRAY
        else split.first
        end
      end
    end

    # Convert to BGR. If already BGR, return :self:. Assumes any 3- or
    # 4-channel image is already BGR(A) (not HSV).
    def to_bgr
      case channel
      when 1 then self.GRAY2BGR
      when 3 then self
      when 4 then self.BGRA2BGR
      else split.first
      end
    end

    module ClassMethods
      def new_sized(size)
        new(size.height, size.width)
      end
    end
  end
end
<commit_msg>Minor cleanup<commit_after>module Bonz
  module MatGeneralMixin
    extend self

    def included(mod)
      mod.include(InstanceMethods)
      mod.extend(ClassMethods)
    end

    module InstanceMethods
      # @see fill
      def fill_points(value, points)
        copy.fill_points!(value, points)
      end

      # @see fill!
      def fill_points!(value, points)
        points.each { |p| self[p.y, p.x] = value }
        self
      end

      # Convert to single channel. If already single channel, return :self:.
      # Assumes any 3- or 4-channel image is BGR(A) (not HSV).
      def to_gray
        case channel
        when 1 then self
        when 3 then self.BGR2GRAY
        when 4 then self.BGRA2GRAY
        else split.first
        end
      end
    end

    # Convert to BGR. If already BGR, return :self:. Assumes any 3- or
    # 4-channel image is already BGR(A) (not HSV).
    def to_bgr
      case channel
      when 1 then self.GRAY2BGR
      when 3 then self
      when 4 then self.BGRA2BGR
      else raise ArgumentError # ambiguous what to do here
      end
    end

    module ClassMethods
      def new_sized(size)
        new(size.height, size.width)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06717044500419815, 'fraction_numerical': 0.011754827875734676, 'mean_word_length': 1.8780193236714975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1658357', 'n_tokens_mistral': 770, 'n_tokens_neox': 730, 'n_words': 253}