<commit_before>defmodule Xema.Helper.Number do
  @moduledoc """
  TODO
  """

  def minimum?(nil, nil, _number), do: :ok
  def minimum?(minimum, true, number) do
    cond do
      number > minimum ->
        :ok
      number == minimum ->
        {:error, %{minimum: minimum, exclusive_minimum: true}}
      true ->
        {:error, %{minimum: minimum}}
    end
  end
  def minimum?(minimum, nil, number),
    do: if number >= minimum,
          do: :ok,
          else: {:error, %{minimum: minimum}}

  defp maximum?(%Xema.Number{maximum: nil}, _number), do: :ok
  defp maximum?(
    %Xema.Number{maximum: maximum, exclusive_maximum: true},
    number
  ) do
    cond do
      number < maximum ->
        :ok
      number == maximum ->
        {:error, %{maximum: maximum, exclusive_maximum: true}}
      true ->
        {:error, %{maximum: maximum}}
    end
  end
  defp maximum?(%Xema.Number{maximum: maximum}, number),
    do: if number <= maximum,
          do: :ok,
          else: {:error, %{maximum: maximum}}

  defp multiple_of?(%Xema.Number{multiple_of: nil}, _number), do: :ok
  defp multiple_of?(%Xema.Number{multiple_of: multiple_of}, number),
    do: if multiple_of?(number, multiple_of),
          do: :ok,
          else: {:error, %{multiple_of: multiple_of}}
  defp multiple_of?(a, b) do
    x = a / b
    x - Float.floor(x) == 0
  end
end<commit_msg>Update number helper<commit_after>defmodule Xema.Helper.Number do
  @moduledoc """
  TODO
  """

  def minimum?(minimum, _exclusive, number)
    when number > minimum,
    do: :ok
  def minimum?(minimum, nil, number)
    when number == minimum,
    do: :ok
  def minimum?(minimum, false, number)
    when number == minimum,
    do: :ok
  def minimum?(minimum, true, number)
    when number == minimum,
    do: {:error, %{minimum: minimum, exclusive_minimum: true}}
  def minimum?(minimum, _exclusive, _number),
    do: {:error, %{minimum: minimum}}

  def maximum?(maximum, _exclusive, number)
    when number < maximum,
    do: :ok
  def maximum?(maximum, nil, number)
    when number == maximum,
    do: :ok
  def maximum?(maximum, false, number)
    when number == maximum,
    do: :ok
  def maximum?(maximum, true, number)
    when number == maximum,
    do: {:error, %{maximum: maximum, exclusive_maximum: true}}
  def maximum?(maximum, _exclusive, _number),
    do: {:error, %{maximum: maximum}}

  def multiple_of?(multiple_of, number),
    do: if _multiple_of?(multiple_of, number),
          do: :ok,
          else: {:error, %{multiple_of: multiple_of}}
  defp _multiple_of?(a, b) do
    x = b / a
    x - Float.floor(x) == 0
  end
end
{'fraction_non_alphanumeric': 0.14422341239479725, 'fraction_numerical': 0.0007651109410864575, 'mean_word_length': 2.90881913303438, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, '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': '5276164', 'n_tokens_mistral': 894, 'n_tokens_neox': 854, 'n_words': 253}