<commit_before>/************************************************************************//**
 * KernelInfo class definitions for RMagick.
 *
 * Copyright &copy; RMagick Project
 *
 * @file rmkinfo.c
 * @version $Id: rmkinfo.c,v 1.0 2011/11/29 15:33:14 naquad Exp $
 * @author Naquad
 ****************************************************************************/

#include "rmagick.h"

/**
 * If there's a kernel info, delete it before destroying the KernelInfo 
 *
 * No Ruby usage (internal function)
 *
 * @param kernel pointer to the KernelInfo object associated with instance
 */

static void
rm_kernel_info_destroy(void *kernel)
{
  if (kernel)
    DestroyKernelInfo((KernelInfo*)kernel);
}

/**
 * Create a KernelInfo object.
 *
 * No Ruby usage (internal function)
 *
 * @param class the Ruby class to use
 * @return a new KernelInfo object
 */
VALUE
KernelInfo_alloc(VALUE class)
{
  return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
}

/**
 * KernelInfo object constructor
 *
 * Ruby usage:
 *   - @verbatim KernelInfo#initialize @endverbatim
 *
 * @param self this object
 * @param kernel_string kernel info string representation to be parsed
 * @return self
 */
VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
  KernelInfo *kernel;

  Check_Type(kernel_string, T_STRING);

  kernel = AcquireKernelInfo(StringValueCStr(kernel_string));

  if (kernel == NULL)
    rb_raise(rb_eRuntimeError, "failed to parse kernel string");

  DATA_PTR(self) = kernel;

  return self;
}

/**
 * Zero kerne NaNs.
 *
 * Ruby usage:
 *   - @verbatim KernelInfo#zero_nans @endverbatim
 *
 * @param self this object
 */
VALUE
KernelInfo_zero_nans(VALUE self)
{
  ZeroKernelNans((KernelInfo*)DATA_PTR(self));
  return Qnil;
}

/**
 * Adds a given amount of the 'Unity' Convolution Kernel to the given pre-scaled and normalized Kernel.
 *
 * Ruby usage:
 *   - @verbatim KernelInfo#unity_add(scale) @endverbatim
 *
 * @param self this object
 * @param scale scale to add
 */
VALUE
KernelInfo_unity_add(VALUE self, VALUE scale)
{<commit_msg>Marked KernelInfo#zero_nans as deprecated. (#531)<commit_after>/************************************************************************//**
 * KernelInfo class definitions for RMagick.
 *
 * Copyright &copy; RMagick Project
 *
 * @file rmkinfo.c
 * @version $Id: rmkinfo.c,v 1.0 2011/11/29 15:33:14 naquad Exp $
 * @author Naquad
 ****************************************************************************/

#include "rmagick.h"

/**
 * If there's a kernel info, delete it before destroying the KernelInfo 
 *
 * No Ruby usage (internal function)
 *
 * @param kernel pointer to the KernelInfo object associated with instance
 */

static void
rm_kernel_info_destroy(void *kernel)
{
  if (kernel)
    DestroyKernelInfo((KernelInfo*)kernel);
}

/**
 * Create a KernelInfo object.
 *
 * No Ruby usage (internal function)
 *
 * @param class the Ruby class to use
 * @return a new KernelInfo object
 */
VALUE
KernelInfo_alloc(VALUE class)
{
  return Data_Wrap_Struct(class, NULL, rm_kernel_info_destroy, NULL);
}

/**
 * KernelInfo object constructor
 *
 * Ruby usage:
 *   - @verbatim KernelInfo#initialize @endverbatim
 *
 * @param self this object
 * @param kernel_string kernel info string representation to be parsed
 * @return self
 */
VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
  KernelInfo *kernel;

  Check_Type(kernel_string, T_STRING);

  kernel = AcquireKernelInfo(StringValueCStr(kernel_string));

  if (kernel == NULL)
    rb_raise(rb_eRuntimeError, "failed to parse kernel string");

  DATA_PTR(self) = kernel;

  return self;
}

/**
 * Zero kerne NaNs.
 *
 * Ruby usage:
 *   - @verbatim KernelInfo#zero_nans @endverbatim
 *
 * @param self this object
 * @deprecated This method has been deprecated.
 */
VALUE
KernelInfo_zero_nans(VALUE self)
{
  rb_warning("KernelInfo#zero_nans is deprecated");
  ZeroKernelNans((KernelInfo*)DATA_PTR(self));
  return Qnil;
}

/**
 * Adds a given amount of the 'Unity' Convolution Kernel to the given pre-scaled and normalized Kernel.
 *
 * Ruby usage:
 *   - @verbatim KernelInfo#unity_add(scale) @endverbatim
 *
 * @param self this object
 * @param scale scale to add
 */
VALUE
KernelInfo_unity_add(VALUE self, VALUE scale)
{
{'fraction_non_alphanumeric': 0.16878232251998118, 'fraction_numerical': 0.008227550540667606, 'mean_word_length': 4.583989501312336, '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': '5964119', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1286, 'n_words': 385}