Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def server_url_for_websocket_url(url):
''' Convert an ``ws(s)`` URL for a Bokeh server into the appropriate
``http(s)`` URL for the websocket endpoint.
Args:
url (str):
An ``ws(s)`` URL ending in ``/ws``
Returns:
str:
... | [] |
Please provide a description of the function:def websocket_url_for_server_url(url):
''' Convert an ``http(s)`` URL for a Bokeh server websocket endpoint into
the appropriate ``ws(s)`` URL
Args:
url (str):
An ``http(s)`` URL
Returns:
str:
The corresponding ``ws(s... | [] |
Please provide a description of the function:def without_property_validation(input_function):
''' Turn off property validation during update callbacks
Example:
.. code-block:: python
@without_property_validation
def update(attr, old, new):
# do things without va... | [] |
Please provide a description of the function:def get_env():
''' Get the correct Jinja2 Environment, also for frozen scripts.
'''
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
# PyInstaller uses _MEIPASS and only works with jinja2.FileSystemLoader
templates_path = join(sys._M... | [] |
Please provide a description of the function:def parallel_plot(df, color=None, palette=None):
npts = df.shape[0]
ndims = len(df.columns)
if color is None:
color = np.ones(npts)
if palette is None:
palette = ['#ff0000']
cmap = LinearColorMapper(high=color.min(),
... | [
"From a dataframe create a parallel coordinate plot\n "
] |
Please provide a description of the function:def handle(self, message, connection):
''' Delegate a received message to the appropriate handler.
Args:
message (Message) :
The message that was receive that needs to be handled
connection (ServerConnection) :
... | [] |
Please provide a description of the function:def _needs_document_lock(func):
'''Decorator that adds the necessary locking and post-processing
to manipulate the session's document. Expects to decorate a
method on ServerSession and transforms it into a coroutine
if it wasn't already.
'''
... | [] |
Please provide a description of the function:def unsubscribe(self, connection):
self._subscribed_connections.discard(connection)
self._last_unsubscribe_time = current_time() | [
"This should only be called by ``ServerConnection.unsubscribe_session`` or our book-keeping will be broken"
] |
Please provide a description of the function:def set_cwd(self, dirname):
# Replace single for double backslashes on Windows
if os.name == 'nt':
dirname = dirname.replace(u"\\", u"\\\\")
if not self.external_kernel:
code = u"get_ipython().kernel.set_cwd(u'''{}'''... | [
"Set shell current working directory."
] |
Please provide a description of the function:def set_bracket_matcher_color_scheme(self, color_scheme):
bsh = sh.BaseSH(parent=self, color_scheme=color_scheme)
mpcolor = bsh.get_matched_p_color()
self._bracket_matcher.format.setBackground(mpcolor) | [
"Set color scheme for matched parentheses."
] |
Please provide a description of the function:def set_color_scheme(self, color_scheme, reset=True):
self.set_bracket_matcher_color_scheme(color_scheme)
self.style_sheet, dark_color = create_qss_style(color_scheme)
self.syntax_style = color_scheme
self._style_sheet_changed()
... | [
"Set color scheme of the shell."
] |
Please provide a description of the function:def long_banner(self):
# Default banner
try:
from IPython.core.usage import quick_guide
except Exception:
quick_guide = ''
banner_parts = [
'Python %s\n' % self.interpreter_versions['python_version'... | [
"Banner for IPython widgets with pylab message",
"\nThese commands were executed:\n>>> from __future__ import division\n>>> from sympy import *\n>>> x, y, z, t = symbols('x y z t')\n>>> k, m, n = symbols('k m n', integer=True)\n>>> f, g, h = symbols('f g h', cls=Function)\n",
"\nWarning: pylab (numpy and matplo... |
Please provide a description of the function:def reset_namespace(self, warning=False, message=False):
reset_str = _("Remove all variables")
warn_str = _("All user-defined variables will be removed. "
"Are you sure you want to proceed?")
kernel_env = self.kernel_mana... | [
"Reset the namespace by removing all names defined by the user.",
"\n from __future__ import division\n from sympy import *\n x, y, z, t = symbols('x y z t')\n k, m, n = symbols('k m n', integer=True)\n ... |
Please provide a description of the function:def create_shortcuts(self):
inspect = config_shortcut(self._control.inspect_current_object,
context='Console',
name='Inspect current object', parent=self)
clear_console = config_shor... | [
"Create shortcuts for ipyconsole."
] |
Please provide a description of the function:def silent_execute(self, code):
try:
self.kernel_client.execute(to_text_string(code), silent=True)
except AttributeError:
pass | [
"Execute code in the kernel without increasing the prompt"
] |
Please provide a description of the function:def silent_exec_method(self, code):
# Generate uuid, which would be used as an indication of whether or
# not the unique request originated from here
local_uuid = to_text_string(uuid.uuid1())
code = to_text_string(code)
if sel... | [
"Silently execute a kernel method and save its reply\n\n The methods passed here **don't** involve getting the value\n of a variable but instead replies that can be handled by\n ast.literal_eval.\n\n To get a value see `get_value`\n\n Parameters\n ----------\n code :... |
Please provide a description of the function:def handle_exec_method(self, msg):
user_exp = msg['content'].get('user_expressions')
if not user_exp:
return
for expression in user_exp:
if expression in self._kernel_methods:
# Process kernel reply
... | [
"\n Handle data returned by silent executions of kernel methods\n\n This is based on the _handle_exec_callback of RichJupyterWidget.\n Therefore this is licensed BSD.\n "
] |
Please provide a description of the function:def set_backend_for_mayavi(self, command):
calling_mayavi = False
lines = command.splitlines()
for l in lines:
if not l.startswith('#'):
if 'import mayavi' in l or 'from mayavi' in l:
calling_ma... | [
"\n Mayavi plots require the Qt backend, so we try to detect if one is\n generated to change backends\n "
] |
Please provide a description of the function:def change_mpl_backend(self, command):
if command.startswith('%matplotlib') and \
len(command.splitlines()) == 1:
if not 'inline' in command:
self.silent_execute(command) | [
"\n If the user is trying to change Matplotlib backends with\n %matplotlib, send the same command again to the kernel to\n correctly change it.\n\n Fixes issue 4002\n "
] |
Please provide a description of the function:def _context_menu_make(self, pos):
menu = super(ShellWidget, self)._context_menu_make(pos)
return self.ipyclient.add_actions_to_context_menu(menu) | [
"Reimplement the IPython context menu"
] |
Please provide a description of the function:def _banner_default(self):
# Don't change banner for external kernels
if self.external_kernel:
return ''
show_banner_o = self.additional_options['show_banner']
if show_banner_o:
return self.long_banner()
... | [
"\n Reimplement banner creation to let the user decide if he wants a\n banner or not\n "
] |
Please provide a description of the function:def _syntax_style_changed(self):
if self._highlighter is None:
# ignore premature calls
return
if self.syntax_style:
self._highlighter._style = create_style_class(self.syntax_style)
self._highlighter._c... | [
"Refresh the highlighting with the current syntax style by class."
] |
Please provide a description of the function:def _prompt_started_hook(self):
if not self._reading:
self._highlighter.highlighting_on = True
self.sig_prompt_ready.emit() | [
"Emit a signal when the prompt is ready."
] |
Please provide a description of the function:def focusInEvent(self, event):
self.focus_changed.emit()
return super(ShellWidget, self).focusInEvent(event) | [
"Reimplement Qt method to send focus change notification"
] |
Please provide a description of the function:def focusOutEvent(self, event):
self.focus_changed.emit()
return super(ShellWidget, self).focusOutEvent(event) | [
"Reimplement Qt method to send focus change notification"
] |
Please provide a description of the function:def register(self, panel, position=Panel.Position.LEFT):
assert panel is not None
pos_to_string = {
Panel.Position.BOTTOM: 'bottom',
Panel.Position.LEFT: 'left',
Panel.Position.RIGHT: 'right',
Panel.Pos... | [
"\n Installs a panel on the editor.\n\n :param panel: Panel to install\n :param position: Position where the panel must be installed.\n :return: The installed panel\n "
] |
Please provide a description of the function:def remove(self, name_or_klass):
logger.debug('removing panel %s' % name_or_klass)
panel = self.get(name_or_klass)
panel.on_uninstall()
panel.hide()
panel.setParent(None)
return self._panels[panel.position].pop(panel.n... | [
"\n Removes the specified panel.\n\n :param name_or_klass: Name or class of the panel to remove.\n :return: The removed panel\n "
] |
Please provide a description of the function:def clear(self):
for i in range(4):
while len(self._panels[i]):
key = sorted(list(self._panels[i].keys()))[0]
panel = self.remove(key)
panel.setParent(None)
panel.deleteLater() | [
"Removes all panel from the CodeEditor."
] |
Please provide a description of the function:def get(self, name_or_klass):
if not is_text_string(name_or_klass):
name_or_klass = name_or_klass.__name__
for zone in range(4):
try:
panel = self._panels[zone][name_or_klass]
except KeyError:
... | [
"\n Gets a specific panel instance.\n\n :param name_or_klass: Name or class of the panel to retrieve.\n :return: The specified panel instance.\n "
] |
Please provide a description of the function:def refresh(self):
logger.debug('Refresh panels')
self.resize()
self._update(self.editor.contentsRect(), 0,
force_update_margins=True) | [
"Refreshes the editor panels (resize and update margins)."
] |
Please provide a description of the function:def resize(self):
crect = self.editor.contentsRect()
view_crect = self.editor.viewport().contentsRect()
s_bottom, s_left, s_right, s_top = self._compute_zones_sizes()
tw = s_left + s_right
th = s_bottom + s_top
w_offse... | [
"Resizes panels."
] |
Please provide a description of the function:def update_floating_panels(self):
crect = self.editor.contentsRect()
panels = self.panels_for_zone(Panel.Position.FLOATING)
for panel in panels:
if not panel.isVisible():
continue
panel.set_geometry(cre... | [
"Update foating panels."
] |
Please provide a description of the function:def _update_viewport_margins(self):
top = 0
left = 0
right = 0
bottom = 0
for panel in self.panels_for_zone(Panel.Position.LEFT):
if panel.isVisible():
width = panel.sizeHint().width()
... | [
"Update viewport margins."
] |
Please provide a description of the function:def _compute_zones_sizes(self):
# Left panels
left = 0
for panel in self.panels_for_zone(Panel.Position.LEFT):
if not panel.isVisible():
continue
size_hint = panel.sizeHint()
left += size_hi... | [
"Compute panel zone sizes."
] |
Please provide a description of the function:def python_like_mod_finder(import_line, alt_path=None,
stop_token=None):
if stop_token and '.' in stop_token:
stop_token = stop_token.split('.')[-1]
tokens = re.split(r'\W', import_line)
if tokens[0] in ['from', 'impo... | [
"\r\n Locate a module path based on an import line in an python-like file\r\n\r\n import_line is the line of source code containing the import\r\n alt_path specifies an alternate base path for the module\r\n stop_token specifies the desired name to stop on\r\n\r\n This is used to a find the path to p... |
Please provide a description of the function:def get_definition_with_regex(source, token, start_line=-1):
if not token:
return None
if DEBUG_EDITOR:
t0 = time.time()
patterns = [ # python / cython keyword definitions
r'^c?import.*\W{0}{1}',
r'fro... | [
"\r\n Find the definition of an object within a source closest to a given line\r\n "
] |
Please provide a description of the function:def python_like_exts():
exts = []
for lang in languages.PYTHON_LIKE_LANGUAGES:
exts.extend(list(languages.ALL_LANGUAGES[lang]))
return ['.' + ext for ext in exts] | [
"Return a list of all python-like extensions"
] |
Please provide a description of the function:def all_editable_exts():
exts = []
for (language, extensions) in languages.ALL_LANGUAGES.items():
exts.extend(list(extensions))
return ['.' + ext for ext in exts] | [
"Return a list of all editable extensions"
] |
Please provide a description of the function:def _complete_path(path=None):
if not path:
return _listdir('.')
dirname, rest = os.path.split(path)
tmp = dirname if dirname else '.'
res = [p for p in _listdir(tmp) if p.startswith(rest)]
# more than one match, or single match which ... | [
"Perform completion of filesystem path.\r\n https://stackoverflow.com/questions/5637124/tab-completion-in-pythons-raw-input\r\n "
] |
Please provide a description of the function:def get_completions(self, info):
if not info['obj']:
return
items = []
obj = info['obj']
if info['context']:
lexer = find_lexer_for_filename(info['filename'])
# get a list of token matches f... | [
"Return a list of (completion, type) tuples\r\n\r\n Simple completion based on python-like identifiers and whitespace\r\n "
] |
Please provide a description of the function:def get_definition(self, info):
if not info['is_python_like']:
return
token = info['obj']
lines = info['lines']
source_code = info['source_code']
filename = info['filename']
line_nr = None
... | [
"\r\n Find the definition for an object within a set of source code\r\n\r\n This is used to find the path of python-like modules\r\n (e.g. cython and enaml) for a goto definition\r\n "
] |
Please provide a description of the function:def get_info(self, info):
if info['docstring']:
if info['filename']:
filename = os.path.basename(info['filename'])
filename = os.path.splitext(filename)[0]
else:
filename = '<modu... | [
"Get a formatted calltip and docstring from Fallback"
] |
Please provide a description of the function:def create_dialog(obj, obj_name):
# Local import
from spyder_kernels.utils.nsview import (ndarray, FakeObject,
Image, is_known_type, DataFrame,
Series)
from spyde... | [
"Creates the editor dialog and returns a tuple (dialog, func) where func\r\n is the function to be called with the dialog instance as argument, after \r\n quitting the dialog box\r\n \r\n The role of this intermediate function is to allow easy monkey-patching.\r\n (uschmitt suggested this indirection... |
Please provide a description of the function:def oedit(obj, modal=True, namespace=None):
# Local import
from spyder.utils.qthelpers import qapplication
app = qapplication()
if modal:
obj_name = ''
else:
assert is_text_string(obj)
obj_name = obj
if... | [
"Edit the object 'obj' in a GUI-based editor and return the edited copy\r\n (if Cancel is pressed, return None)\r\n\r\n The object 'obj' is a container\r\n \r\n Supported container types:\r\n dict, list, set, tuple, str/unicode or numpy.array\r\n \r\n (instantiate a new QApplication if necessar... |
Please provide a description of the function:def get_item_children(item):
children = [item.child(index) for index in range(item.childCount())]
for child in children[:]:
others = get_item_children(child)
if others is not None:
children += others
return sorted(children,... | [
"Return a sorted list of all the children items of 'item'."
] |
Please provide a description of the function:def item_at_line(root_item, line):
previous_item = root_item
item = root_item
for item in get_item_children(root_item):
if item.line > line:
return previous_item
previous_item = item
else:
return item | [
"\r\n Find and return the item of the outline explorer under which is located\r\n the specified 'line' of the editor.\r\n "
] |
Please provide a description of the function:def get_actions_from_items(self, items):
fromcursor_act = create_action(self, text=_('Go to cursor position'),
icon=ima.icon('fromcursor'),
triggered=self.go_to_cursor_position... | [
"Reimplemented OneColumnTree method"
] |
Please provide a description of the function:def __hide_or_show_root_items(self, item):
for _it in self.get_top_level_items():
_it.setHidden(_it is not item and not self.show_all_files) | [
"\r\n show_all_files option is disabled: hide all root items except *item*\r\n show_all_files option is enabled: do nothing\r\n "
] |
Please provide a description of the function:def set_current_editor(self, editor, update):
editor_id = editor.get_id()
if editor_id in list(self.editor_ids.values()):
item = self.editor_items[editor_id]
if not self.freeze:
self.scrollToItem(item)
... | [
"Bind editor instance"
] |
Please provide a description of the function:def file_renamed(self, editor, new_filename):
if editor is None:
# This is needed when we can't find an editor to attach
# the outline explorer to.
# Fix issue 8813
return
editor_id = editor.get_... | [
"File was renamed, updating outline explorer tree"
] |
Please provide a description of the function:def set_editor_ids_order(self, ordered_editor_ids):
if self.ordered_editor_ids != ordered_editor_ids:
self.ordered_editor_ids = ordered_editor_ids
if self.sort_files_alphabetically is False:
self.__sort_toplevel_i... | [
"\r\n Order the root file items in the Outline Explorer following the\r\n provided list of editor ids.\r\n "
] |
Please provide a description of the function:def __sort_toplevel_items(self):
if self.show_all_files is False:
return
current_ordered_items = [self.topLevelItem(index) for index in
range(self.topLevelItemCount())]
if self.sort_files_a... | [
"\r\n Sort the root file items in alphabetical order if\r\n 'sort_files_alphabetically' is True, else order the items as\r\n specified in the 'self.ordered_editor_ids' list.\r\n "
] |
Please provide a description of the function:def populate_branch(self, editor, root_item, tree_cache=None):
if tree_cache is None:
tree_cache = {}
# Removing cached items for which line is > total line nb
for _l in list(tree_cache.keys()):
if _l >... | [
"\r\n Generates an outline of the editor's content and stores the result\r\n in a cache.\r\n "
] |
Please provide a description of the function:def root_item_selected(self, item):
if self.show_all_files:
return
for root_item in self.get_top_level_items():
if root_item is item:
self.expandItem(root_item)
else:
self.co... | [
"Root item has been selected: expanding it and collapsing others"
] |
Please provide a description of the function:def restore(self):
if self.current_editor is not None:
self.collapseAll()
editor_id = self.editor_ids[self.current_editor]
self.root_item_selected(self.editor_items[editor_id]) | [
"Reimplemented OneColumnTree method"
] |
Please provide a description of the function:def get_root_item(self, item):
root_item = item
while isinstance(root_item.parent(), QTreeWidgetItem):
root_item = root_item.parent()
return root_item | [
"Return the root item of the specified item."
] |
Please provide a description of the function:def get_visible_items(self):
items = []
iterator = QTreeWidgetItemIterator(self)
while iterator.value():
item = iterator.value()
if not item.isHidden():
if item.parent():
if ... | [
"Return a list of all visible items in the treewidget."
] |
Please provide a description of the function:def activated(self, item):
editor_item = self.editor_items.get(
self.editor_ids.get(self.current_editor))
line = 0
if item == editor_item:
line = 1
elif isinstance(item, TreeItem):
line = it... | [
"Double-click event"
] |
Please provide a description of the function:def clicked(self, item):
if isinstance(item, FileRootItem):
self.root_item_selected(item)
self.activated(item) | [
"Click event"
] |
Please provide a description of the function:def setup_buttons(self):
self.fromcursor_btn = create_toolbutton(
self, icon=ima.icon('fromcursor'), tip=_('Go to cursor position'),
triggered=self.treewidget.go_to_cursor_position)
buttons = [self.fromcursor_btn]
... | [
"Setup the buttons of the outline explorer widget toolbar."
] |
Please provide a description of the function:def get_options(self):
return dict(
show_fullpath=self.treewidget.show_fullpath,
show_all_files=self.treewidget.show_all_files,
group_cells=self.treewidget.group_cells,
show_comments=self.treewidget.show_... | [
"\r\n Return outline explorer options\r\n "
] |
Please provide a description of the function:def on_uninstall(self):
self._on_close = True
self.enabled = False
self._editor = None | [
"Uninstalls the editor extension from the editor."
] |
Please provide a description of the function:def add_to_distribution(dist):
try:
dist.add_qt_bindings()
except AttributeError:
raise ImportError("This script requires guidata 1.5+")
for _modname in ('spyder', 'spyderplugins'):
dist.add_module_data_files(_modname, ("", ),
... | [
"Add package to py2exe/cx_Freeze distribution object\n Extension to guidata.disthelpers"
] |
Please provide a description of the function:def get_versions(reporev=True):
import sys
import platform
import qtpy
import qtpy.QtCore
revision = None
if reporev:
from spyder.utils import vcs
revision, branch = vcs.get_git_revision(os.path.dirname(__dir__))
if not sys... | [
"Get version information for components used by Spyder"
] |
Please provide a description of the function:def is_number(dtype):
return is_float(dtype) or ('int' in dtype.name) or ('long' in dtype.name) \
or ('short' in dtype.name) | [
"Return True is datatype dtype is a number kind"
] |
Please provide a description of the function:def get_idx_rect(index_list):
rows, cols = list(zip(*[(i.row(), i.column()) for i in index_list]))
return ( min(rows), max(rows), min(cols), max(cols) ) | [
"Extract the boundaries from a list of indexes"
] |
Please provide a description of the function:def columnCount(self, qindex=QModelIndex()):
if self.total_cols <= self.cols_loaded:
return self.total_cols
else:
return self.cols_loaded | [
"Array column number"
] |
Please provide a description of the function:def rowCount(self, qindex=QModelIndex()):
if self.total_rows <= self.rows_loaded:
return self.total_rows
else:
return self.rows_loaded | [
"Array row number"
] |
Please provide a description of the function:def data(self, index, role=Qt.DisplayRole):
if not index.isValid():
return to_qvariant()
value = self.get_value(index)
if is_binary_string(value):
try:
value = to_text_string(value, 'utf8')
... | [
"Cell content"
] |
Please provide a description of the function:def setData(self, index, value, role=Qt.EditRole):
if not index.isValid() or self.readonly:
return False
i = index.row()
j = index.column()
value = from_qvariant(value, str)
dtype = self._data.dtype.name
... | [
"Cell content change"
] |
Please provide a description of the function:def headerData(self, section, orientation, role=Qt.DisplayRole):
if role != Qt.DisplayRole:
return to_qvariant()
labels = self.xlabels if orientation == Qt.Horizontal else self.ylabels
if labels is None:
return t... | [
"Set header data"
] |
Please provide a description of the function:def createEditor(self, parent, option, index):
model = index.model()
value = model.get_value(index)
if model._data.dtype.name == "bool":
value = not value
model.setData(index, to_qvariant(value))
ret... | [
"Create editor widget"
] |
Please provide a description of the function:def commitAndCloseEditor(self):
editor = self.sender()
# Avoid a segfault with PyQt5. Variable value won't be changed
# but at least Spyder won't crash. It seems generated by a bug in sip.
try:
self.commitData.emit(e... | [
"Commit and close editor"
] |
Please provide a description of the function:def setEditorData(self, editor, index):
text = from_qvariant(index.model().data(index, Qt.DisplayRole), str)
editor.setText(text) | [
"Set editor widget's data"
] |
Please provide a description of the function:def resize_to_contents(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.resizeColumnsToContents()
self.model().fetch_more(columns=True)
self.resizeColumnsToContents()
QApplication.restoreOverrideCursor(... | [
"Resize cells to contents"
] |
Please provide a description of the function:def setup_menu(self):
self.copy_action = create_action(self, _('Copy'),
shortcut=keybinding('Copy'),
icon=ima.icon('editcopy'),
tr... | [
"Setup context menu"
] |
Please provide a description of the function:def contextMenuEvent(self, event):
self.menu.popup(event.globalPos())
event.accept() | [
"Reimplement Qt method"
] |
Please provide a description of the function:def keyPressEvent(self, event):
if event == QKeySequence.Copy:
self.copy()
else:
QTableView.keyPressEvent(self, event) | [
"Reimplement Qt method"
] |
Please provide a description of the function:def _sel_to_text(self, cell_range):
if not cell_range:
return
row_min, row_max, col_min, col_max = get_idx_rect(cell_range)
if col_min == 0 and col_max == (self.model().cols_loaded-1):
# we've selected a whole co... | [
"Copy an array portion to a unicode string"
] |
Please provide a description of the function:def copy(self):
cliptxt = self._sel_to_text( self.selectedIndexes() )
clipboard = QApplication.clipboard()
clipboard.setText(cliptxt) | [
"Copy text to clipboard"
] |
Please provide a description of the function:def accept_changes(self):
for (i, j), value in list(self.model.changes.items()):
self.data[i, j] = value
if self.old_data_shape is not None:
self.data.shape = self.old_data_shape | [
"Accept changes"
] |
Please provide a description of the function:def change_format(self):
format, valid = QInputDialog.getText(self, _( 'Format'),
_( "Float formatting"),
QLineEdit.Normal, self.model.get_format())
if valid:
format ... | [
"Change display format"
] |
Please provide a description of the function:def setup_and_check(self, data, title='', readonly=False,
xlabels=None, ylabels=None):
self.data = data
readonly = readonly or not self.data.flags.writeable
is_record_array = data.dtype.names is not None
... | [
"\r\n Setup ArrayEditor:\r\n return False if data is not supported, True otherwise\r\n "
] |
Please provide a description of the function:def change_active_widget(self, index):
string_index = [':']*3
string_index[self.last_dim] = '<font color=red>%i</font>'
self.slicing_label.setText((r"Slicing: [" + ", ".join(string_index) +
"]") % index)
... | [
"\r\n This is implemented for handling negative values in index for\r\n 3d arrays, to give the same behavior as slicing\r\n "
] |
Please provide a description of the function:def current_dim_changed(self, index):
self.last_dim = index
string_size = ['%i']*3
string_size[index] = '<font color=red>%i</font>'
self.shape_label.setText(('Shape: (' + ', '.join(string_size) +
... | [
"\r\n This change the active axis the array editor is plotting over\r\n in 3D\r\n "
] |
Please provide a description of the function:def accept(self):
for index in range(self.stack.count()):
self.stack.widget(index).accept_changes()
QDialog.accept(self) | [
"Reimplement Qt method"
] |
Please provide a description of the function:def error(self, message):
QMessageBox.critical(self, _("Array editor"), message)
self.setAttribute(Qt.WA_DeleteOnClose)
self.reject() | [
"An error occured, closing the dialog box"
] |
Please provide a description of the function:def reject(self):
if self.arraywidget is not None:
for index in range(self.stack.count()):
self.stack.widget(index).reject_changes()
QDialog.reject(self) | [
"Reimplement Qt method"
] |
Please provide a description of the function:def find_lexer_for_filename(filename):
filename = filename or ''
root, ext = os.path.splitext(filename)
if ext in custom_extension_lexer_mapping:
lexer = get_lexer_by_name(custom_extension_lexer_mapping[ext])
else:
try:
lexer ... | [
"Get a Pygments Lexer given a filename.\n "
] |
Please provide a description of the function:def get_keywords(lexer):
if not hasattr(lexer, 'tokens'):
return []
if 'keywords' in lexer.tokens:
try:
return lexer.tokens['keywords'][0][0].words
except:
pass
keywords = []
for vals in lexer.tokens.values... | [
"Get the keywords for a given lexer.\n "
] |
Please provide a description of the function:def get_words(file_path=None, content=None, extension=None):
if (file_path is None and (content is None or extension is None) or
file_path and content and extension):
error_msg = ('Must provide `file_path` or `content` and `extension`')
... | [
"\n Extract all words from a source code file to be used in code completion.\n\n Extract the list of words that contains the file in the editor,\n to carry out the inline completion similar to VSCode.\n "
] |
Please provide a description of the function:def get_parent_until(path):
dirname = osp.dirname(path)
try:
mod = osp.basename(path)
mod = osp.splitext(mod)[0]
imp.find_module(mod, [dirname])
except ImportError:
return
items = [mod]
while 1:
items.append(os... | [
"\n Given a file path, determine the full module path.\n\n e.g. '/usr/lib/python2.7/dist-packages/numpy/core/__init__.pyc' yields\n 'numpy.core'\n "
] |
Please provide a description of the function:def _get_docstring(self):
left = self.position
while left:
if self.source_code[left: left + 3] in ['', "'''"]:
right -= 3
break
right += 1
if left and right < len(self.source_code):
... | [
"Find the docstring we are currently in.",
"', \"'''\"]:\n left += 3\n break\n left -= 1\n right = self.position\n while right < len(self.source_code):\n if self.source_code[right - 3: right] in ['"
] |
Please provide a description of the function:def load_connection_settings(self):
existing_kernel = CONF.get("existing-kernel", "settings", {})
connection_file_path = existing_kernel.get("json_file_path", "")
is_remote = existing_kernel.get("is_remote", False)
username = existin... | [
"Load the user's previously-saved kernel connection settings."
] |
Please provide a description of the function:def save_connection_settings(self):
if not self.save_layout.isChecked():
return
is_ssh_key = bool(self.kf_radio.isChecked())
connection_settings = {
"json_file_path": self.cf.text(),
"is_remote": self.rm_... | [
"Save user's kernel connection settings."
] |
Please provide a description of the function:def get_color(value, alpha):
color = QColor()
for typ in COLORS:
if isinstance(value, typ):
color = QColor(COLORS[typ])
color.setAlphaF(alpha)
return color | [
"Return color depending on value type"
] |
Please provide a description of the function:def get_col_sep(self):
if self.tab_btn.isChecked():
return u"\t"
elif self.ws_btn.isChecked():
return None
return to_text_string(self.line_edt.text()) | [
"Return the column separator"
] |
Please provide a description of the function:def get_row_sep(self):
if self.eol_btn.isChecked():
return u"\n"
return to_text_string(self.line_edt_row.text()) | [
"Return the row separator"
] |
Please provide a description of the function:def set_as_data(self, as_data):
self._as_data = as_data
self.asDataChanged.emit(as_data) | [
"Set if data type conversion"
] |
Please provide a description of the function:def _display_data(self, index):
return to_qvariant(self._data[index.row()][index.column()]) | [
"Return a data element"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.