<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Tests methods of the TEC_Langmuir class.
"""

__author__ = "<NAME> (<EMAIL>)"
__version__ = ""
__date__ = ""
__copyright__ = "Copyright (c) 2013 <NAME>"
__license__ = ""

from tec import TEC_Langmuir
import unittest
import pickle

class MethodsSpecialCase(unittest.TestCase):
  """
  Tests the special cases of the methods.
  """
  pass
  
class MethodsValues(unittest.TestCase):
  """
  Tests the output of the methods match some expected values.
  """
  
  def setUp(self):
    """
    Unpickle the standard data for use in the tests.
    """
    
    self.std = pickle.load(open("test/TEC_Langmuir_temporary_STANDARD.dat","r"))
  
  def test_calc_saturation_pt_output_voltage(self):
    """
    calc_saturation_pt output_voltage matches standard values.
    """
    TECL = TEC_Langmuir(self.std[0])
    output_params = TECL.calc_saturation_pt()
    output_voltage = output_params["output_voltage"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(self.std[0]["Collector"]["voltage"]/output_voltage,1,places=4)

  def test_calc_saturation_pt_output_current_density(self):
    """
    calc_saturation_pt output_current_density matches standard values.
    """
    TECL = TEC_Langmuir(self.std[0])
    output_params = TECL.calc_saturation_pt()
    output_current_density = output_params["output_current_density"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(1e4*self.std[0]["output_current_density"]/output_current_density,1,places=3)

  def test_calc_critical_pt_output_voltage(self):
    """
    calc_critical_pt output_voltage matches standard values.
    """
    TECL = TEC_Langmuir(self.std[-1])
    output_params = TECL.calc_critical_pt()
    output_voltage = output_params["output_voltage"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(self.std[-1]["Collector"]["voltage"]/output_voltage,1,places=4)

  def test_calc_critical_pt_output_current_density(self):
    """
    calc_critical_pt output_current_density matches standard values.
    """
    TECL = TEC_Langmuir(self.std[-1])
    output_params = TECL.calc_critical_pt()
    output_current_density = output_params["output_current_density"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(1e4*self.std[-1]["output_current_density"]/output_current_density,1,places=3)
    
  def test_calc_output_current_density(self):
    """
    calc_output_current_density matches standard values.
    """
    for data in self.std:
      TECL = TEC_Langmuir(data)
      # Set the following to a very low precision.
      self.assertAlmostEqual(1e4*data["output_current_density"]/TECL.calc_output_current_density(),\
        1,places=3)<commit_msg>Reduced precision of almostEqual test.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Tests methods of the TEC_Langmuir class.
"""

__author__ = "<NAME> (<EMAIL>)"
__version__ = ""
__date__ = ""
__copyright__ = "Copyright (c) 2013 <NAME>"
__license__ = ""

from tec import TEC_Langmuir
import unittest
import pickle

class MethodsSpecialCase(unittest.TestCase):
  """
  Tests the special cases of the methods.
  """
  pass
  
class MethodsValues(unittest.TestCase):
  """
  Tests the output of the methods match some expected values.
  """
  
  def setUp(self):
    """
    Unpickle the standard data for use in the tests.
    """
    
    self.std = pickle.load(open("test/TEC_Langmuir_temporary_STANDARD.dat","r"))
  
  def test_calc_saturation_pt_output_voltage(self):
    """
    calc_saturation_pt output_voltage matches standard values.
    """
    TECL = TEC_Langmuir(self.std[0])
    output_params = TECL.calc_saturation_pt()
    output_voltage = output_params["output_voltage"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(self.std[0]["Collector"]["voltage"]/output_voltage,1,places=4)

  def test_calc_saturation_pt_output_current_density(self):
    """
    calc_saturation_pt output_current_density matches standard values.
    """
    TECL = TEC_Langmuir(self.std[0])
    output_params = TECL.calc_saturation_pt()
    output_current_density = output_params["output_current_density"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(1e4*self.std[0]["output_current_density"]/output_current_density,1,places=3)

  def test_calc_critical_pt_output_voltage(self):
    """
    calc_critical_pt output_voltage matches standard values.
    """
    TECL = TEC_Langmuir(self.std[-1])
    output_params = TECL.calc_critical_pt()
    output_voltage = output_params["output_voltage"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(self.std[-1]["Collector"]["voltage"]/output_voltage,1,places=4)

  def test_calc_critical_pt_output_current_density(self):
    """
    calc_critical_pt output_current_density matches standard values.
    """
    TECL = TEC_Langmuir(self.std[-1])
    output_params = TECL.calc_critical_pt()
    output_current_density = output_params["output_current_density"]
    # Set the following to a very low precision.
    self.assertAlmostEqual(1e4*self.std[-1]["output_current_density"]/output_current_density,1,places=3)
    
  def test_calc_output_current_density(self):
    """
    calc_output_current_density matches standard values.
    """
    for data in self.std:
      TECL = TEC_Langmuir(data)
      # Set the following to a very low precision.
      self.assertAlmostEqual(1e4*data["output_current_density"]/TECL.calc_output_current_density(),\
        1,places=2)
{'fraction_non_alphanumeric': 0.10991572530034069, 'fraction_numerical': 0.010399856553702708, 'mean_word_length': 4.373795761078998, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '797910', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1799, 'n_words': 351}