_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q235200 | User.get_label | train | def get_label(self, label_name):
"""Return the user's label that has a given name.
:param label_name: The name to search for.
:type label_name: str
:return: A label that has a matching name or ``None`` if not found.
:rtype: :class:`pytodoist.todoist.Label`
>>> from pyto... | python | {
"resource": ""
} |
q235201 | User.add_filter | train | def add_filter(self, name, query, color=None, item_order=None):
"""Create a new filter.
.. warning:: Requires Todoist premium.
:param name: The name of the filter.
:param query: The query to search for.
:param color: The color of the filter.
:param item_order: The filte... | python | {
"resource": ""
} |
q235202 | User.get_filter | train | def get_filter(self, name):
"""Return the filter that has the given filter name.
:param name: The name to search for.
:return: The filter with the given name.
:rtype: :class:`pytodoist.todoist.Filter`
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@... | python | {
"resource": ""
} |
q235203 | User._update_notification_settings | train | def _update_notification_settings(self, event, service,
should_notify):
"""Update the settings of a an events notifications.
:param event: Update the notification settings of this event.
:type event: str
:param service: The notification service to u... | python | {
"resource": ""
} |
q235204 | User.get_productivity_stats | train | def get_productivity_stats(self):
"""Return the user's productivity stats.
:return: A JSON-encoded representation of the user's productivity
stats.
:rtype: A JSON-encoded object.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'passw... | python | {
"resource": ""
} |
q235205 | User.delete | train | def delete(self, reason=None):
"""Delete the user's account from Todoist.
.. warning:: You cannot recover the user after deletion!
:param reason: The reason for deletion.
:type reason: str
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com',... | python | {
"resource": ""
} |
q235206 | Project.archive | train | def archive(self):
"""Archive the project.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('PyTodoist')
>>> project.archive()
"""
args = {'id': self.id}
_perform_command(self.owne... | python | {
"resource": ""
} |
q235207 | Project.add_task | train | def add_task(self, content, date=None, priority=None):
"""Add a task to the project
:param content: The task description.
:type content: str
:param date: The task deadline.
:type date: str
:param priority: The priority of the task.
:type priority: int
:re... | python | {
"resource": ""
} |
q235208 | Project.get_uncompleted_tasks | train | def get_uncompleted_tasks(self):
"""Return a list of all uncompleted tasks in this project.
.. warning:: Requires Todoist premium.
:return: A list of all uncompleted tasks in this project.
:rtype: list of :class:`pytodoist.todoist.Task`
>>> from pytodoist import todoist
... | python | {
"resource": ""
} |
q235209 | Project.get_completed_tasks | train | def get_completed_tasks(self):
"""Return a list of all completed tasks in this project.
:return: A list of all completed tasks in this project.
:rtype: list of :class:`pytodoist.todoist.Task`
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'pass... | python | {
"resource": ""
} |
q235210 | Project.get_tasks | train | def get_tasks(self):
"""Return all tasks in this project.
:return: A list of all tasks in this project.class
:rtype: list of :class:`pytodoist.todoist.Task`
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.g... | python | {
"resource": ""
} |
q235211 | Project.add_note | train | def add_note(self, content):
"""Add a note to the project.
.. warning:: Requires Todoist premium.
:param content: The note content.
:type content: str
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = use... | python | {
"resource": ""
} |
q235212 | Project.get_notes | train | def get_notes(self):
"""Return a list of all of the project's notes.
:return: A list of notes.
:rtype: list of :class:`pytodoist.todoist.Note`
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('Py... | python | {
"resource": ""
} |
q235213 | Project.share | train | def share(self, email, message=None):
"""Share the project with another Todoist user.
:param email: The other user's email address.
:type email: str
:param message: Optional message to send with the invitation.
:type message: str
>>> from pytodoist import todoist
... | python | {
"resource": ""
} |
q235214 | Project.delete_collaborator | train | def delete_collaborator(self, email):
"""Remove a collaborating user from the shared project.
:param email: The collaborator's email address.
:type email: str
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user... | python | {
"resource": ""
} |
q235215 | Task.complete | train | def complete(self):
"""Mark the task complete.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('PyTodoist')
>>> task = project.add_task('Install PyTodoist')
>>> task.complete()
"""
... | python | {
"resource": ""
} |
q235216 | Task.uncomplete | train | def uncomplete(self):
"""Mark the task uncomplete.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('PyTodoist')
>>> task = project.add_task('Install PyTodoist')
>>> task.uncomplete()
"""
... | python | {
"resource": ""
} |
q235217 | Task.get_notes | train | def get_notes(self):
"""Return all notes attached to this Task.
:return: A list of all notes attached to this Task.
:rtype: list of :class:`pytodoist.todoist.Note`
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project =... | python | {
"resource": ""
} |
q235218 | Task.move | train | def move(self, project):
"""Move this task to another project.
:param project: The project to move the task to.
:type project: :class:`pytodoist.todoist.Project`
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = u... | python | {
"resource": ""
} |
q235219 | Task.add_date_reminder | train | def add_date_reminder(self, service, due_date):
"""Add a reminder to the task which activates on a given date.
.. warning:: Requires Todoist premium.
:param service: ```email```, ```sms``` or ```push``` for mobile.
:type service: str
:param due_date: The due date in UTC, format... | python | {
"resource": ""
} |
q235220 | Task.add_location_reminder | train | def add_location_reminder(self, service, name, lat, long, trigger, radius):
"""Add a reminder to the task which activates on at a given location.
.. warning:: Requires Todoist premium.
:param service: ```email```, ```sms``` or ```push``` for mobile.
:type service: str
:param na... | python | {
"resource": ""
} |
q235221 | Task.get_reminders | train | def get_reminders(self):
"""Return a list of the task's reminders.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('PyTodoist')
>>> task = project.add_task('Install PyTodoist')
>>> task.add_date_... | python | {
"resource": ""
} |
q235222 | Task.delete | train | def delete(self):
"""Delete the task.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('Homework')
>>> task = project.add_task('Read Chapter 4')
>>> task.delete()
"""
args = {'ids'... | python | {
"resource": ""
} |
q235223 | Note.delete | train | def delete(self):
"""Delete the note, removing it from it's task.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> project = user.get_project('PyTodoist')
>>> task = project.add_task('Install PyTodoist.')
>>> note = task.ad... | python | {
"resource": ""
} |
q235224 | Filter.update | train | def update(self):
"""Update the filter's details on Todoist.
You must call this method to register any local attribute changes with
Todoist.
>>> from pytodoist import todoist
>>> user = todoist.login('john.doe@gmail.com', 'password')
>>> overdue_filter = user.add_filter... | python | {
"resource": ""
} |
q235225 | apply_text | train | def apply_text(incoming, func):
"""Call `func` on text portions of incoming color string.
:param iter incoming: Incoming string/ColorStr/string-like object to iterate.
:param func: Function to call with string portion as first and only parameter.
:return: Modified string, same class type as incoming s... | python | {
"resource": ""
} |
q235226 | ColorBytes.decode | train | def decode(self, encoding='utf-8', errors='strict'):
"""Decode using the codec registered for encoding. Default encoding is 'utf-8'.
errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors
raise a UnicodeDecodeError. Other possible values a... | python | {
"resource": ""
} |
q235227 | ColorStr.center | train | def center(self, width, fillchar=None):
"""Return centered in a string of length width. Padding is done using the specified fill character or space.
:param int width: Length of output string.
:param str fillchar: Use this character instead of spaces.
"""
if fillchar is not None:... | python | {
"resource": ""
} |
q235228 | ColorStr.endswith | train | def endswith(self, suffix, start=0, end=None):
"""Return True if ends with the specified suffix, False otherwise.
With optional start, test beginning at that position. With optional end, stop comparing at that position.
suffix can also be a tuple of strings to try.
:param str suffix: S... | python | {
"resource": ""
} |
q235229 | ColorStr.encode | train | def encode(self, encoding=None, errors='strict'):
"""Encode using the codec registered for encoding. encoding defaults to the default encoding.
errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors
raise a UnicodeEncodeError. Other possib... | python | {
"resource": ""
} |
q235230 | ColorStr.decode | train | def decode(self, encoding=None, errors='strict'):
"""Decode using the codec registered for encoding. encoding defaults to the default encoding.
errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors
raise a UnicodeDecodeError. Other possib... | python | {
"resource": ""
} |
q235231 | ColorStr.format | train | def format(self, *args, **kwargs):
"""Return a formatted version, using substitutions from args and kwargs.
The substitutions are identified by braces ('{' and '}').
"""
return self.__class__(super(ColorStr, self).format(*args, **kwargs), keep_tags=True) | python | {
"resource": ""
} |
q235232 | ColorStr.join | train | def join(self, iterable):
"""Return a string which is the concatenation of the strings in the iterable.
:param iterable: Join items in this iterable.
"""
return self.__class__(super(ColorStr, self).join(iterable), keep_tags=True) | python | {
"resource": ""
} |
q235233 | ColorStr.splitlines | train | def splitlines(self, keepends=False):
"""Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and True.
:param bool keepends: Include linebreaks.
"""
return [self.__class__(l) for l in... | python | {
"resource": ""
} |
q235234 | ColorStr.startswith | train | def startswith(self, prefix, start=0, end=-1):
"""Return True if string starts with the specified prefix, False otherwise.
With optional start, test beginning at that position. With optional end, stop comparing at that position. prefix
can also be a tuple of strings to try.
:param str ... | python | {
"resource": ""
} |
q235235 | ColorStr.zfill | train | def zfill(self, width):
"""Pad a numeric string with zeros on the left, to fill a field of the specified width.
The string is never truncated.
:param int width: Length of output string.
"""
if not self.value_no_colors:
result = self.value_no_colors.zfill(width)
... | python | {
"resource": ""
} |
q235236 | Color.colorize | train | def colorize(cls, color, string, auto=False):
"""Color-code entire string using specified color.
:param str color: Color of string.
:param str string: String to colorize.
:param bool auto: Enable auto-color (dark/light terminal).
:return: Class instance for colorized string.
... | python | {
"resource": ""
} |
q235237 | list_tags | train | 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 | {
"resource": ""
} |
q235238 | ANSICodeMapping.disable_if_no_tty | train | 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 | {
"resource": ""
} |
q235239 | get_console_info | train | 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 | {
"resource": ""
} |
q235240 | bg_color_native_ansi | train | 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 | {
"resource": ""
} |
q235241 | WindowsStream.colors | train | 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 | {
"resource": ""
} |
q235242 | WindowsStream.colors | train | 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 | {
"resource": ""
} |
q235243 | WindowsStream.write | train | 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 | {
"resource": ""
} |
q235244 | prune_overridden | train | 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 | {
"resource": ""
} |
q235245 | parse_input | train | 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 | {
"resource": ""
} |
q235246 | build_color_index | train | 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 | {
"resource": ""
} |
q235247 | find_char_color | train | 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 | {
"resource": ""
} |
q235248 | angular_distance_fast | train | 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 | {
"resource": ""
} |
q235249 | angular_distance | train | 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 | {
"resource": ""
} |
q235250 | memoize | train | 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 | {
"resource": ""
} |
q235251 | Model.free_parameters | train | 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 | {
"resource": ""
} |
q235252 | Model.set_free_parameters | train | 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 | {
"resource": ""
} |
q235253 | Model.add_independent_variable | train | 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 | {
"resource": ""
} |
q235254 | Model.remove_independent_variable | train | 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 | {
"resource": ""
} |
q235255 | Model.add_external_parameter | train | 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 | {
"resource": ""
} |
q235256 | Model.unlink | train | 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 | {
"resource": ""
} |
q235257 | Model.display | train | 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 | {
"resource": ""
} |
q235258 | Model.save | train | 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 | {
"resource": ""
} |
q235259 | Model.get_point_source_fluxes | train | 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 | {
"resource": ""
} |
q235260 | Model.get_extended_source_fluxes | train | 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 | {
"resource": ""
} |
q235261 | long_path_formatter | train | 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 | {
"resource": ""
} |
q235262 | PointSource.has_free_parameters | train | 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 | {
"resource": ""
} |
q235263 | PointSource._repr__base | train | 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 | {
"resource": ""
} |
q235264 | get_function | train | 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 | {
"resource": ""
} |
q235265 | get_function_class | train | 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 | {
"resource": ""
} |
q235266 | FunctionMeta.check_calling_sequence | train | 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 | {
"resource": ""
} |
q235267 | Function.free_parameters | train | 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 | {
"resource": ""
} |
q235268 | _get_data_file_path | train | 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 | {
"resource": ""
} |
q235269 | DMFitFunction._setup | train | 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 | {
"resource": ""
} |
q235270 | DMSpectra._setup | train | 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 | {
"resource": ""
} |
q235271 | is_valid_variable_name | train | 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 | {
"resource": ""
} |
q235272 | _check_unit | train | 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 | {
"resource": ""
} |
q235273 | Log_parabola.peak_energy | train | 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 | {
"resource": ""
} |
q235274 | ParameterBase.in_unit_of | train | 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 | {
"resource": ""
} |
q235275 | ParameterBase._get_value | train | 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 | {
"resource": ""
} |
q235276 | ParameterBase._set_value | train | 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 | {
"resource": ""
} |
q235277 | ParameterBase._set_internal_value | train | 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 | {
"resource": ""
} |
q235278 | ParameterBase._set_min_value | train | 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 | {
"resource": ""
} |
q235279 | ParameterBase._set_max_value | train | 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 | {
"resource": ""
} |
q235280 | ParameterBase._set_bounds | train | 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 | {
"resource": ""
} |
q235281 | Parameter._set_prior | train | 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 | {
"resource": ""
} |
q235282 | Parameter.set_uninformative_prior | train | 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 | {
"resource": ""
} |
q235283 | Parameter.remove_auxiliary_variable | train | 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 | {
"resource": ""
} |
q235284 | OldNode._get_child_from_path | train | def _get_child_from_path(self, path):
"""
Return a children below this level, starting from a path of the kind "this_level.something.something.name"
:param path: the key
:return: the child
"""
keys = path.split(".")
this_child = self
for key in keys:
... | python | {
"resource": ""
} |
q235285 | OldNode._find_instances | train | def _find_instances(self, cls):
"""
Find all the instances of cls below this node.
:return: a dictionary of instances of cls
"""
instances = collections.OrderedDict()
for child_name, child in self._children.iteritems():
if isinstance(child, cls):
... | python | {
"resource": ""
} |
q235286 | find_library | train | def find_library(library_root, additional_places=None):
"""
Returns the name of the library without extension
:param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so
:return: the name of the library found (NOTE: this is *not* the path), and a director... | python | {
"resource": ""
} |
q235287 | dict_to_table | train | def dict_to_table(dictionary, list_of_keys=None):
"""
Return a table representing the dictionary.
:param dictionary: the dictionary to represent
:param list_of_keys: optionally, only the keys in this list will be inserted in the table
:return: a Table instance
"""
# assert len(dictionary.v... | python | {
"resource": ""
} |
q235288 | Table._base_repr_ | train | def _base_repr_(self, html=False, show_name=True, **kwargs):
"""
Override the method in the astropy.Table class
to avoid displaying the description, and the format
of the columns
"""
table_id = 'table{id}'.format(id=id(self))
data_lines, outs = self.formatter._p... | python | {
"resource": ""
} |
q235289 | ExtraGraphQLView.fetch_cache_key | train | def fetch_cache_key(request):
""" Returns a hashed cache key. """
m = hashlib.md5()
m.update(request.body)
return m.hexdigest() | python | {
"resource": ""
} |
q235290 | ExtraGraphQLView.dispatch | train | def dispatch(self, request, *args, **kwargs):
""" Fetches queried data from graphql and returns cached & hashed key. """
if not graphql_api_settings.CACHE_ACTIVE:
return self.super_call(request, *args, **kwargs)
cache = caches["default"]
operation_ast = self.get_operation_as... | python | {
"resource": ""
} |
q235291 | _parse | train | def _parse(partial_dt):
"""
parse a partial datetime object to a complete datetime object
"""
dt = None
try:
if isinstance(partial_dt, datetime):
dt = partial_dt
if isinstance(partial_dt, date):
dt = _combine_date_time(partial_dt, time(0, 0, 0))
if isi... | python | {
"resource": ""
} |
q235292 | clean_dict | train | def clean_dict(d):
"""
Remove all empty fields in a nested dict
"""
if not isinstance(d, (dict, list)):
return d
if isinstance(d, list):
return [v for v in (clean_dict(v) for v in d) if v]
return OrderedDict(
[(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d... | python | {
"resource": ""
} |
q235293 | _get_queryset | train | def _get_queryset(klass):
"""
Returns a QuerySet from a Model, Manager, or QuerySet. Created to make
get_object_or_404 and get_list_or_404 more DRY.
Raises a ValueError if klass is not a Model, Manager, or QuerySet.
"""
if isinstance(klass, QuerySet):
return klass
elif isinstance(kl... | python | {
"resource": ""
} |
q235294 | find_schema_paths | train | def find_schema_paths(schema_files_path=DEFAULT_SCHEMA_FILES_PATH):
"""Searches the locations in the `SCHEMA_FILES_PATH` to
try to find where the schema SQL files are located.
"""
paths = []
for path in schema_files_path:
if os.path.isdir(path):
paths.append(path)
if paths:
... | python | {
"resource": ""
} |
q235295 | run | train | def run():
"""Exposes a CLI to configure the SharQ Server and runs the server."""
# create a arg parser and configure it.
parser = argparse.ArgumentParser(description='SharQ Server.')
parser.add_argument('-c', '--config', action='store', required=True,
help='Absolute path of the ... | python | {
"resource": ""
} |
q235296 | setup_server | train | def setup_server(config_path):
"""Configure SharQ server, start the requeue loop
and return the server."""
# configure the SharQ server
server = SharQServer(config_path)
# start the requeue loop
gevent.spawn(server.requeue)
return server | python | {
"resource": ""
} |
q235297 | SharQServer.requeue | train | def requeue(self):
"""Loop endlessly and requeue expired jobs."""
job_requeue_interval = float(
self.config.get('sharq', 'job_requeue_interval'))
while True:
self.sq.requeue()
gevent.sleep(job_requeue_interval / 1000.00) | python | {
"resource": ""
} |
q235298 | SharQServer._view_enqueue | train | def _view_enqueue(self, queue_type, queue_id):
"""Enqueues a job into SharQ."""
response = {
'status': 'failure'
}
try:
request_data = json.loads(request.data)
except Exception, e:
response['message'] = e.message
return jsonify(**re... | python | {
"resource": ""
} |
q235299 | SharQServer._view_dequeue | train | def _view_dequeue(self, queue_type):
"""Dequeues a job from SharQ."""
response = {
'status': 'failure'
}
request_data = {
'queue_type': queue_type
}
try:
response = self.sq.dequeue(**request_data)
if response['status'] == '... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.