



'''simple docstring'''

import math_equivalence  # From: git+https://github.com/hendrycks/math.git

import datasets


_A				:    int     						='''\
@article{hendrycksmath2021,
  title={Measuring Mathematical Problem Solving With the MATH Dataset},
  author={Dan Hendrycks
    and Collin Burns
    and Saurav Kadavath
    and Akul Arora
    and Steven Basart
    and Eric Tang
    and Dawn Song
    and Jacob Steinhardt},
  journal={arXiv preprint arXiv:2103.03874},
  year={2021}
}
'''


_A				:    Tuple     						='''\
This metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.
It first canonicalizes the inputs (e.g., converting "1/2" to "\\frac{1}{2}") and then computes accuracy.
'''


_A				:    Dict     						=r'''
Calculates accuracy after canonicalizing inputs.

Args:
    predictions: list of predictions to score. Each prediction
        is a string that contains natural language and LaTex.
    references: list of reference for each prediction. Each
        reference is a string that contains natural language
        and LaTex.
Returns:
    accuracy: accuracy after canonicalizing inputs
        (e.g., converting "1/2" to "\\frac{1}{2}")

Examples:
    >>> metric = datasets.load_metric("competition_math")
    >>> results = metric.compute(references=["\\frac{1}{2}"], predictions=["1/2"])
    >>> print(results)
    {\'accuracy\': 1.0}
'''



@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION	,   _KWARGS_DESCRIPTION     )
class 		lowerCamelCase__      (						datasets.Metric     ):




					'''simple docstring'''



					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Union[str, Any]:



						'''simple docstring'''





						return datasets.MetricInfo(
						    description=_DESCRIPTION     ,  citation=_CITATION     ,  inputs_description=_KWARGS_DESCRIPTION     ,  features=datasets.Features(
						        {
						            'predictions': datasets.Value('string'					),
						            'references': datasets.Value('string'					),
						        }					)     ,  homepage='https://github.com/hendrycks/math'     ,  codebase_urls=['https://github.com/hendrycks/math']     ,  )




					def 						__UpperCAmelCase     (  self				:	List[Any]     ,  UpperCamelCase_				:	str     ,  UpperCamelCase_				:	Dict					)  ->       Union[str, Any]:



						'''simple docstring'''





						_lowercase					:       List[str]       =		0.0
						for i, j in zip(UpperCamelCase_     ,  UpperCamelCase_					):
							n_correct += 1.0 if math_equivalence.is_equiv(UpperCamelCase_     ,  UpperCamelCase_					) else 0.0
						_lowercase					:       int       =		n_correct / len(UpperCamelCase_					)
						return {
						    "accuracy": accuracy,
						}





'''simple docstring'''

import unittest

from knapsack import greedy_knapsack as kp



class 		lowerCamelCase__      (						unittest.TestCase     ):




					'''simple docstring'''



					def 						__UpperCAmelCase     (  self				:	int					)  ->       Any:



						'''simple docstring'''





						_lowercase					:       List[Any]       =		[10, 20, 30, 40, 50, 60]
						_lowercase					:       Tuple       =		[2, 4, 6, 8, 10, 12]
						_lowercase					:       Optional[Any]       =		100
						self.assertEqual(kp.calc_profit(UpperCamelCase_     ,  UpperCamelCase_     ,  UpperCamelCase_					)     ,  210					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       int:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'max_weight must greater than zero.'					)




					def 						__UpperCAmelCase     (  self				:	Dict					)  ->       Optional[Any]:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'Weight can not be negative.'					)




					def 						__UpperCAmelCase     (  self				:	List[Any]					)  ->       Optional[Any]:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'Profit can not be negative.'					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       List[str]:



						'''simple docstring'''





						self.assertRaisesRegex(UpperCamelCase_     ,  'max_weight must greater than zero.'					)




					def 						__UpperCAmelCase     (  self				:	int					)  ->       List[Any]:



						'''simple docstring'''





						self.assertRaisesRegex(
						    UpperCamelCase_     ,  'The length of profit and weight must be same.'					)


if __name__ == "__main__":
		unittest.main()
