# Path: astroNN/config.py
# MAGIC_NUMBER = magic_num_reader()


import astropy.units as u
import numpy as np
from astroNN.config import MAGIC_NUMBER
    """
    NumPy implementation of tf.nn.relu

    :param x: Data to have ReLU activated
    :type x: Union[ndarray, float]
    :return: ReLU activated data
    :rtype: Union[ndarray, float]
    :History: 2018-Apr-11 - Written - Henry Leung (University of Toronto)
    """
    return x * (x > 0)


def mape_core(x, y, axis=None, mode=None):
    if isinstance(x, list):
        x = np.array(x)
    if isinstance(y, list):
        y = np.array(y)
    if isinstance(x, u.Quantity) and isinstance(y, u.Quantity):
        percentage = ((x - y) / y).value
        # still need to take the value for creating mask
        x = x.value
        y = y.value
    elif (isinstance(x, u.Quantity) and not isinstance(y, u.Quantity)) or \
            (not isinstance(x, u.Quantity) and isinstance(y, u.Quantity)):
        raise TypeError("Only one of your data provided has astropy units \n"
                        "Either both x and y are ndarray or both x and y are astropy.Quatity, "
                        "return without astropy units in all case")
    else:
        percentage = (x - y) / y
    if mode == 'mean':

# Path: astroNN/config.py
# MAGIC_NUMBER = magic_num_reader()


# Path: astroNN/nn/numpy.py
import astropy.units as u
import numpy as np
from astroNN.config import MAGIC_NUMBER

    """
    NumPy implementation of tf.nn.relu

    :param x: Data to have ReLU activated
    :type x: Union[ndarray, float]
    :return: ReLU activated data
    :rtype: Union[ndarray, float]
    :History: 2018-Apr-11 - Written - Henry Leung (University of Toronto)
    """
    return x * (x > 0)


def mape_core(x, y, axis=None, mode=None):
    if isinstance(x, list):
        x = np.array(x)
    if isinstance(y, list):
        y = np.array(y)
    if isinstance(x, u.Quantity) and isinstance(y, u.Quantity):
        percentage = ((x - y) / y).value
        # still need to take the value for creating mask
        x = x.value
        y = y.value
    elif (isinstance(x, u.Quantity) and not isinstance(y, u.Quantity)) or \
            (not isinstance(x, u.Quantity) and isinstance(y, u.Quantity)):
        raise TypeError("Only one of your data provided has astropy units \n"
                        "Either both x and y are ndarray or both x and y are astropy.Quatity, "
                        "return without astropy units in all case")
    else:
        percentage = (x - y) / y
    if mode == 'mean':

        return np.ma.mean(np.ma.array(np.abs(percentage) * 100., mask=((x == MAGIC_NUMBER) | (y == MAGIC_NUMBER))),