# Path: smtk/sm_utils.py
# def convert_accel_units(acceleration, from_, to_='cm/s/s'):  # noqa
#     """
#     Converts acceleration from/to different units
# 
#     :param acceleration: the acceleration (numeric or numpy array)
#     :param from_: unit of `acceleration`: string in "g", "m/s/s", "m/s**2",
#         "m/s^2", "cm/s/s", "cm/s**2" or "cm/s^2"
#     :param to_: new unit of `acceleration`: string in "g", "m/s/s", "m/s**2",
#         "m/s^2", "cm/s/s", "cm/s**2" or "cm/s^2". When missing, it defaults
#         to "cm/s/s"
# 
#     :return: acceleration converted to the given units (by default, 'cm/s/s')
#     """
#     m_sec_square = ("m/s/s", "m/s**2", "m/s^2")
#     cm_sec_square = ("cm/s/s", "cm/s**2", "cm/s^2")
#     acceleration = np.asarray(acceleration)
#     if from_ == 'g':
#         if to_ == 'g':
#             return acceleration
#         if to_ in m_sec_square:
#             return acceleration * g
#         if to_ in cm_sec_square:
#             return acceleration * (100 * g)
#     elif from_ in m_sec_square:
#         if to_ == 'g':
#             return acceleration / g
#         if to_ in m_sec_square:
#             return acceleration
#         if to_ in cm_sec_square:
#             return acceleration * 100
#     elif from_ in cm_sec_square:
#         if to_ == 'g':
#             return acceleration / (100 * g)
#         if to_ in m_sec_square:
#             return acceleration / 100
#         if to_ in cm_sec_square:
#             return acceleration
# 
#     raise ValueError("Unrecognised time history units. "
#                      "Should take either ''g'', ''m/s/s'' or ''cm/s/s''")
# 
# SCALAR_XY = {
#     "Geometric": lambda x, y: np.sqrt(x * y),
#     "Arithmetic": lambda x, y: (x + y) / 2.,
#     "Larger": lambda x, y: np.max(np.array([x, y]), axis=0),
#     "Vectorial": lambda x, y: np.sqrt(x ** 2. + y ** 2.)
# }


import os
import sys
import unittest
import numpy as np
from datetime import datetime
from scipy.constants import g
from smtk.sm_utils import convert_accel_units, SCALAR_XY
                              convert_accel_units_old(acc, 'g')/100)

            # check that the old calls to convert_accel_units:
            # are the same as the actual:
            for unit in ['g', 'cm/s/s', 'm/s/s']:
                self.assertNEqual(convert_accel_units_old(acc, unit),
                                  func(acc, unit))

            with self.assertRaises(ValueError):  # invalid units 'a':
                func(acc, 'a')

    def tst_scalar_xy(self):
        '''Commented out: it tested whether SCALAR_XY supported numpy
        array, it does not'''
        argslist = [(np.nan, np.nan),
                    (1, 2),
                    (3.5, -4.706),
                    (np.array([np.nan, 1, 3.5]),
                     np.array([np.nan, 2, -4.706]))]

        types = ['Geometric', 'Arithmetic', 'Larger', 'Vectorial']

        # SCALAR_XY = {"Geometric": lambda x, y: np.sqrt(x * y),
        #              "Arithmetic": lambda x, y: (x + y) / 2.,
        #              "Larger": lambda x, y: np.max(np.array([x, y])),
        #              "Vectorial": lambda x, y: np.sqrt(x ** 2. + y ** 2.)}
        expected = {
            'Geometric': [np.nan, np.sqrt(1 * 2), np.sqrt(3.5 * -4.706),
                          [np.nan, np.sqrt(1 * 2), np.sqrt(3.5 * -4.706)]],
            'Arithmetic': [np.nan, (1+2.)/2., (3.5 - 4.706)/2,

# Path: smtk/sm_utils.py
# def convert_accel_units(acceleration, from_, to_='cm/s/s'):  # noqa
#     """
#     Converts acceleration from/to different units
# 
#     :param acceleration: the acceleration (numeric or numpy array)
#     :param from_: unit of `acceleration`: string in "g", "m/s/s", "m/s**2",
#         "m/s^2", "cm/s/s", "cm/s**2" or "cm/s^2"
#     :param to_: new unit of `acceleration`: string in "g", "m/s/s", "m/s**2",
#         "m/s^2", "cm/s/s", "cm/s**2" or "cm/s^2". When missing, it defaults
#         to "cm/s/s"
# 
#     :return: acceleration converted to the given units (by default, 'cm/s/s')
#     """
#     m_sec_square = ("m/s/s", "m/s**2", "m/s^2")
#     cm_sec_square = ("cm/s/s", "cm/s**2", "cm/s^2")
#     acceleration = np.asarray(acceleration)
#     if from_ == 'g':
#         if to_ == 'g':
#             return acceleration
#         if to_ in m_sec_square:
#             return acceleration * g
#         if to_ in cm_sec_square:
#             return acceleration * (100 * g)
#     elif from_ in m_sec_square:
#         if to_ == 'g':
#             return acceleration / g
#         if to_ in m_sec_square:
#             return acceleration
#         if to_ in cm_sec_square:
#             return acceleration * 100
#     elif from_ in cm_sec_square:
#         if to_ == 'g':
#             return acceleration / (100 * g)
#         if to_ in m_sec_square:
#             return acceleration / 100
#         if to_ in cm_sec_square:
#             return acceleration
# 
#     raise ValueError("Unrecognised time history units. "
#                      "Should take either ''g'', ''m/s/s'' or ''cm/s/s''")
# 
# SCALAR_XY = {
#     "Geometric": lambda x, y: np.sqrt(x * y),
#     "Arithmetic": lambda x, y: (x + y) / 2.,
#     "Larger": lambda x, y: np.max(np.array([x, y]), axis=0),
#     "Vectorial": lambda x, y: np.sqrt(x ** 2. + y ** 2.)
# }


# Path: tests/sm_utils_test.py
import os
import sys
import unittest
import numpy as np
from datetime import datetime
from scipy.constants import g
from smtk.sm_utils import convert_accel_units, SCALAR_XY

                              convert_accel_units_old(acc, 'g')/100)

            # check that the old calls to convert_accel_units:
            # are the same as the actual:
            for unit in ['g', 'cm/s/s', 'm/s/s']:
                self.assertNEqual(convert_accel_units_old(acc, unit),
                                  func(acc, unit))

            with self.assertRaises(ValueError):  # invalid units 'a':
                func(acc, 'a')

    def tst_scalar_xy(self):
        '''Commented out: it tested whether SCALAR_XY supported numpy
        array, it does not'''
        argslist = [(np.nan, np.nan),
                    (1, 2),
                    (3.5, -4.706),
                    (np.array([np.nan, 1, 3.5]),
                     np.array([np.nan, 2, -4.706]))]

        types = ['Geometric', 'Arithmetic', 'Larger', 'Vectorial']

        # SCALAR_XY = {"Geometric": lambda x, y: np.sqrt(x * y),
        #              "Arithmetic": lambda x, y: (x + y) / 2.,
        #              "Larger": lambda x, y: np.max(np.array([x, y])),
        #              "Vectorial": lambda x, y: np.sqrt(x ** 2. + y ** 2.)}
        expected = {
            'Geometric': [np.nan, np.sqrt(1 * 2), np.sqrt(3.5 * -4.706),
                          [np.nan, np.sqrt(1 * 2), np.sqrt(3.5 * -4.706)]],
            'Arithmetic': [np.nan, (1+2.)/2., (3.5 - 4.706)/2,

                           [np.nan, (1+2.)/2., (3.5 - 4.706)/2]],