repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
Robpol86/colorclass
colorclass/color.py
Color.bgblue
def bgblue(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgblue', stri...
python
def bgblue(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgblue', stri...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L139-L148
Robpol86/colorclass
colorclass/color.py
Color.magenta
def magenta(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('magenta', st...
python
def magenta(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('magenta', st...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L151-L160
Robpol86/colorclass
colorclass/color.py
Color.bgmagenta
def bgmagenta(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgmagenta'...
python
def bgmagenta(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgmagenta'...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L163-L172
Robpol86/colorclass
colorclass/color.py
Color.cyan
def cyan(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('cyan', string, ...
python
def cyan(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('cyan', string, ...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L175-L184
Robpol86/colorclass
colorclass/color.py
Color.bgcyan
def bgcyan(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgcyan', stri...
python
def bgcyan(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgcyan', stri...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L187-L196
Robpol86/colorclass
colorclass/color.py
Color.white
def white(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('white', string...
python
def white(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('white', string...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L199-L208
Robpol86/colorclass
colorclass/color.py
Color.bgwhite
def bgwhite(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgwhite', st...
python
def bgwhite(cls, string, auto=False): """Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color """ return cls.colorize('bgwhite', st...
Color-code entire string. :param str string: String to colorize. :param bool auto: Enable auto-color (dark/light terminal). :return: Class instance for colorized string. :rtype: Color
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/color.py#L211-L220
Robpol86/colorclass
colorclass/codes.py
list_tags
def list_tags(): """List the available tags. :return: List of 4-item tuples: opening tag, closing tag, main ansi value, closing ansi value. :rtype: list """ # Build reverse dictionary. Keys are closing tags, values are [closing ansi, opening tag, opening ansi]. reverse_dict = dict() for tag...
python
def list_tags(): """List the available tags. :return: List of 4-item tuples: opening tag, closing tag, main ansi value, closing ansi value. :rtype: list """ # Build reverse dictionary. Keys are closing tags, values are [closing ansi, opening tag, opening ansi]. reverse_dict = dict() for tag...
List the available tags. :return: List of 4-item tuples: opening tag, closing tag, main ansi value, closing ansi value. :rtype: list
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/codes.py#L196-L229
Robpol86/colorclass
colorclass/codes.py
ANSICodeMapping.disable_if_no_tty
def disable_if_no_tty(cls): """Disable all colors only if there is no TTY available. :return: True if colors are disabled, False if stderr or stdout is a TTY. :rtype: bool """ if sys.stdout.isatty() or sys.stderr.isatty(): return False cls.disable_all_colors(...
python
def disable_if_no_tty(cls): """Disable all colors only if there is no TTY available. :return: True if colors are disabled, False if stderr or stdout is a TTY. :rtype: bool """ if sys.stdout.isatty() or sys.stderr.isatty(): return False cls.disable_all_colors(...
Disable all colors only if there is no TTY available. :return: True if colors are disabled, False if stderr or stdout is a TTY. :rtype: bool
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/codes.py#L94-L103
Robpol86/colorclass
colorclass/windows.py
init_kernel32
def init_kernel32(kernel32=None): """Load a unique instance of WinDLL into memory, set arg/return types, and get stdout/err handles. 1. Since we are setting DLL function argument types and return types, we need to maintain our own instance of kernel32 to prevent overriding (or being overwritten by) user...
python
def init_kernel32(kernel32=None): """Load a unique instance of WinDLL into memory, set arg/return types, and get stdout/err handles. 1. Since we are setting DLL function argument types and return types, we need to maintain our own instance of kernel32 to prevent overriding (or being overwritten by) user...
Load a unique instance of WinDLL into memory, set arg/return types, and get stdout/err handles. 1. Since we are setting DLL function argument types and return types, we need to maintain our own instance of kernel32 to prevent overriding (or being overwritten by) user's own changes to ctypes.windll.kernel32....
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L74-L110
Robpol86/colorclass
colorclass/windows.py
get_console_info
def get_console_info(kernel32, handle): """Get information about this current console window. http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231 https://code.google.com/p/colorama/issues/detail?id=47 https://bitbucket.org/pytest-dev/py/src/4617fe46/py/_io/terminalwriter.py Windows 10...
python
def get_console_info(kernel32, handle): """Get information about this current console window. http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231 https://code.google.com/p/colorama/issues/detail?id=47 https://bitbucket.org/pytest-dev/py/src/4617fe46/py/_io/terminalwriter.py Windows 10...
Get information about this current console window. http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231 https://code.google.com/p/colorama/issues/detail?id=47 https://bitbucket.org/pytest-dev/py/src/4617fe46/py/_io/terminalwriter.py Windows 10 Insider since around February 2016 finally int...
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L113-L148
Robpol86/colorclass
colorclass/windows.py
bg_color_native_ansi
def bg_color_native_ansi(kernel32, stderr, stdout): """Get background color and if console supports ANSI colors natively for both streams. :param ctypes.windll.kernel32 kernel32: Loaded kernel32 instance. :param int stderr: stderr handle. :param int stdout: stdout handle. :return: Background color...
python
def bg_color_native_ansi(kernel32, stderr, stdout): """Get background color and if console supports ANSI colors natively for both streams. :param ctypes.windll.kernel32 kernel32: Loaded kernel32 instance. :param int stderr: stderr handle. :param int stdout: stdout handle. :return: Background color...
Get background color and if console supports ANSI colors natively for both streams. :param ctypes.windll.kernel32 kernel32: Loaded kernel32 instance. :param int stderr: stderr handle. :param int stdout: stdout handle. :return: Background color (int) and native ANSI support (bool). :rtype: tuple
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L151-L172
Robpol86/colorclass
colorclass/windows.py
WindowsStream.colors
def colors(self): """Return the current foreground and background colors.""" try: return get_console_info(self._kernel32, self._stream_handle)[:2] except OSError: return WINDOWS_CODES['white'], WINDOWS_CODES['black']
python
def colors(self): """Return the current foreground and background colors.""" try: return get_console_info(self._kernel32, self._stream_handle)[:2] except OSError: return WINDOWS_CODES['white'], WINDOWS_CODES['black']
Return the current foreground and background colors.
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L217-L222
Robpol86/colorclass
colorclass/windows.py
WindowsStream.colors
def colors(self, color_code): """Change the foreground and background colors for subsequently printed characters. None resets colors to their original values (when class was instantiated). Since setting a color requires including both foreground and background codes (merged), setting just the ...
python
def colors(self, color_code): """Change the foreground and background colors for subsequently printed characters. None resets colors to their original values (when class was instantiated). Since setting a color requires including both foreground and background codes (merged), setting just the ...
Change the foreground and background colors for subsequently printed characters. None resets colors to their original values (when class was instantiated). Since setting a color requires including both foreground and background codes (merged), setting just the foreground color resets the backg...
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L225-L262
Robpol86/colorclass
colorclass/windows.py
WindowsStream.write
def write(self, p_str): """Write to stream. :param str p_str: string to print. """ for segment in RE_SPLIT.split(p_str): if not segment: # Empty string. p_str probably starts with colors so the first item is always ''. continue if ...
python
def write(self, p_str): """Write to stream. :param str p_str: string to print. """ for segment in RE_SPLIT.split(p_str): if not segment: # Empty string. p_str probably starts with colors so the first item is always ''. continue if ...
Write to stream. :param str p_str: string to print.
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L264-L280
Robpol86/colorclass
colorclass/windows.py
Windows.disable
def disable(cls): """Restore sys.stderr and sys.stdout to their original objects. Resets colors to their original values. :return: If streams restored successfully. :rtype: bool """ # Skip if not on Windows. if not IS_WINDOWS: return False # Restore ...
python
def disable(cls): """Restore sys.stderr and sys.stdout to their original objects. Resets colors to their original values. :return: If streams restored successfully. :rtype: bool """ # Skip if not on Windows. if not IS_WINDOWS: return False # Restore ...
Restore sys.stderr and sys.stdout to their original objects. Resets colors to their original values. :return: If streams restored successfully. :rtype: bool
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L298-L323
Robpol86/colorclass
colorclass/windows.py
Windows.enable
def enable(cls, auto_colors=False, reset_atexit=False): """Enable color text with print() or sys.stdout.write() (stderr too). :param bool auto_colors: Automatically selects dark or light colors based on current terminal's background color. Only works with {autored} and related tags. ...
python
def enable(cls, auto_colors=False, reset_atexit=False): """Enable color text with print() or sys.stdout.write() (stderr too). :param bool auto_colors: Automatically selects dark or light colors based on current terminal's background color. Only works with {autored} and related tags. ...
Enable color text with print() or sys.stdout.write() (stderr too). :param bool auto_colors: Automatically selects dark or light colors based on current terminal's background color. Only works with {autored} and related tags. :param bool reset_atexit: Resets original colors upon Python exit ...
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/windows.py#L331-L376
Robpol86/colorclass
colorclass/parse.py
prune_overridden
def prune_overridden(ansi_string): """Remove color codes that are rendered ineffective by subsequent codes in one escape sequence then sort codes. :param str ansi_string: Incoming ansi_string with ANSI color codes. :return: Color string with pruned color sequences. :rtype: str """ multi_seqs =...
python
def prune_overridden(ansi_string): """Remove color codes that are rendered ineffective by subsequent codes in one escape sequence then sort codes. :param str ansi_string: Incoming ansi_string with ANSI color codes. :return: Color string with pruned color sequences. :rtype: str """ multi_seqs =...
Remove color codes that are rendered ineffective by subsequent codes in one escape sequence then sort codes. :param str ansi_string: Incoming ansi_string with ANSI color codes. :return: Color string with pruned color sequences. :rtype: str
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/parse.py#L17-L46
Robpol86/colorclass
colorclass/parse.py
parse_input
def parse_input(tagged_string, disable_colors, keep_tags): """Perform the actual conversion of tags to ANSI escaped codes. Provides a version of the input without any colors for len() and other methods. :param str tagged_string: The input unicode value. :param bool disable_colors: Strip all colors in ...
python
def parse_input(tagged_string, disable_colors, keep_tags): """Perform the actual conversion of tags to ANSI escaped codes. Provides a version of the input without any colors for len() and other methods. :param str tagged_string: The input unicode value. :param bool disable_colors: Strip all colors in ...
Perform the actual conversion of tags to ANSI escaped codes. Provides a version of the input without any colors for len() and other methods. :param str tagged_string: The input unicode value. :param bool disable_colors: Strip all colors in both outputs. :param bool keep_tags: Skip parsing curly bracke...
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/parse.py#L49-L96
Robpol86/colorclass
colorclass/search.py
build_color_index
def build_color_index(ansi_string): """Build an index between visible characters and a string with invisible color codes. :param str ansi_string: String with color codes (ANSI escape sequences). :return: Position of visible characters in color string (indexes match non-color string). :rtype: tuple ...
python
def build_color_index(ansi_string): """Build an index between visible characters and a string with invisible color codes. :param str ansi_string: String with color codes (ANSI escape sequences). :return: Position of visible characters in color string (indexes match non-color string). :rtype: tuple ...
Build an index between visible characters and a string with invisible color codes. :param str ansi_string: String with color codes (ANSI escape sequences). :return: Position of visible characters in color string (indexes match non-color string). :rtype: tuple
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/search.py#L6-L23
Robpol86/colorclass
colorclass/search.py
find_char_color
def find_char_color(ansi_string, pos): """Determine what color a character is in the string. :param str ansi_string: String with color codes (ANSI escape sequences). :param int pos: Position of the character in the ansi_string. :return: Character along with all surrounding color codes. :rtype: str...
python
def find_char_color(ansi_string, pos): """Determine what color a character is in the string. :param str ansi_string: String with color codes (ANSI escape sequences). :param int pos: Position of the character in the ansi_string. :return: Character along with all surrounding color codes. :rtype: str...
Determine what color a character is in the string. :param str ansi_string: String with color codes (ANSI escape sequences). :param int pos: Position of the character in the ansi_string. :return: Character along with all surrounding color codes. :rtype: str
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/search.py#L26-L49
Robpol86/colorclass
example.py
main
def main(): """Main function called upon script execution.""" if OPTIONS.get('--no-colors'): disable_all_colors() elif OPTIONS.get('--colors'): enable_all_colors() if is_enabled() and os.name == 'nt': Windows.enable(auto_colors=True, reset_atexit=True) elif OPTIONS.get('--li...
python
def main(): """Main function called upon script execution.""" if OPTIONS.get('--no-colors'): disable_all_colors() elif OPTIONS.get('--colors'): enable_all_colors() if is_enabled() and os.name == 'nt': Windows.enable(auto_colors=True, reset_atexit=True) elif OPTIONS.get('--li...
Main function called upon script execution.
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/example.py#L35-L225
threeML/astromodels
astromodels/utils/angular_distance.py
angular_distance_fast
def angular_distance_fast(ra1, dec1, ra2, dec2): """ Compute angular distance using the Haversine formula. Use this one when you know you will never ask for points at their antipodes. If this is not the case, use the angular_distance function which is slower, but works also for antipodes. :param lo...
python
def angular_distance_fast(ra1, dec1, ra2, dec2): """ Compute angular distance using the Haversine formula. Use this one when you know you will never ask for points at their antipodes. If this is not the case, use the angular_distance function which is slower, but works also for antipodes. :param lo...
Compute angular distance using the Haversine formula. Use this one when you know you will never ask for points at their antipodes. If this is not the case, use the angular_distance function which is slower, but works also for antipodes. :param lon1: :param lat1: :param lon2: :param lat2: :r...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/angular_distance.py#L4-L26
threeML/astromodels
astromodels/utils/angular_distance.py
angular_distance
def angular_distance(ra1, dec1, ra2, dec2): """ Returns the angular distance between two points, two sets of points, or a set of points and one point. :param ra1: array or float, longitude of first point(s) :param dec1: array or float, latitude of first point(s) :param ra2: array or float, longitud...
python
def angular_distance(ra1, dec1, ra2, dec2): """ Returns the angular distance between two points, two sets of points, or a set of points and one point. :param ra1: array or float, longitude of first point(s) :param dec1: array or float, latitude of first point(s) :param ra2: array or float, longitud...
Returns the angular distance between two points, two sets of points, or a set of points and one point. :param ra1: array or float, longitude of first point(s) :param dec1: array or float, latitude of first point(s) :param ra2: array or float, longitude of second point(s) :param dec2: array or float, la...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/angular_distance.py#L29-L58
threeML/astromodels
astromodels/utils/angular_distance.py
spherical_angle
def spherical_angle( ra0, dec0, ra1, dec1, ra2, dec2 ): """ Returns the spherical angle distance between two sets of great circles defined by (ra0, dec0), (ra1, dec1) and (ra0, dec0), (ra2, dec2) :param ra0: array or float, longitude of intersection point(s) :param dec0: array or float, latitude of int...
python
def spherical_angle( ra0, dec0, ra1, dec1, ra2, dec2 ): """ Returns the spherical angle distance between two sets of great circles defined by (ra0, dec0), (ra1, dec1) and (ra0, dec0), (ra2, dec2) :param ra0: array or float, longitude of intersection point(s) :param dec0: array or float, latitude of int...
Returns the spherical angle distance between two sets of great circles defined by (ra0, dec0), (ra1, dec1) and (ra0, dec0), (ra2, dec2) :param ra0: array or float, longitude of intersection point(s) :param dec0: array or float, latitude of intersection point(s) :param ra1: array or float, longitude of firs...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/angular_distance.py#L61-L83
threeML/astromodels
astromodels/core/memoization.py
use_astromodels_memoization
def use_astromodels_memoization(switch, cache_size=_CACHE_SIZE): """ Activate/deactivate memoization temporarily :param switch: True (memoization on) or False (memoization off) :param cache_size: number of previous evaluation of functions to keep in memory. Default: 100 :return: """ global...
python
def use_astromodels_memoization(switch, cache_size=_CACHE_SIZE): """ Activate/deactivate memoization temporarily :param switch: True (memoization on) or False (memoization off) :param cache_size: number of previous evaluation of functions to keep in memory. Default: 100 :return: """ global...
Activate/deactivate memoization temporarily :param switch: True (memoization on) or False (memoization off) :param cache_size: number of previous evaluation of functions to keep in memory. Default: 100 :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/memoization.py#L11-L32
threeML/astromodels
astromodels/core/memoization.py
memoize
def memoize(method): """ A decorator for functions of sources which memoize the results of the last _CACHE_SIZE calls, :param method: method to be memoized :return: the decorated method """ cache = method.cache = collections.OrderedDict() # Put these two methods in the local space (faster...
python
def memoize(method): """ A decorator for functions of sources which memoize the results of the last _CACHE_SIZE calls, :param method: method to be memoized :return: the decorated method """ cache = method.cache = collections.OrderedDict() # Put these two methods in the local space (faster...
A decorator for functions of sources which memoize the results of the last _CACHE_SIZE calls, :param method: method to be memoized :return: the decorated method
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/memoization.py#L36-L90
threeML/astromodels
astromodels/xspec/xspec_settings.py
xspec_cosmo
def xspec_cosmo(H0=None,q0=None,lambda_0=None): """ Define the Cosmology in use within the XSpec models. See Xspec manual for help: http://heasarc.nasa.gov/xanadu/xspec/manual/XScosmo.html All parameters can be modified or just a single parameter :param H0: the hubble constant :param q0: ...
python
def xspec_cosmo(H0=None,q0=None,lambda_0=None): """ Define the Cosmology in use within the XSpec models. See Xspec manual for help: http://heasarc.nasa.gov/xanadu/xspec/manual/XScosmo.html All parameters can be modified or just a single parameter :param H0: the hubble constant :param q0: ...
Define the Cosmology in use within the XSpec models. See Xspec manual for help: http://heasarc.nasa.gov/xanadu/xspec/manual/XScosmo.html All parameters can be modified or just a single parameter :param H0: the hubble constant :param q0: :param lambda_0: :return: Either none or the current...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/xspec/xspec_settings.py#L24-L63
threeML/astromodels
astromodels/xspec/factory.py
find_model_dat
def find_model_dat(): """ Find the file containing the definition of all the models in Xspec (model.dat) and return its path """ # model.dat is in $HEADAS/../spectral headas_env = os.environ.get("HEADAS") assert headas_env is not None, ("You need to setup the HEADAS variable before import...
python
def find_model_dat(): """ Find the file containing the definition of all the models in Xspec (model.dat) and return its path """ # model.dat is in $HEADAS/../spectral headas_env = os.environ.get("HEADAS") assert headas_env is not None, ("You need to setup the HEADAS variable before import...
Find the file containing the definition of all the models in Xspec (model.dat) and return its path
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/xspec/factory.py#L38-L70
threeML/astromodels
astromodels/xspec/factory.py
get_models
def get_models(model_dat_path): """ Parse the model.dat file from Xspec and returns a dictionary containing the definition of all the models :param model_dat_path: the path to the model.dat file :return: dictionary containing the definition of all XSpec models """ # Check first if we already h...
python
def get_models(model_dat_path): """ Parse the model.dat file from Xspec and returns a dictionary containing the definition of all the models :param model_dat_path: the path to the model.dat file :return: dictionary containing the definition of all XSpec models """ # Check first if we already h...
Parse the model.dat file from Xspec and returns a dictionary containing the definition of all the models :param model_dat_path: the path to the model.dat file :return: dictionary containing the definition of all XSpec models
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/xspec/factory.py#L73-L340
threeML/astromodels
astromodels/core/model.py
Model._add_source
def _add_source(self, source): """ Remember to call _update_parameters after this! :param source: :return: """ try: self._add_child(source) except AttributeError: if isinstance(source, Source): raise DuplicatedNode("Mor...
python
def _add_source(self, source): """ Remember to call _update_parameters after this! :param source: :return: """ try: self._add_child(source) except AttributeError: if isinstance(source, Source): raise DuplicatedNode("Mor...
Remember to call _update_parameters after this! :param source: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L82-L121
threeML/astromodels
astromodels/core/model.py
Model._remove_source
def _remove_source(self, source_name): """ Remember to call _update_parameters after this :param source_name: :return: """ assert source_name in self.sources, "Source %s is not part of the current model" % source_name source = self.sources.pop(source_name) ...
python
def _remove_source(self, source_name): """ Remember to call _update_parameters after this :param source_name: :return: """ assert source_name in self.sources, "Source %s is not part of the current model" % source_name source = self.sources.pop(source_name) ...
Remember to call _update_parameters after this :param source_name: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L123-L146
threeML/astromodels
astromodels/core/model.py
Model.free_parameters
def free_parameters(self): """ Get a dictionary with all the free parameters in this model :return: dictionary of free parameters """ # Refresh the list self._update_parameters() # Filter selecting only free parameters free_parameters_dictionary = col...
python
def free_parameters(self): """ Get a dictionary with all the free parameters in this model :return: dictionary of free parameters """ # Refresh the list self._update_parameters() # Filter selecting only free parameters free_parameters_dictionary = col...
Get a dictionary with all the free parameters in this model :return: dictionary of free parameters
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L186-L207
threeML/astromodels
astromodels/core/model.py
Model.linked_parameters
def linked_parameters(self): """ Get a dictionary with all parameters in this model in a linked status. A parameter is in a linked status if it is linked to another parameter (i.e. it is forced to have the same value of the other parameter), or if it is linked with another parameter or a...
python
def linked_parameters(self): """ Get a dictionary with all parameters in this model in a linked status. A parameter is in a linked status if it is linked to another parameter (i.e. it is forced to have the same value of the other parameter), or if it is linked with another parameter or a...
Get a dictionary with all parameters in this model in a linked status. A parameter is in a linked status if it is linked to another parameter (i.e. it is forced to have the same value of the other parameter), or if it is linked with another parameter or an independent variable through a law. :r...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L210-L233
threeML/astromodels
astromodels/core/model.py
Model.set_free_parameters
def set_free_parameters(self, values): """ Set the free parameters in the model to the provided values. NOTE: of course, order matters :param values: a list of new values :return: None """ assert len(values) == len(self.free_parameters) for parameter, ...
python
def set_free_parameters(self, values): """ Set the free parameters in the model to the provided values. NOTE: of course, order matters :param values: a list of new values :return: None """ assert len(values) == len(self.free_parameters) for parameter, ...
Set the free parameters in the model to the provided values. NOTE: of course, order matters :param values: a list of new values :return: None
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L235-L249
threeML/astromodels
astromodels/core/model.py
Model.sources
def sources(self): """ Returns a dictionary containing all defined sources (of any kind) :return: collections.OrderedDict() """ sources = collections.OrderedDict() for d in (self.point_sources, self.extended_sources, self.particle_sources): sources.update...
python
def sources(self): """ Returns a dictionary containing all defined sources (of any kind) :return: collections.OrderedDict() """ sources = collections.OrderedDict() for d in (self.point_sources, self.extended_sources, self.particle_sources): sources.update...
Returns a dictionary containing all defined sources (of any kind) :return: collections.OrderedDict()
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L333-L347
threeML/astromodels
astromodels/core/model.py
Model.add_independent_variable
def add_independent_variable(self, variable): """ Add a global independent variable to this model, such as time. :param variable: an IndependentVariable instance :return: none """ assert isinstance(variable, IndependentVariable), "Variable must be an instance of Indepen...
python
def add_independent_variable(self, variable): """ Add a global independent variable to this model, such as time. :param variable: an IndependentVariable instance :return: none """ assert isinstance(variable, IndependentVariable), "Variable must be an instance of Indepen...
Add a global independent variable to this model, such as time. :param variable: an IndependentVariable instance :return: none
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L373-L390
threeML/astromodels
astromodels/core/model.py
Model.remove_independent_variable
def remove_independent_variable(self, variable_name): """ Remove an independent variable which was added with add_independent_variable :param variable_name: name of variable to remove :return: """ self._remove_child(variable_name) # Remove also from the list of...
python
def remove_independent_variable(self, variable_name): """ Remove an independent variable which was added with add_independent_variable :param variable_name: name of variable to remove :return: """ self._remove_child(variable_name) # Remove also from the list of...
Remove an independent variable which was added with add_independent_variable :param variable_name: name of variable to remove :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L392-L403
threeML/astromodels
astromodels/core/model.py
Model.add_external_parameter
def add_external_parameter(self, parameter): """ Add a parameter that comes from something other than a function, to the model. :param parameter: a Parameter instance :return: none """ assert isinstance(parameter, Parameter), "Variable must be an instance of Independent...
python
def add_external_parameter(self, parameter): """ Add a parameter that comes from something other than a function, to the model. :param parameter: a Parameter instance :return: none """ assert isinstance(parameter, Parameter), "Variable must be an instance of Independent...
Add a parameter that comes from something other than a function, to the model. :param parameter: a Parameter instance :return: none
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L405-L430
threeML/astromodels
astromodels/core/model.py
Model.link
def link(self, parameter_1, parameter_2, link_function=None): """ Link the value of the provided parameters through the provided function (identity is the default, i.e., parameter_1 = parameter_2). :param parameter_1: the first parameter;can be either a single parameter or a list of pra...
python
def link(self, parameter_1, parameter_2, link_function=None): """ Link the value of the provided parameters through the provided function (identity is the default, i.e., parameter_1 = parameter_2). :param parameter_1: the first parameter;can be either a single parameter or a list of pra...
Link the value of the provided parameters through the provided function (identity is the default, i.e., parameter_1 = parameter_2). :param parameter_1: the first parameter;can be either a single parameter or a list of prarameters :param parameter_2: the second parameter :param link_func...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L442-L482
threeML/astromodels
astromodels/core/model.py
Model.unlink
def unlink(self, parameter): """ Sets free one or more parameters which have been linked previously :param parameter: the parameter to be set free, can also be a list of parameters :return: (none) """ if not isinstance(parameter,list): # Make a list of one eleme...
python
def unlink(self, parameter): """ Sets free one or more parameters which have been linked previously :param parameter: the parameter to be set free, can also be a list of parameters :return: (none) """ if not isinstance(parameter,list): # Make a list of one eleme...
Sets free one or more parameters which have been linked previously :param parameter: the parameter to be set free, can also be a list of parameters :return: (none)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L488-L513
threeML/astromodels
astromodels/core/model.py
Model.display
def display(self, complete=False): """ Display information about the point source. :param complete : if True, displays also information on fixed parameters :return: (none) """ # Switch on the complete display flag self._complete_display = bool(complete) ...
python
def display(self, complete=False): """ Display information about the point source. :param complete : if True, displays also information on fixed parameters :return: (none) """ # Switch on the complete display flag self._complete_display = bool(complete) ...
Display information about the point source. :param complete : if True, displays also information on fixed parameters :return: (none)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L515-L532
threeML/astromodels
astromodels/core/model.py
Model.save
def save(self, output_file, overwrite=False): """Save the model to disk""" if os.path.exists(output_file) and overwrite is False: raise ModelFileExists("The file %s exists already. If you want to overwrite it, use the 'overwrite=True' " "options as 'model...
python
def save(self, output_file, overwrite=False): """Save the model to disk""" if os.path.exists(output_file) and overwrite is False: raise ModelFileExists("The file %s exists already. If you want to overwrite it, use the 'overwrite=True' " "options as 'model...
Save the model to disk
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L915-L946
threeML/astromodels
astromodels/core/model.py
Model.get_point_source_position
def get_point_source_position(self, id): """ Get the point source position (R.A., Dec) :param id: id of the source :return: a tuple with R.A. and Dec. """ pts = self._point_sources.values()[id] return pts.position.get_ra(), pts.position.get_dec()
python
def get_point_source_position(self, id): """ Get the point source position (R.A., Dec) :param id: id of the source :return: a tuple with R.A. and Dec. """ pts = self._point_sources.values()[id] return pts.position.get_ra(), pts.position.get_dec()
Get the point source position (R.A., Dec) :param id: id of the source :return: a tuple with R.A. and Dec.
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L956-L966
threeML/astromodels
astromodels/core/model.py
Model.get_point_source_fluxes
def get_point_source_fluxes(self, id, energies, tag=None): """ Get the fluxes from the id-th point source :param id: id of the source :param energies: energies at which you need the flux :param tag: a tuple (integration variable, a, b) specifying the integration to perform. If t...
python
def get_point_source_fluxes(self, id, energies, tag=None): """ Get the fluxes from the id-th point source :param id: id of the source :param energies: energies at which you need the flux :param tag: a tuple (integration variable, a, b) specifying the integration to perform. If t...
Get the fluxes from the id-th point source :param id: id of the source :param energies: energies at which you need the flux :param tag: a tuple (integration variable, a, b) specifying the integration to perform. If this parameter is specified then the returned value will be the average ...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L968-L982
threeML/astromodels
astromodels/core/model.py
Model.get_extended_source_fluxes
def get_extended_source_fluxes(self, id, j2000_ra, j2000_dec, energies): """ Get the flux of the id-th extended sources at the given position at the given energies :param id: id of the source :param j2000_ra: R.A. where the flux is desired :param j2000_dec: Dec. where the flux i...
python
def get_extended_source_fluxes(self, id, j2000_ra, j2000_dec, energies): """ Get the flux of the id-th extended sources at the given position at the given energies :param id: id of the source :param j2000_ra: R.A. where the flux is desired :param j2000_dec: Dec. where the flux i...
Get the flux of the id-th extended sources at the given position at the given energies :param id: id of the source :param j2000_ra: R.A. where the flux is desired :param j2000_dec: Dec. where the flux is desired :param energies: energies at which the flux is desired :return: flu...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L996-L1007
threeML/astromodels
astromodels/core/model.py
Model.get_total_flux
def get_total_flux(self, energies): """ Returns the total differential flux at the provided energies from all *point* sources :return: """ fluxes = [] for src in self._point_sources: fluxes.append(self._point_sources[src](energies)) return np.sum(...
python
def get_total_flux(self, energies): """ Returns the total differential flux at the provided energies from all *point* sources :return: """ fluxes = [] for src in self._point_sources: fluxes.append(self._point_sources[src](energies)) return np.sum(...
Returns the total differential flux at the provided energies from all *point* sources :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/model.py#L1069-L1082
threeML/astromodels
astromodels/utils/long_path_formatter.py
long_path_formatter
def long_path_formatter(line, max_width=pd.get_option('max_colwidth')): """ If a path is longer than max_width, it substitute it with the first and last element, joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes 'this...shorten' :param line: :param max_width: ...
python
def long_path_formatter(line, max_width=pd.get_option('max_colwidth')): """ If a path is longer than max_width, it substitute it with the first and last element, joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes 'this...shorten' :param line: :param max_width: ...
If a path is longer than max_width, it substitute it with the first and last element, joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes 'this...shorten' :param line: :param max_width: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/long_path_formatter.py#L4-L30
threeML/astromodels
astromodels/sources/point_source.py
PointSource.has_free_parameters
def has_free_parameters(self): """ Returns True or False whether there is any parameter in this source :return: """ for component in self._components.values(): for par in component.shape.parameters.values(): if par.free: return...
python
def has_free_parameters(self): """ Returns True or False whether there is any parameter in this source :return: """ for component in self._components.values(): for par in component.shape.parameters.values(): if par.free: return...
Returns True or False whether there is any parameter in this source :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/point_source.py#L214-L235
threeML/astromodels
astromodels/sources/point_source.py
PointSource.free_parameters
def free_parameters(self): """ Returns a dictionary of free parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ free_parameters = collections.OrderedDict() for co...
python
def free_parameters(self): """ Returns a dictionary of free parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ free_parameters = collections.OrderedDict() for co...
Returns a dictionary of free parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/point_source.py#L238-L262
threeML/astromodels
astromodels/sources/point_source.py
PointSource.parameters
def parameters(self): """ Returns a dictionary of all parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ all_parameters = collections.OrderedDict() for component...
python
def parameters(self): """ Returns a dictionary of all parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ all_parameters = collections.OrderedDict() for component...
Returns a dictionary of all parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/point_source.py#L265-L285
threeML/astromodels
astromodels/sources/point_source.py
PointSource._repr__base
def _repr__base(self, rich_output=False): """ Representation of the object :param rich_output: if True, generates HTML, otherwise text :return: the representation """ # Make a dictionary which will then be transformed in a list repr_dict = collections.OrderedDi...
python
def _repr__base(self, rich_output=False): """ Representation of the object :param rich_output: if True, generates HTML, otherwise text :return: the representation """ # Make a dictionary which will then be transformed in a list repr_dict = collections.OrderedDi...
Representation of the object :param rich_output: if True, generates HTML, otherwise text :return: the representation
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/point_source.py#L287-L309
threeML/astromodels
astromodels/sources/particle_source.py
ParticleSource.get_flux
def get_flux(self, energies): """Get the total flux of this particle source at the given energies (summed over the components)""" results = [component.shape(energies) for component in self.components.values()] return numpy.sum(results, 0)
python
def get_flux(self, energies): """Get the total flux of this particle source at the given energies (summed over the components)""" results = [component.shape(energies) for component in self.components.values()] return numpy.sum(results, 0)
Get the total flux of this particle source at the given energies (summed over the components)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/particle_source.py#L62-L68
threeML/astromodels
astromodels/sources/particle_source.py
ParticleSource.free_parameters
def free_parameters(self): """ Returns a dictionary of free parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ free_parameters = collections.OrderedDict() for co...
python
def free_parameters(self): """ Returns a dictionary of free parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ free_parameters = collections.OrderedDict() for co...
Returns a dictionary of free parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/particle_source.py#L94-L112
threeML/astromodels
astromodels/sources/particle_source.py
ParticleSource.parameters
def parameters(self): """ Returns a dictionary of all parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ all_parameters = collections.OrderedDict() for component...
python
def parameters(self): """ Returns a dictionary of all parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return: """ all_parameters = collections.OrderedDict() for component...
Returns a dictionary of all parameters for this source. We use the parameter path as the key because it's guaranteed to be unique, unlike the parameter name. :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/particle_source.py#L115-L131
threeML/astromodels
astromodels/functions/functions_3D.py
Continuous_injection_diffusion_ellipse.get_total_spatial_integral
def get_total_spatial_integral(self, z=None): """ Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses. :return: an array of values of the integral (same dimension as z). """ ...
python
def get_total_spatial_integral(self, z=None): """ Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses. :return: an array of values of the integral (same dimension as z). """ ...
Returns the total integral (for 2D functions) or the integral over the spatial components (for 3D functions). needs to be implemented in subclasses. :return: an array of values of the integral (same dimension as z).
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/functions_3D.py#L192-L202
threeML/astromodels
astromodels/functions/function.py
get_function
def get_function(function_name, composite_function_expression=None): """ Returns the function "name", which must be among the known functions or a composite function. :param function_name: the name of the function (use 'composite' if the function is a composite function) :param composite_function_expre...
python
def get_function(function_name, composite_function_expression=None): """ Returns the function "name", which must be among the known functions or a composite function. :param function_name: the name of the function (use 'composite' if the function is a composite function) :param composite_function_expre...
Returns the function "name", which must be among the known functions or a composite function. :param function_name: the name of the function (use 'composite' if the function is a composite function) :param composite_function_expression: composite function specification such as ((((powerlaw{1} + (sin{2} * 3...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L1566-L1609
threeML/astromodels
astromodels/functions/function.py
get_function_class
def get_function_class(function_name): """ Return the type for the requested function :param function_name: the function to return :return: the type for that function (i.e., this is a class, not an instance) """ if function_name in _known_functions: return _known_functions[function_na...
python
def get_function_class(function_name): """ Return the type for the requested function :param function_name: the function to return :return: the type for that function (i.e., this is a class, not an instance) """ if function_name in _known_functions: return _known_functions[function_na...
Return the type for the requested function :param function_name: the function to return :return: the type for that function (i.e., this is a class, not an instance)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L1612-L1627
threeML/astromodels
astromodels/functions/function.py
_parse_function_expression
def _parse_function_expression(function_specification): """ Parse a complex function expression like: ((((powerlaw{1} + (sin{2} * 3)) + (sin{2} * 25)) - (powerlaw{1} * 16)) + (sin{2} ** 3.0)) and return a composite function instance :param function_specification: :return: a composite function...
python
def _parse_function_expression(function_specification): """ Parse a complex function expression like: ((((powerlaw{1} + (sin{2} * 3)) + (sin{2} * 25)) - (powerlaw{1} * 16)) + (sin{2} ** 3.0)) and return a composite function instance :param function_specification: :return: a composite function...
Parse a complex function expression like: ((((powerlaw{1} + (sin{2} * 3)) + (sin{2} * 25)) - (powerlaw{1} * 16)) + (sin{2} ** 3.0)) and return a composite function instance :param function_specification: :return: a composite function instance
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L1648-L1825
threeML/astromodels
astromodels/functions/function.py
FunctionMeta.check_calling_sequence
def check_calling_sequence(name, function_name, function, possible_variables): """ Check the calling sequence for the function looking for the variables specified. One or more of the variables can be in the calling sequence. Note that the order of the variables will be enforced. ...
python
def check_calling_sequence(name, function_name, function, possible_variables): """ Check the calling sequence for the function looking for the variables specified. One or more of the variables can be in the calling sequence. Note that the order of the variables will be enforced. ...
Check the calling sequence for the function looking for the variables specified. One or more of the variables can be in the calling sequence. Note that the order of the variables will be enforced. It will also enforce that the first parameter in the calling sequence is called 'self'. :p...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L339-L385
threeML/astromodels
astromodels/functions/function.py
Function.free_parameters
def free_parameters(self): """ Returns a dictionary of free parameters for this function :return: dictionary of free parameters """ free_parameters = collections.OrderedDict([(k,v) for k, v in self.parameters.iteritems() if v.free]) return free_parameters
python
def free_parameters(self): """ Returns a dictionary of free parameters for this function :return: dictionary of free parameters """ free_parameters = collections.OrderedDict([(k,v) for k, v in self.parameters.iteritems() if v.free]) return free_parameters
Returns a dictionary of free parameters for this function :return: dictionary of free parameters
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L518-L527
threeML/astromodels
astromodels/functions/function.py
Function.evaluate_at
def evaluate_at(self, *args, **parameter_specification): # pragma: no cover """ Evaluate the function at the given x(,y,z) for the provided parameters, explicitly provided as part of the parameter_specification keywords. :param *args: :param **parameter_specification: :...
python
def evaluate_at(self, *args, **parameter_specification): # pragma: no cover """ Evaluate the function at the given x(,y,z) for the provided parameters, explicitly provided as part of the parameter_specification keywords. :param *args: :param **parameter_specification: :...
Evaluate the function at the given x(,y,z) for the provided parameters, explicitly provided as part of the parameter_specification keywords. :param *args: :param **parameter_specification: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/function.py#L772-L787
threeML/astromodels
astromodels/functions/priors.py
Gaussian.from_unit_cube
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ mu = self.mu.value sigma = self.sigma.value sqrt_two = 1.414213562 if x < 1e-16 or (1 - x) < 1e-16: ...
python
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ mu = self.mu.value sigma = self.sigma.value sqrt_two = 1.414213562 if x < 1e-16 or (1 - x) < 1e-16: ...
Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/priors.py#L75-L98
threeML/astromodels
astromodels/functions/priors.py
Cauchy.from_unit_cube
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ x0 = self.x0.value gamma = self.gamma.value half_pi = 1.57079632679 res = np.tan(np.pi * x - half_pi) * ...
python
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ x0 = self.x0.value gamma = self.gamma.value half_pi = 1.57079632679 res = np.tan(np.pi * x - half_pi) * ...
Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/priors.py#L304-L321
threeML/astromodels
astromodels/functions/priors.py
Cosine_Prior.from_unit_cube
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ cosdec_min = np.cos(deg2rad*(90.0 + self.lower_bound.value)) cosdec_max = np.cos(deg2rad*(90.0 + self.upper_bound.value)) ...
python
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ cosdec_min = np.cos(deg2rad*(90.0 + self.lower_bound.value)) cosdec_max = np.cos(deg2rad*(90.0 + self.upper_bound.value)) ...
Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/priors.py#L404-L428
threeML/astromodels
astromodels/functions/priors.py
Uniform_prior.from_unit_cube
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ lower_bound = self.lower_bound.value upper_bound = self.upper_bound.value low = lower_bound spread = floa...
python
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ lower_bound = self.lower_bound.value upper_bound = self.upper_bound.value low = lower_bound spread = floa...
Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/priors.py#L594-L612
threeML/astromodels
astromodels/functions/priors.py
Log_uniform_prior.from_unit_cube
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ low = math.log10(self.lower_bound.value) up = math.log10(self.upper_bound.value) spread = up - low par = ...
python
def from_unit_cube(self, x): """ Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return: """ low = math.log10(self.lower_bound.value) up = math.log10(self.upper_bound.value) spread = up - low par = ...
Used by multinest :param x: 0 < x < 1 :param lower_bound: :param upper_bound: :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/priors.py#L673-L689
threeML/astromodels
astromodels/utils/data_files.py
_get_data_file_path
def _get_data_file_path(data_file): """ Returns the absolute path to the required data files. :param data_file: relative path to the data file, relative to the astromodels/data path. So to get the path to data/dark_matter/gammamc_dif.dat you need to use data_file="dark_matter/gammamc_dif.dat" :retu...
python
def _get_data_file_path(data_file): """ Returns the absolute path to the required data files. :param data_file: relative path to the data file, relative to the astromodels/data path. So to get the path to data/dark_matter/gammamc_dif.dat you need to use data_file="dark_matter/gammamc_dif.dat" :retu...
Returns the absolute path to the required data files. :param data_file: relative path to the data file, relative to the astromodels/data path. So to get the path to data/dark_matter/gammamc_dif.dat you need to use data_file="dark_matter/gammamc_dif.dat" :return: absolute path of the data file
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/data_files.py#L5-L25
threeML/astromodels
astromodels/functions/dark_matter/dm_models.py
DMFitFunction._setup
def _setup(self): tablepath = _get_data_file_path("dark_matter/gammamc_dif.dat") self._data = np.loadtxt(tablepath) """ Mapping between the channel codes and the rows in the gammamc file 1 : 8, # ee 2 : 6, # mumu 3 : 3, # tautau 4 :...
python
def _setup(self): tablepath = _get_data_file_path("dark_matter/gammamc_dif.dat") self._data = np.loadtxt(tablepath) """ Mapping between the channel codes and the rows in the gammamc file 1 : 8, # ee 2 : 6, # mumu 3 : 3, # tautau 4 :...
Mapping between the channel codes and the rows in the gammamc file 1 : 8, # ee 2 : 6, # mumu 3 : 3, # tautau 4 : 1, # bb 5 : 2, # tt 6 : 7, # gg 7 : 4, # ww 8 : 5, # zz 9 : 0, # cc 10 : 10, # uu ...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/dark_matter/dm_models.py#L48-L108
threeML/astromodels
astromodels/functions/dark_matter/dm_models.py
DMSpectra._setup
def _setup(self): # Get and open the two data files tablepath_h = _get_data_file_path("dark_matter/dmSpecTab.npy") self._data_h = np.load(tablepath_h) tablepath_f = _get_data_file_path("dark_matter/gammamc_dif.dat") self._data_f = np.loadtxt(tablepath_f) """ ...
python
def _setup(self): # Get and open the two data files tablepath_h = _get_data_file_path("dark_matter/dmSpecTab.npy") self._data_h = np.load(tablepath_h) tablepath_f = _get_data_file_path("dark_matter/gammamc_dif.dat") self._data_f = np.loadtxt(tablepath_f) """ ...
Mapping between the channel codes and the rows in the gammamc file dmSpecTab.npy created to match this mapping too 1 : 8, # ee 2 : 6, # mumu 3 : 3, # tautau 4 : 1, # bb 5 : 2, # tt 6 : 7, # gg 7 : 4, # ww 8 : 5,...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/dark_matter/dm_models.py#L209-L291
threeML/astromodels
astromodels/utils/vincenty.py
vincenty
def vincenty(lon0, lat0, a1, s): """ Returns the coordinates of a new point that is a given angular distance s away from a starting point (lon0, lat0) at bearing (angle from north) a1), to within a given precision Note that this calculation is a simplified version of the full vincenty problem, which solves for t...
python
def vincenty(lon0, lat0, a1, s): """ Returns the coordinates of a new point that is a given angular distance s away from a starting point (lon0, lat0) at bearing (angle from north) a1), to within a given precision Note that this calculation is a simplified version of the full vincenty problem, which solves for t...
Returns the coordinates of a new point that is a given angular distance s away from a starting point (lon0, lat0) at bearing (angle from north) a1), to within a given precision Note that this calculation is a simplified version of the full vincenty problem, which solves for the coordinates on the surface on an arbit...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/vincenty.py#L3-L33
threeML/astromodels
astromodels/utils/valid_variable.py
is_valid_variable_name
def is_valid_variable_name(string_to_check): """ Returns whether the provided name is a valid variable name in Python :param string_to_check: the string to be checked :return: True or False """ try: parse('{} = None'.format(string_to_check)) return True except (SyntaxErro...
python
def is_valid_variable_name(string_to_check): """ Returns whether the provided name is a valid variable name in Python :param string_to_check: the string to be checked :return: True or False """ try: parse('{} = None'.format(string_to_check)) return True except (SyntaxErro...
Returns whether the provided name is a valid variable name in Python :param string_to_check: the string to be checked :return: True or False
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/utils/valid_variable.py#L4-L19
threeML/astromodels
astromodels/core/units.py
_check_unit
def _check_unit(new_unit, old_unit): """ Check that the new unit is compatible with the old unit for the quantity described by variable_name :param new_unit: instance of astropy.units.Unit :param old_unit: instance of astropy.units.Unit :return: nothin """ try: new_unit.physical_t...
python
def _check_unit(new_unit, old_unit): """ Check that the new unit is compatible with the old unit for the quantity described by variable_name :param new_unit: instance of astropy.units.Unit :param old_unit: instance of astropy.units.Unit :return: nothin """ try: new_unit.physical_t...
Check that the new unit is compatible with the old unit for the quantity described by variable_name :param new_unit: instance of astropy.units.Unit :param old_unit: instance of astropy.units.Unit :return: nothin
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/units.py#L29-L50
threeML/astromodels
astromodels/functions/functions.py
Log_parabola.peak_energy
def peak_energy(self): """ Returns the peak energy in the nuFnu spectrum :return: peak energy in keV """ # Eq. 6 in Massaro et al. 2004 # (http://adsabs.harvard.edu/abs/2004A%26A...413..489M) return self.piv.value * pow(10, ((2 + self.alpha.value) * np.log(10))...
python
def peak_energy(self): """ Returns the peak energy in the nuFnu spectrum :return: peak energy in keV """ # Eq. 6 in Massaro et al. 2004 # (http://adsabs.harvard.edu/abs/2004A%26A...413..489M) return self.piv.value * pow(10, ((2 + self.alpha.value) * np.log(10))...
Returns the peak energy in the nuFnu spectrum :return: peak energy in keV
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/functions.py#L1562-L1572
threeML/astromodels
astromodels/sources/extended_source.py
ExtendedSource.get_spatially_integrated_flux
def get_spatially_integrated_flux( self, energies): """ Returns total flux of source at the given energy :param energies: energies (array or float) :return: differential flux at given energy """ if not isinstance(energies, np.ndarray): energies = ...
python
def get_spatially_integrated_flux( self, energies): """ Returns total flux of source at the given energy :param energies: energies (array or float) :return: differential flux at given energy """ if not isinstance(energies, np.ndarray): energies = ...
Returns total flux of source at the given energy :param energies: energies (array or float) :return: differential flux at given energy
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/sources/extended_source.py#L128-L159
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.get_ra
def get_ra(self): """ Get R.A. corresponding to the current position (ICRS, J2000) :return: Right Ascension """ try: return self.ra.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transform_to(...
python
def get_ra(self): """ Get R.A. corresponding to the current position (ICRS, J2000) :return: Right Ascension """ try: return self.ra.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transform_to(...
Get R.A. corresponding to the current position (ICRS, J2000) :return: Right Ascension
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L117-L132
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.get_dec
def get_dec(self): """ Get Dec. corresponding to the current position (ICRS, J2000) :return: Declination """ try: return self.dec.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transform_to('i...
python
def get_dec(self): """ Get Dec. corresponding to the current position (ICRS, J2000) :return: Declination """ try: return self.dec.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transform_to('i...
Get Dec. corresponding to the current position (ICRS, J2000) :return: Declination
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L134-L149
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.get_l
def get_l(self): """ Get Galactic Longitude (l) corresponding to the current position :return: Galactic Longitude """ try: return self.l.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transfor...
python
def get_l(self): """ Get Galactic Longitude (l) corresponding to the current position :return: Galactic Longitude """ try: return self.l.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transfor...
Get Galactic Longitude (l) corresponding to the current position :return: Galactic Longitude
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L151-L166
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.get_b
def get_b(self): """ Get Galactic latitude (b) corresponding to the current position :return: Latitude """ try: return self.b.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transform_to('galac...
python
def get_b(self): """ Get Galactic latitude (b) corresponding to the current position :return: Latitude """ try: return self.b.value except AttributeError: # Transform from L,B to R.A., Dec return self.sky_coord.transform_to('galac...
Get Galactic latitude (b) corresponding to the current position :return: Latitude
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L168-L183
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.parameters
def parameters(self): """ Get the dictionary of parameters (either ra,dec or l,b) :return: dictionary of parameters """ if self._coord_type == 'galactic': return collections.OrderedDict((('l', self.l), ('b', self.b))) else: return collections....
python
def parameters(self): """ Get the dictionary of parameters (either ra,dec or l,b) :return: dictionary of parameters """ if self._coord_type == 'galactic': return collections.OrderedDict((('l', self.l), ('b', self.b))) else: return collections....
Get the dictionary of parameters (either ra,dec or l,b) :return: dictionary of parameters
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L216-L229
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.fix
def fix(self): """ Fix the parameters with the coordinates (either ra,dec or l,b depending on how the class has been instanced) """ if self._coord_type == 'equatorial': self.ra.fix = True self.dec.fix = True else: self.l.fi...
python
def fix(self): """ Fix the parameters with the coordinates (either ra,dec or l,b depending on how the class has been instanced) """ if self._coord_type == 'equatorial': self.ra.fix = True self.dec.fix = True else: self.l.fi...
Fix the parameters with the coordinates (either ra,dec or l,b depending on how the class has been instanced)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L258-L273
threeML/astromodels
astromodels/core/sky_direction.py
SkyDirection.free
def free(self): """ Free the parameters with the coordinates (either ra,dec or l,b depending on how the class has been instanced) """ if self._coord_type == 'equatorial': self.ra.fix = False self.dec.fix = False else: self....
python
def free(self): """ Free the parameters with the coordinates (either ra,dec or l,b depending on how the class has been instanced) """ if self._coord_type == 'equatorial': self.ra.fix = False self.dec.fix = False else: self....
Free the parameters with the coordinates (either ra,dec or l,b depending on how the class has been instanced)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/sky_direction.py#L275-L290
threeML/astromodels
astromodels/functions/template_model.py
TemplateModel._custom_init_
def _custom_init_(self, model_name, other_name=None,log_interp = True): """ Custom initialization for this model :param model_name: the name of the model, corresponding to the root of the .h5 file in the data directory :param other_name: (optional) the name to be used as name of...
python
def _custom_init_(self, model_name, other_name=None,log_interp = True): """ Custom initialization for this model :param model_name: the name of the model, corresponding to the root of the .h5 file in the data directory :param other_name: (optional) the name to be used as name of...
Custom initialization for this model :param model_name: the name of the model, corresponding to the root of the .h5 file in the data directory :param other_name: (optional) the name to be used as name of the model when used in astromodels. If None (default), use the same name as model_...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/functions/template_model.py#L304-L407
threeML/astromodels
astromodels/core/parameter.py
accept_quantity
def accept_quantity(input_type=float, allow_none=False): """ A class-method decorator which allow a given method (typically the set_value method) to receive both a astropy.Quantity or a simple float, but to be coded like it's always receiving a pure float in the right units. This is to give ...
python
def accept_quantity(input_type=float, allow_none=False): """ A class-method decorator which allow a given method (typically the set_value method) to receive both a astropy.Quantity or a simple float, but to be coded like it's always receiving a pure float in the right units. This is to give ...
A class-method decorator which allow a given method (typically the set_value method) to receive both a astropy.Quantity or a simple float, but to be coded like it's always receiving a pure float in the right units. This is to give a way to avoid the huge bottleneck that are astropy.units :param...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L71-L125
threeML/astromodels
astromodels/core/parameter.py
ParameterBase.in_unit_of
def in_unit_of(self, unit, as_quantity=False): """ Return the current value transformed to the new units :param unit: either an astropy.Unit instance, or a string which can be converted to an astropy.Unit instance, like "1 / (erg cm**2 s)" :param as_quantity: if True, the me...
python
def in_unit_of(self, unit, as_quantity=False): """ Return the current value transformed to the new units :param unit: either an astropy.Unit instance, or a string which can be converted to an astropy.Unit instance, like "1 / (erg cm**2 s)" :param as_quantity: if True, the me...
Return the current value transformed to the new units :param unit: either an astropy.Unit instance, or a string which can be converted to an astropy.Unit instance, like "1 / (erg cm**2 s)" :param as_quantity: if True, the method return an astropy.Quantity, if False just a floating point num...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L325-L346
threeML/astromodels
astromodels/core/parameter.py
ParameterBase.internal_to_external_delta
def internal_to_external_delta(self, internal_value, internal_delta): """ Transform an interval from the internal to the external reference (through the transformation). It is useful if you have for example a confidence interval in internal reference and you want to transform it to the e...
python
def internal_to_external_delta(self, internal_value, internal_delta): """ Transform an interval from the internal to the external reference (through the transformation). It is useful if you have for example a confidence interval in internal reference and you want to transform it to the e...
Transform an interval from the internal to the external reference (through the transformation). It is useful if you have for example a confidence interval in internal reference and you want to transform it to the external reference :param interval_value: value in internal reference :par...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L373-L389
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._get_value
def _get_value(self): """Return current parameter value""" # This is going to be true (possibly) only for derived classes. It is here to make the code cleaner # and also to avoid infinite recursion if self._aux_variable: return self._aux_variable['law'](self._aux_variable[...
python
def _get_value(self): """Return current parameter value""" # This is going to be true (possibly) only for derived classes. It is here to make the code cleaner # and also to avoid infinite recursion if self._aux_variable: return self._aux_variable['law'](self._aux_variable[...
Return current parameter value
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L394-L415
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._set_value
def _set_value(self, new_value): """Sets the current value of the parameter, ensuring that it is within the allowed range.""" if self.min_value is not None and new_value < self.min_value: raise SettingOutOfBounds( "Trying to set parameter {0} = {1}, which is less than the m...
python
def _set_value(self, new_value): """Sets the current value of the parameter, ensuring that it is within the allowed range.""" if self.min_value is not None and new_value < self.min_value: raise SettingOutOfBounds( "Trying to set parameter {0} = {1}, which is less than the m...
Sets the current value of the parameter, ensuring that it is within the allowed range.
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L420-L471
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._set_internal_value
def _set_internal_value(self, new_internal_value): """ This is supposed to be only used by fitting engines :param new_internal_value: new value in internal representation :return: none """ if new_internal_value != self._internal_value: self._internal_value ...
python
def _set_internal_value(self, new_internal_value): """ This is supposed to be only used by fitting engines :param new_internal_value: new value in internal representation :return: none """ if new_internal_value != self._internal_value: self._internal_value ...
This is supposed to be only used by fitting engines :param new_internal_value: new value in internal representation :return: none
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L491-L507
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._set_min_value
def _set_min_value(self, min_value): """Sets current minimum allowed value""" # Check that the min value can be transformed if a transformation is present if self._transformation is not None: if min_value is not None: try: _ = self._transforma...
python
def _set_min_value(self, min_value): """Sets current minimum allowed value""" # Check that the min value can be transformed if a transformation is present if self._transformation is not None: if min_value is not None: try: _ = self._transforma...
Sets current minimum allowed value
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L518-L550
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._get_internal_min_value
def _get_internal_min_value(self): """ This is supposed to be only used by fitting engines to get the minimum value in internal representation. It is supposed to be called only once before doing the minimization/sampling, to set the range of the parameter :return: minimum value in inter...
python
def _get_internal_min_value(self): """ This is supposed to be only used by fitting engines to get the minimum value in internal representation. It is supposed to be called only once before doing the minimization/sampling, to set the range of the parameter :return: minimum value in inter...
This is supposed to be only used by fitting engines to get the minimum value in internal representation. It is supposed to be called only once before doing the minimization/sampling, to set the range of the parameter :return: minimum value in internal representation (or None if there is no minimum)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L565-L589
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._set_max_value
def _set_max_value(self, max_value): """Sets current maximum allowed value""" self._external_max_value = max_value # Check that the current value of the parameter is still within the boundaries. If not, issue a warning if self._external_max_value is not None and self.value > self._ext...
python
def _set_max_value(self, max_value): """Sets current maximum allowed value""" self._external_max_value = max_value # Check that the current value of the parameter is still within the boundaries. If not, issue a warning if self._external_max_value is not None and self.value > self._ext...
Sets current maximum allowed value
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L600-L612
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._get_internal_max_value
def _get_internal_max_value(self): """ This is supposed to be only used by fitting engines to get the maximum value in internal representation. It is supposed to be called only once before doing the minimization/sampling, to set the range of the parameter :return: maximum value in inter...
python
def _get_internal_max_value(self): """ This is supposed to be only used by fitting engines to get the maximum value in internal representation. It is supposed to be called only once before doing the minimization/sampling, to set the range of the parameter :return: maximum value in inter...
This is supposed to be only used by fitting engines to get the maximum value in internal representation. It is supposed to be called only once before doing the minimization/sampling, to set the range of the parameter :return: maximum value in internal representation (or None if there is no minimum)
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L627-L651
threeML/astromodels
astromodels/core/parameter.py
ParameterBase._set_bounds
def _set_bounds(self, bounds): """Sets the boundaries for this parameter to min_value and max_value""" # Use the properties so that the checks and the handling of units are made automatically min_value, max_value = bounds # Remove old boundaries to avoid problems with the new one, if ...
python
def _set_bounds(self, bounds): """Sets the boundaries for this parameter to min_value and max_value""" # Use the properties so that the checks and the handling of units are made automatically min_value, max_value = bounds # Remove old boundaries to avoid problems with the new one, if ...
Sets the boundaries for this parameter to min_value and max_value
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L653-L667
threeML/astromodels
astromodels/core/parameter.py
ParameterBase.to_dict
def to_dict(self, minimal=False): """Returns the representation for serialization""" data = collections.OrderedDict() if minimal: # In the minimal representation we just output the value data['value'] = self._to_python_type(self.value) else: # I...
python
def to_dict(self, minimal=False): """Returns the representation for serialization""" data = collections.OrderedDict() if minimal: # In the minimal representation we just output the value data['value'] = self._to_python_type(self.value) else: # I...
Returns the representation for serialization
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L709-L732
threeML/astromodels
astromodels/core/parameter.py
Parameter._get_internal_delta
def _get_internal_delta(self): """ This is only supposed to be used by fitting/sampling engine, to get the initial step in internal representation :return: initial delta in internal representation """ if self._transformation is None: return self._delta els...
python
def _get_internal_delta(self): """ This is only supposed to be used by fitting/sampling engine, to get the initial step in internal representation :return: initial delta in internal representation """ if self._transformation is None: return self._delta els...
This is only supposed to be used by fitting/sampling engine, to get the initial step in internal representation :return: initial delta in internal representation
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L847-L908
threeML/astromodels
astromodels/core/parameter.py
Parameter._set_prior
def _set_prior(self, prior): """Set prior for this parameter. The prior must be a function accepting the current value of the parameter as input and giving the probability density as output.""" if prior is None: # Removing prior self._prior = None else: ...
python
def _set_prior(self, prior): """Set prior for this parameter. The prior must be a function accepting the current value of the parameter as input and giving the probability density as output.""" if prior is None: # Removing prior self._prior = None else: ...
Set prior for this parameter. The prior must be a function accepting the current value of the parameter as input and giving the probability density as output.
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L916-L946
threeML/astromodels
astromodels/core/parameter.py
Parameter.set_uninformative_prior
def set_uninformative_prior(self, prior_class): """ Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a log-uniform prior between the current minimum and maximum. NOTE: if the current minimum and maximum are not defined, the default bounds f...
python
def set_uninformative_prior(self, prior_class): """ Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a log-uniform prior between the current minimum and maximum. NOTE: if the current minimum and maximum are not defined, the default bounds f...
Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a log-uniform prior between the current minimum and maximum. NOTE: if the current minimum and maximum are not defined, the default bounds for the prior class will be used. :param prior_class : the c...
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L962-L1011
threeML/astromodels
astromodels/core/parameter.py
Parameter.remove_auxiliary_variable
def remove_auxiliary_variable(self): """ Remove an existing auxiliary variable :return: """ if not self.has_auxiliary_variable(): # do nothing, but print a warning warnings.warn("Cannot remove a non-existing auxiliary variable", RuntimeWarning) ...
python
def remove_auxiliary_variable(self): """ Remove an existing auxiliary variable :return: """ if not self.has_auxiliary_variable(): # do nothing, but print a warning warnings.warn("Cannot remove a non-existing auxiliary variable", RuntimeWarning) ...
Remove an existing auxiliary variable :return:
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L1077-L1102
threeML/astromodels
astromodels/core/parameter.py
Parameter.to_dict
def to_dict(self, minimal=False): """Returns the representation for serialization""" data = super(Parameter, self).to_dict() # Add wether is a normalization or not data['is_normalization'] = self._is_normalization if minimal: # No need to add anything ...
python
def to_dict(self, minimal=False): """Returns the representation for serialization""" data = super(Parameter, self).to_dict() # Add wether is a normalization or not data['is_normalization'] = self._is_normalization if minimal: # No need to add anything ...
Returns the representation for serialization
https://github.com/threeML/astromodels/blob/9aac365a372f77603039533df9a6b694c1e360d5/astromodels/core/parameter.py#L1152-L1190