<commit_before># -------------------------------------------------------------------------------
# Name:        test_trafo
# Purpose:     testing file for the wradlib.trafo module
#
# Authors:     <NAME>, <NAME> and <NAME>
#
# Created:     12.03.2013
# Copyright:   (c) <NAME>, <NAME> and <NAME> 2011
# Licence:     The MIT License
# -------------------------------------------------------------------------------
# !/usr/bin/env python
import unittest
import numpy as np
import wradlib.trafo as trafo


class TransformationTest(unittest.TestCase):
    def setUp(self):
        self.rvp = np.array([0., 128., 255.])
        self.dbz = np.array([-32.5, 31.5, 95.0])
        self.lin = np.array([1e-4, 1, 1e4])
        self.dec = np.array([-40, 0, 40])
        self.r = np.array([5., 10., 20.])
        self.speedsi = np.array([0., 1., 50.])  # speed in m/s
        self.speedkmh = np.array([0., 3.6, 180.])  # speed in km/h
        self.speedmph = np.array([0., 2.23693629, 111.8468146])  # speed in miles/h
        self.speedkts = np.array([0., 1.94384449, 97.19222462])  # speed in knots

    def test_rvp2dBZ(self):
        self.assertTrue(np.allclose(trafo.rvp2dBZ(self.rvp), self.dbz))

    def test_decibel(self):
        self.assertTrue(np.allclose(trafo.decibel(self.lin), self.dec))

    def test_idecibel(self):
        self.assertTrue(np.allclose(trafo.idecibel(self.dec), self.lin))

    def test_r2depth(self):
        self.assertTrue(np.allclose(trafo.r2depth(self.r, 720), np.array([1., 2., 4.])))
        self.assertTrue(np.allclose(trafo.r2depth(self.r, 360), np.array([0.5, 1., 2.])))

    def test_si2kmh(self):
        self.assertTrue(np.allclose(trafo.si2kmh(self.speedsi), self.speedkmh))

    def test_si2mph(self):
        self.assertTrue(np.allclose(trafo.si2mph(self.speedsi), self.speedmph))

    def test_si2kts(self):
        self.assertTrue(np.allclose(trafo.si2kts(self.speedsi), self.speedkts))

    def test_kmh2si(self):
        self.assertTrue(np.allclose(trafo.kmh2si(self.speedkmh), self.speedsi))

    def test_mph2si(self):
        self.assertTrue(np.allclose(trafo.mph2si(self.speedmph), self.speedsi))<commit_msg>WIP: add `test_kdp2r` in `test_trafo.py`<commit_after># -------------------------------------------------------------------------------
# Name:        test_trafo
# Purpose:     testing file for the wradlib.trafo module
#
# Authors:     <NAME>, <NAME> and <NAME>
#
# Created:     12.03.2013
# Copyright:   (c) <NAME>, <NAME> and <NAME> 2011
# Licence:     The MIT License
# -------------------------------------------------------------------------------
# !/usr/bin/env python
import unittest
import numpy as np
import wradlib.trafo as trafo


class TransformationTest(unittest.TestCase):
    def setUp(self):
        self.rvp = np.array([0., 128., 255.])
        self.dbz = np.array([-32.5, 31.5, 95.0])
        self.lin = np.array([1e-4, 1, 1e4])
        self.dec = np.array([-40, 0, 40])
        self.r = np.array([5., 10., 20.])
        self.kdp = np.array([0., 1., 2., 5.])
        self.speedsi = np.array([0., 1., 50.])  # speed in m/s
        self.speedkmh = np.array([0., 3.6, 180.])  # speed in km/h
        self.speedmph = np.array([0., 2.23693629, 111.8468146])  # speed in miles/h
        self.speedkts = np.array([0., 1.94384449, 97.19222462])  # speed in knots

    def test_rvp2dBZ(self):
        self.assertTrue(np.allclose(trafo.rvp2dBZ(self.rvp), self.dbz))

    def test_decibel(self):
        self.assertTrue(np.allclose(trafo.decibel(self.lin), self.dec))

    def test_idecibel(self):
        self.assertTrue(np.allclose(trafo.idecibel(self.dec), self.lin))

    def test_r2depth(self):
        self.assertTrue(np.allclose(trafo.r2depth(self.r, 720), np.array([1., 2., 4.])))
        self.assertTrue(np.allclose(trafo.r2depth(self.r, 360), np.array([0.5, 1., 2.])))

    def test_kdp2r(self):
        self.assertTrue(np.allclose(trafo.kdp2r(self.kdp, 9.45), np.array([0., 19.11933017, 34.46261032, 75.09260608])))

    def test_si2kmh(self):
        self.assertTrue(np.allclose(trafo.si2kmh(self.speedsi), self.speedkmh))

    def test_si2mph(self):
        self.assertTrue(np.allclose(trafo.si2mph(self.speedsi), self.speedmph))

    def test_si2kts(self):
        self.assertTrue(np.allclose(trafo.si2kts(self.speedsi), self.speedkts))

    def test_kmh2si(self):
        self.assertTrue(np.allclose(trafo.kmh2si(self.speedkmh), self.speedsi))

    def test_mph2si(self):
        self.assertTrue(np.allclose(trafo.mph2si(self.speedmph), self.speedsi))
{'fraction_non_alphanumeric': 0.22619836536337531, 'fraction_numerical': 0.06251380605257345, 'mean_word_length': 2.293090909090909, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3280787', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1665, 'n_words': 288}