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


import os
import warnings
import numpy as np
from astropy import units as u
from astroNN.config import MAGIC_NUMBER
    from astroNN.config import ENVVAR_WARN_FLAG
            if not isinstance(parallax_err, u.Quantity):
                # assume parallax error carry the same original unit as parallax if no units detected
                parallax_err = (parallax_err * original_parallax_unit).to(default_parallax_unit).value
            if isinstance(parallax_err, u.Quantity):
                parallax_err = parallax_err.to(default_parallax_unit).value
    #     warnings.warn(f'Please be advised that astroNN mag_to_absmag() expects {default_parallax_unit.name}, '
    #           f'astroNN has corrected the unit according to astropy unit framework')
    # else:
    #     warnings.warn(f'Please be advised that astroNN mag_to_absmag expects parallax in {default_parallax_unit.name}')

    mag = np.array(mag)
    parallax_unitless = np.array(parallax)  # Take the value as we cant apply log10 to astropy unit

    magic_idx = ((parallax_unitless == MAGIC_NUMBER) | (mag == MAGIC_NUMBER) | (mag < -90.) | np.isnan(parallax_unitless) | np.isnan(mag))  # check for magic number

    with warnings.catch_warnings():  # suppress numpy Runtime warning caused by MAGIC_NUMBER
        warnings.simplefilter("ignore")
        absmag = mag + 5. * (np.log10(parallax_unitless) - 2.)

    if parallax_unitless.shape != ():  # check if its only 1 element
        absmag[magic_idx] = MAGIC_NUMBER
    else:
        absmag = MAGIC_NUMBER if magic_idx == [1] else absmag
    if parallax_err is None:
        return absmag
    else:
        absmag_err = 5. * np.abs(parallax_err / (parallax_unitless * absmag))
        if parallax_unitless.shape != ():  # check if its only 1 element
            absmag_err[magic_idx] = MAGIC_NUMBER
        else:

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


# Path: astroNN/gaia/gaia_shared.py
import os
import warnings
import numpy as np
from astropy import units as u
from astroNN.config import MAGIC_NUMBER
    from astroNN.config import ENVVAR_WARN_FLAG

            if not isinstance(parallax_err, u.Quantity):
                # assume parallax error carry the same original unit as parallax if no units detected
                parallax_err = (parallax_err * original_parallax_unit).to(default_parallax_unit).value
            if isinstance(parallax_err, u.Quantity):
                parallax_err = parallax_err.to(default_parallax_unit).value
    #     warnings.warn(f'Please be advised that astroNN mag_to_absmag() expects {default_parallax_unit.name}, '
    #           f'astroNN has corrected the unit according to astropy unit framework')
    # else:
    #     warnings.warn(f'Please be advised that astroNN mag_to_absmag expects parallax in {default_parallax_unit.name}')

    mag = np.array(mag)
    parallax_unitless = np.array(parallax)  # Take the value as we cant apply log10 to astropy unit

    magic_idx = ((parallax_unitless == MAGIC_NUMBER) | (mag == MAGIC_NUMBER) | (mag < -90.) | np.isnan(parallax_unitless) | np.isnan(mag))  # check for magic number

    with warnings.catch_warnings():  # suppress numpy Runtime warning caused by MAGIC_NUMBER
        warnings.simplefilter("ignore")
        absmag = mag + 5. * (np.log10(parallax_unitless) - 2.)

    if parallax_unitless.shape != ():  # check if its only 1 element
        absmag[magic_idx] = MAGIC_NUMBER
    else:
        absmag = MAGIC_NUMBER if magic_idx == [1] else absmag
    if parallax_err is None:
        return absmag
    else:
        absmag_err = 5. * np.abs(parallax_err / (parallax_unitless * absmag))
        if parallax_unitless.shape != ():  # check if its only 1 element
            absmag_err[magic_idx] = MAGIC_NUMBER
        else:

            absmag_err = MAGIC_NUMBER if magic_idx == [1] else absmag_err