_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q239600
table.getkeyword
train
def getkeyword(self, keyword): """Get the value of a table keyword. The value of a keyword can be a: - scalar which is returned as a normal python scalar. - an array which is returned as a numpy array. - a reference to a table which is returned as a string containing its ...
python
{ "resource": "" }
q239601
table.getcolkeyword
train
def getcolkeyword(self, columnname, keyword): """Get the value of a column keyword. It is similar to :func:`getkeyword`. """ if isinstance(keyword, str): return self._getkeyword(columnname, keyword, -1) else: return self._getkeyword(columnname, '', keywo...
python
{ "resource": "" }
q239602
table.getsubtables
train
def getsubtables(self): """Get the names of all subtables.""" keyset = self.getkeywords() names = [] for key, value in keyset.items(): if isinstance(value, str) and value.find('Table: ') == 0: names.append(_do_remove_prefix(value)) return names
python
{ "resource": "" }
q239603
table.putkeyword
train
def putkeyword(self, keyword, value, makesubrecord=False): """Put the value of a table keyword. The value of a keyword can be a: - scalar which can be given a normal python scalar or numpy scalar. - an array which can be given as a numpy array. A 1-dimensional array can also ...
python
{ "resource": "" }
q239604
table.removekeyword
train
def removekeyword(self, keyword): """Remove a table keyword. Similar to :func:`getkeyword` the name can consist of multiple parts. In that case a field in a struct will be removed. Instead of a keyword name an index can be given which removes the i-th keyword. """ ...
python
{ "resource": "" }
q239605
table.removecolkeyword
train
def removecolkeyword(self, columnname, keyword): """Remove a column keyword. It is similar to :func:`removekeyword`. """ if isinstance(keyword, str): self._removekeyword(columnname, keyword, -1) else: self._removekeyword(columnname, '', keyword)
python
{ "resource": "" }
q239606
table.getdesc
train
def getdesc(self, actual=True): """Get the table description. By default it returns the actual description (thus telling the actual array shapes and data managers used). `actual=False` means that the original description as made by :func:`maketabdesc` is returned. """ ...
python
{ "resource": "" }
q239607
table.getcoldesc
train
def getcoldesc(self, columnname, actual=True): """Get the description of a column. By default it returns the actual description (thus telling the actual array shapes and data managers used). `actual=False` means that the original description as made by :func:`makescacoldesc` or ...
python
{ "resource": "" }
q239608
table.coldesc
train
def coldesc(self, columnname, actual=True): """Make the description of a column. Make the description object of the given column as :func:`makecoldesc` is doing with the description given by :func:`getcoldesc`. """ import casacore.tables.tableutil as pt return p...
python
{ "resource": "" }
q239609
table.getdminfo
train
def getdminfo(self, columnname=None): """Get data manager info. Each column in a table is stored using a data manager. A storage manager is a data manager storing the physically in a file. A virtual column engine is a data manager that does not store data but calculates it on th...
python
{ "resource": "" }
q239610
table.setdmprop
train
def setdmprop(self, name, properties, bycolumn=True): """Set properties of a data manager. Properties (e.g. cachesize) of a data manager can be changed by defining them appropriately in the properties argument (a dict). Current values can be obtained using function :func:`getdmprop` whi...
python
{ "resource": "" }
q239611
table.showstructure
train
def showstructure(self, dataman=True, column=True, subtable=False, sort=False): """Show table structure in a formatted string. The structure of this table and optionally its subtables is shown. It shows the data manager info and column descriptions. Optionally the ...
python
{ "resource": "" }
q239612
table.summary
train
def summary(self, recurse=False): """Print a summary of the table. It prints the number of columns and rows, column names, and table and column keywords. If `recurse=True` it also prints the summary of all subtables, i.e. tables referenced by table keywords. """ ...
python
{ "resource": "" }
q239613
table.selectrows
train
def selectrows(self, rownrs): """Return a reference table containing the given rows.""" t = self._selectrows(rownrs, name='') # selectrows returns a Table object, so turn that into table. return table(t, _oper=3)
python
{ "resource": "" }
q239614
table.query
train
def query(self, query='', name='', sortlist='', columns='', limit=0, offset=0, style='Python'): """Query the table and return the result as a reference table. This method queries the table. It forms a `TaQL <../../doc/199.html>`_ command from the given arguments and execut...
python
{ "resource": "" }
q239615
table.sort
train
def sort(self, sortlist, name='', limit=0, offset=0, style='Python'): """Sort the table and return the result as a reference table. This method sorts the table. It forms a `TaQL <../../doc/199.html>`_ command from the given arguments and executes it using the :func:...
python
{ "resource": "" }
q239616
table.select
train
def select(self, columns, name='', style='Python'): """Select columns and return the result as a reference table. This method represents the SELECT part of a TaQL command using the given columns (or column expressions). It forms a `TaQL <../../doc/199.html>`_ command from the gi...
python
{ "resource": "" }
q239617
table.browse
train
def browse(self, wait=True, tempname="/tmp/seltable"): """ Browse a table using casabrowser or a simple wxwidget based browser. By default the casabrowser is used if it can be found (in your PATH). Otherwise the wxwidget one is used if wx can be loaded. The casabrowser can only...
python
{ "resource": "" }
q239618
table.view
train
def view(self, wait=True, tempname="/tmp/seltable"): """ View a table using casaviewer, casabrowser, or wxwidget based browser. The table is viewed depending on the type: MeasurementSet is viewed using casaviewer. Image is viewed using casaviewer. ot...
python
{ "resource": "" }
q239619
table._repr_html_
train
def _repr_html_(self): """Give a nice representation of tables in notebooks.""" out = "<table class='taqltable' style='overflow-x:auto'>\n" # Print column names (not if they are all auto-generated) if not(all([colname[:4] == "Col_" for colname in self.colnames()])): out += "...
python
{ "resource": "" }
q239620
nth
train
def nth(lst, n): """Return the nth item in the list.""" expect_type(n, (String, Number), unit=None) if isinstance(n, String): if n.value.lower() == 'first': i = 0 elif n.value.lower() == 'last': i = -1 else: raise ValueError("Invalid index %r" % (...
python
{ "resource": "" }
q239621
CoreExtension.handle_import
train
def handle_import(self, name, compilation, rule): """Implementation of the core Sass import mechanism, which just looks for files on disk. """ # TODO this is all not terribly well-specified by Sass. at worst, # it's unclear how far "upwards" we should be allowed to go. but i'm ...
python
{ "resource": "" }
q239622
print_error
train
def print_error(input, err, scanner): """This is a really dumb long function to print error messages nicely.""" p = err.pos # Figure out the line number line = input[:p].count('\n') print err.msg + " on line " + repr(line + 1) + ":" # Now try printing part of the line text = input[max(p - 80...
python
{ "resource": "" }
q239623
Generator.equal_set
train
def equal_set(self, a, b): "See if a and b have the same elements" if len(a) != len(b): return 0 if a == b: return 1 return self.subset(a, b) and self.subset(b, a)
python
{ "resource": "" }
q239624
Generator.add_to
train
def add_to(self, parent, additions): "Modify parent to include all elements in additions" for x in additions: if x not in parent: parent.append(x) self.changed()
python
{ "resource": "" }
q239625
Namespace.declare_alias
train
def declare_alias(self, name): """Insert a Python function into this Namespace with an explicitly-given name, but detect its argument count automatically. """ def decorator(f): self._auto_register_function(f, name) return f return decorator
python
{ "resource": "" }
q239626
tmemoize.collect
train
def collect(self): """Clear cache of results which have timed out""" for func in self._caches: cache = {} for key in self._caches[func]: if (time.time() - self._caches[func][key][1]) < self._timeouts[func]: cache[key] = self._caches[func][key] ...
python
{ "resource": "" }
q239627
extend_unique
train
def extend_unique(seq, more): """Return a new sequence containing the items in `seq` plus any items in `more` that aren't already in `seq`, preserving the order of both. """ seen = set(seq) new = [] for item in more: if item not in seen: seen.add(item) new.append(...
python
{ "resource": "" }
q239628
RuleAncestry.with_more_selectors
train
def with_more_selectors(self, selectors): """Return a new ancestry that also matches the given selectors. No nesting is done. """ if self.headers and self.headers[-1].is_selector: new_selectors = extend_unique( self.headers[-1].selectors, sele...
python
{ "resource": "" }
q239629
Calculator.parse_interpolations
train
def parse_interpolations(self, string): """Parse a string for interpolations, but don't treat anything else as Sass syntax. Returns an AST node. """ # Shortcut: if there are no #s in the string in the first place, it # must not have any interpolations, right? if '#' not ...
python
{ "resource": "" }
q239630
Calculator.parse_vars_and_interpolations
train
def parse_vars_and_interpolations(self, string): """Parse a string for variables and interpolations, but don't treat anything else as Sass syntax. Returns an AST node. """ # Shortcut: if there are no #s or $s in the string in the first place, # it must not have anything of inter...
python
{ "resource": "" }
q239631
reject
train
def reject(lst, *values): """Removes the given values from the list""" lst = List.from_maybe(lst) values = frozenset(List.from_maybe_starargs(values)) ret = [] for item in lst: if item not in values: ret.append(item) return List(ret, use_comma=lst.use_comma)
python
{ "resource": "" }
q239632
add_error_marker
train
def add_error_marker(text, position, start_line=1): """Add a caret marking a given position in a string of input. Returns (new_text, caret_line). """ indent = " " lines = [] caret_line = start_line for line in text.split("\n"): lines.append(indent + line) if 0 <= positio...
python
{ "resource": "" }
q239633
SassBaseError.format_sass_stack
train
def format_sass_stack(self): """Return a "traceback" of Sass imports.""" if not self.rule_stack: return "" ret = ["on ", self.format_file_and_line(self.rule_stack[0]), "\n"] last_file = self.rule_stack[0].source_file # TODO this could go away if rules knew their imp...
python
{ "resource": "" }
q239634
SassError.format_python_stack
train
def format_python_stack(self): """Return a traceback of Python frames, from where the error occurred to where it was first caught and wrapped. """ ret = ["Traceback:\n"] ret.extend(traceback.format_tb(self.original_traceback)) return "".join(ret)
python
{ "resource": "" }
q239635
SassError.to_css
train
def to_css(self): """Return a stylesheet that will show the wrapped error at the top of the browser window. """ # TODO should this include the traceback? any security concerns? prefix = self.format_prefix() original_error = self.format_original_error() sass_stack...
python
{ "resource": "" }
q239636
compile_string
train
def compile_string(string, compiler_class=Compiler, **kwargs): """Compile a single string, and return a string of CSS. Keyword arguments are passed along to the underlying `Compiler`. """ compiler = compiler_class(**kwargs) return compiler.compile_string(string)
python
{ "resource": "" }
q239637
Compilation.parse_selectors
train
def parse_selectors(self, raw_selectors): """ Parses out the old xCSS "foo extends bar" syntax. Returns a 2-tuple: a set of selectors, and a set of extended selectors. """ # Fix tabs and spaces in selectors raw_selectors = _spaces_re.sub(' ', raw_selectors) part...
python
{ "resource": "" }
q239638
Compilation._get_properties
train
def _get_properties(self, rule, scope, block): """ Implements properties and variables extraction and assignment """ prop, raw_value = (_prop_split_re.split(block.prop, 1) + [None])[:2] if raw_value is not None: raw_value = raw_value.strip() try: ...
python
{ "resource": "" }
q239639
_constrain
train
def _constrain(value, lb=0, ub=1): """Helper for Color constructors. Constrains a value to a range.""" if value < lb: return lb elif value > ub: return ub else: return value
python
{ "resource": "" }
q239640
Number._add_sub
train
def _add_sub(self, other, op): """Implements both addition and subtraction.""" if not isinstance(other, Number): return NotImplemented # If either side is unitless, inherit the other side's units. Skip all # the rest of the conversion math, too. if self.is_unitless ...
python
{ "resource": "" }
q239641
Number.to_base_units
train
def to_base_units(self): """Convert to a fixed set of "base" units. The particular units are arbitrary; what's important is that they're consistent. Used for addition and comparisons. """ # Convert to "standard" units, as defined by the conversions dict above amount = s...
python
{ "resource": "" }
q239642
Number.wrap_python_function
train
def wrap_python_function(cls, fn): """Wraps an unary Python math function, translating the argument from Sass to Python on the way in, and vice versa for the return value. Used to wrap simple Python functions like `ceil`, `floor`, etc. """ def wrapped(sass_arg): # TO...
python
{ "resource": "" }
q239643
Number.to_python_index
train
def to_python_index(self, length, check_bounds=True, circular=False): """Return a plain Python integer appropriate for indexing a sequence of the given length. Raise if this is impossible for any reason whatsoever. """ if not self.is_unitless: raise ValueError("Index...
python
{ "resource": "" }
q239644
List.maybe_new
train
def maybe_new(cls, values, use_comma=True): """If `values` contains only one item, return that item. Otherwise, return a List as normal. """ if len(values) == 1: return values[0] else: return cls(values, use_comma=use_comma)
python
{ "resource": "" }
q239645
List.from_maybe_starargs
train
def from_maybe_starargs(cls, args, use_comma=True): """If `args` has one element which appears to be a list, return it. Otherwise, return a list as normal. Mainly used by Sass function implementations that predate `...` support, so they can accept both a list of arguments and a single l...
python
{ "resource": "" }
q239646
Color.from_name
train
def from_name(cls, name): """Build a Color from a CSS color name.""" self = cls.__new__(cls) # TODO self.original_literal = name r, g, b, a = COLOR_NAMES[name] self.value = r, g, b, a return self
python
{ "resource": "" }
q239647
String.unquoted
train
def unquoted(cls, value, literal=False): """Helper to create a string with no quotes.""" return cls(value, quotes=None, literal=literal)
python
{ "resource": "" }
q239648
_is_combinator_subset_of
train
def _is_combinator_subset_of(specific, general, is_first=True): """Return whether `specific` matches a non-strict subset of what `general` matches. """ if is_first and general == ' ': # First selector always has a space to mean "descendent of root", which # still holds if any other selec...
python
{ "resource": "" }
q239649
_weave_conflicting_selectors
train
def _weave_conflicting_selectors(prefixes, a, b, suffix=()): """Part of the selector merge algorithm above. Not useful on its own. Pay no attention to the man behind the curtain. """ # OK, what this actually does: given a list of selector chains, two # "conflicting" selector chains, and an optiona...
python
{ "resource": "" }
q239650
_merge_simple_selectors
train
def _merge_simple_selectors(a, b): """Merge two simple selectors, for the purposes of the LCS algorithm below. In practice this returns the more specific selector if one is a subset of the other, else it returns None. """ # TODO what about combinators if a.is_superset_of(b): return b ...
python
{ "resource": "" }
q239651
longest_common_subsequence
train
def longest_common_subsequence(a, b, mergefunc=None): """Find the longest common subsequence between two iterables. The longest common subsequence is the core of any diff algorithm: it's the longest sequence of elements that appears in both parent sequences in the same order, but NOT necessarily consec...
python
{ "resource": "" }
q239652
SimpleSelector.is_superset_of
train
def is_superset_of(self, other, soft_combinator=False): """Return True iff this selector matches the same elements as `other`, and perhaps others. That is, ``.foo`` is a superset of ``.foo.bar``, because the latter is more specific. Set `soft_combinator` true to ignore the spec...
python
{ "resource": "" }
q239653
Selector.substitute
train
def substitute(self, target, replacement): """Return a list of selectors obtained by replacing the `target` selector with `replacement`. Herein lie the guts of the Sass @extend directive. In general, for a selector ``a X b Y c``, a target ``X Y``, and a replacement ``q Z``, ret...
python
{ "resource": "" }
q239654
convert_units_to_base_units
train
def convert_units_to_base_units(units): """Convert a set of units into a set of "base" units. Returns a 2-tuple of `factor, new_units`. """ total_factor = 1 new_units = [] for unit in units: if unit not in BASE_UNIT_CONVERSIONS: continue factor, new_unit = BASE_UNIT...
python
{ "resource": "" }
q239655
count_base_units
train
def count_base_units(units): """Returns a dict mapping names of base units to how many times they appear in the given iterable of units. Effectively this counts how many length units you have, how many time units, and so forth. """ ret = {} for unit in units: factor, base_unit = get_con...
python
{ "resource": "" }
q239656
cancel_base_units
train
def cancel_base_units(units, to_remove): """Given a list of units, remove a specified number of each base unit. Arguments: units: an iterable of units to_remove: a mapping of base_unit => count, such as that returned from count_base_units Returns a 2-tuple of (factor, remaining...
python
{ "resource": "" }
q239657
is_builtin_css_function
train
def is_builtin_css_function(name): """Returns whether the given `name` looks like the name of a builtin CSS function. Unrecognized functions not in this list produce warnings. """ name = name.replace('_', '-') if name in BUILTIN_FUNCTIONS: return True # Vendor-specific functions (...
python
{ "resource": "" }
q239658
determine_encoding
train
def determine_encoding(buf): """Return the appropriate encoding for the given CSS source, according to the CSS charset rules. `buf` may be either a string or bytes. """ # The ultimate default is utf8; bravo, W3C bom_encoding = 'UTF-8' if not buf: # What return bom_encoding ...
python
{ "resource": "" }
q239659
Interpolation.maybe
train
def maybe(cls, parts, quotes=None, type=String, **kwargs): """Returns an interpolation if there are multiple parts, otherwise a plain Literal. This keeps the AST somewhat simpler, but also is the only way `Literal.from_bareword` gets called. """ if len(parts) > 1: re...
python
{ "resource": "" }
q239660
image_height
train
def image_height(image): """ Returns the height of the image found at the path supplied by `image` relative to your project's images directory. """ image_size_cache = _get_cache('image_size_cache') if not Image: raise SassMissingDependency('PIL', 'image manipulation') filepath = Stri...
python
{ "resource": "" }
q239661
SourceFile.path
train
def path(self): """Concatenation of ``origin`` and ``relpath``, as a string. Used in stack traces and other debugging places. """ if self.origin: return six.text_type(self.origin / self.relpath) else: return six.text_type(self.relpath)
python
{ "resource": "" }
q239662
SourceFile.from_filename
train
def from_filename(cls, path_string, origin=MISSING, **kwargs): """ Read Sass source from a String specifying the path """ path = Path(path_string) return cls.from_path(path, origin, **kwargs)
python
{ "resource": "" }
q239663
SourceFile.from_file
train
def from_file(cls, f, origin=MISSING, relpath=MISSING, **kwargs): """Read Sass source from a file or file-like object. If `origin` or `relpath` are missing, they are derived from the file's ``.name`` attribute as with `from_path`. If it doesn't have one, the origin becomes None and the...
python
{ "resource": "" }
q239664
SourceFile.from_string
train
def from_string(cls, string, relpath=None, encoding=None, is_sass=None): """Read Sass source from the contents of a string. The origin is always None. `relpath` defaults to "string:...". """ if isinstance(string, six.text_type): # Already decoded; we don't know what encodin...
python
{ "resource": "" }
q239665
FastQuadTree.hit
train
def hit(self, rect): """Returns the items that overlap a bounding rectangle. Returns the set of all items in the quad-tree that overlap with a bounding rectangle. @param rect: The bounding rectangle being tested against the quad-tree. This must possess left, top...
python
{ "resource": "" }
q239666
BufferedRenderer.scroll
train
def scroll(self, vector): """ scroll the background in pixels :param vector: (int, int) """ self.center((vector[0] + self.view_rect.centerx, vector[1] + self.view_rect.centery))
python
{ "resource": "" }
q239667
BufferedRenderer.center
train
def center(self, coords): """ center the map on a pixel float numbers will be rounded. :param coords: (number, number) """ x, y = round(coords[0]), round(coords[1]) self.view_rect.center = x, y mw, mh = self.data.map_size tw, th = self.data.tile_size ...
python
{ "resource": "" }
q239668
BufferedRenderer.draw
train
def draw(self, surface, rect, surfaces=None): """ Draw the map onto a surface pass a rect that defines the draw area for: drawing to an area smaller that the whole window/screen surfaces may optionally be passed that will be blitted onto the surface. this must be a sequence...
python
{ "resource": "" }
q239669
BufferedRenderer.set_size
train
def set_size(self, size): """ Set the size of the map in pixels This is an expensive operation, do only when absolutely needed. :param size: (width, height) pixel size of camera/view of the group """ buffer_size = self._calculate_zoom_buffer_size(size, self._zoom_level) ...
python
{ "resource": "" }
q239670
BufferedRenderer.translate_point
train
def translate_point(self, point): """ Translate world coordinates and return screen coordinates. Respects zoom level Will be returned as tuple. :rtype: tuple """ mx, my = self.get_center_offset() if self._zoom_level == 1.0: return point[0] + mx, point[1] + ...
python
{ "resource": "" }
q239671
BufferedRenderer.translate_points
train
def translate_points(self, points): """ Translate coordinates and return screen coordinates Will be returned in order passed as tuples. :return: list """ retval = list() append = retval.append sx, sy = self.get_center_offset() if self._zoom_level == 1.0:...
python
{ "resource": "" }
q239672
BufferedRenderer._render_map
train
def _render_map(self, surface, rect, surfaces): """ Render the map and optional surfaces to destination surface :param surface: pygame surface to draw to :param rect: area to draw to :param surfaces: optional sequence of surfaces to interlace between tiles """ self._tile...
python
{ "resource": "" }
q239673
BufferedRenderer._clear_surface
train
def _clear_surface(self, surface, rect=None): """ Clear the buffer, taking in account colorkey or alpha :return: """ clear_color = self._rgb_clear_color if self._clear_color is None else self._clear_color surface.fill(clear_color, rect)
python
{ "resource": "" }
q239674
BufferedRenderer._draw_surfaces
train
def _draw_surfaces(self, surface, offset, surfaces): """ Draw surfaces onto buffer, then redraw tiles that cover them :param surface: destination :param offset: offset to compensate for buffer alignment :param surfaces: sequence of surfaces to blit """ surface_blit = sur...
python
{ "resource": "" }
q239675
BufferedRenderer._queue_edge_tiles
train
def _queue_edge_tiles(self, dx, dy): """ Queue edge tiles and clear edge areas on buffer if needed :param dx: Edge along X axis to enqueue :param dy: Edge along Y axis to enqueue :return: None """ v = self._tile_view tw, th = self.data.tile_size self._til...
python
{ "resource": "" }
q239676
BufferedRenderer._create_buffers
train
def _create_buffers(self, view_size, buffer_size): """ Create the buffers, taking in account pixel alpha or colorkey :param view_size: pixel size of the view :param buffer_size: pixel size of the buffer """ requires_zoom_buffer = not view_size == buffer_size self._zoom_b...
python
{ "resource": "" }
q239677
PyscrollDataAdapter.reload_animations
train
def reload_animations(self): """ Reload animation information PyscrollDataAdapter.get_animations must be implemented """ self._update_time() self._animation_queue = list() self._tracked_gids = set() self._animation_map = dict() for gid, frame_data in se...
python
{ "resource": "" }
q239678
PyscrollDataAdapter.get_tile_image
train
def get_tile_image(self, x, y, l): """ Get a tile image, respecting current animations :param x: x coordinate :param y: y coordinate :param l: layer :type x: int :type y: int :type l: int :rtype: pygame.Surface """ # disabled for now, re...
python
{ "resource": "" }
q239679
PyscrollDataAdapter.get_tile_images_by_rect
train
def get_tile_images_by_rect(self, rect): """ Given a 2d area, return generator of tile images inside Given the coordinates, yield the following tuple for each tile: X, Y, Layer Number, pygame Surface This method also defines render order by re arranging the positions of each ...
python
{ "resource": "" }
q239680
TiledMapData.convert_surfaces
train
def convert_surfaces(self, parent, alpha=False): """ Convert all images in the data to match the parent :param parent: pygame.Surface :param alpha: preserve alpha channel or not :return: None """ images = list() for i in self.tmx.images: try: ...
python
{ "resource": "" }
q239681
TiledMapData.visible_object_layers
train
def visible_object_layers(self): """ This must return layer objects This is not required for custom data formats. :return: Sequence of pytmx object layers/groups """ return (layer for layer in self.tmx.visible_layers if isinstance(layer, pytmx.TiledObjectGroup))
python
{ "resource": "" }
q239682
TiledMapData.get_tile_images_by_rect
train
def get_tile_images_by_rect(self, rect): """ Speed up data access More efficient because data is accessed and cached locally """ def rev(seq, start, stop): if start < 0: start = 0 return enumerate(seq[start:stop + 1], start) x1, y1, x2, ...
python
{ "resource": "" }
q239683
Hero.move_back
train
def move_back(self, dt): """ If called after an update, the sprite can move back """ self._position = self._old_position self.rect.topleft = self._position self.feet.midbottom = self.rect.midbottom
python
{ "resource": "" }
q239684
QuestGame.handle_input
train
def handle_input(self): """ Handle pygame input events """ poll = pygame.event.poll event = poll() while event: if event.type == QUIT: self.running = False break elif event.type == KEYDOWN: if event.key == ...
python
{ "resource": "" }
q239685
QuestGame.update
train
def update(self, dt): """ Tasks that occur over time should be handled here """ self.group.update(dt) # check if the sprite's feet are colliding with wall # sprite must have a rect called feet, and move_back method, # otherwise this will fail for sprite in self.g...
python
{ "resource": "" }
q239686
QuestGame.run
train
def run(self): """ Run the game loop """ clock = pygame.time.Clock() self.running = True from collections import deque times = deque(maxlen=30) try: while self.running: dt = clock.tick() / 1000. times.append(clock.get_...
python
{ "resource": "" }
q239687
PyscrollGroup.draw
train
def draw(self, surface): """ Draw all sprites and map onto the surface :param surface: pygame surface to draw to :type surface: pygame.surface.Surface """ ox, oy = self._map_layer.get_center_offset() new_surfaces = list() spritedict = self.spritedict gl ...
python
{ "resource": "" }
q239688
IsometricBufferedRenderer.center
train
def center(self, coords): """ center the map on a "map pixel" """ x, y = [round(i, 0) for i in coords] self.view_rect.center = x, y tw, th = self.data.tile_size left, ox = divmod(x, tw) top, oy = divmod(y, th) vec = int(ox / 2), int(oy) iso = v...
python
{ "resource": "" }
q239689
env_options.get_odoo_args
train
def get_odoo_args(self, ctx): """Return a list of Odoo command line arguments from the Click context.""" config = ctx.params.get("config") addons_path = ctx.params.get("addons_path") database = ctx.params.get("database") log_level = ctx.params.get("log_level") logfile = c...
python
{ "resource": "" }
q239690
make_query
train
def make_query(search_term, querytype='AdvancedKeywordQuery'): ''' Repackage strings into a search dictionary This function takes a list of search terms and specifications and repackages it as a dictionary object that can be used to conduct a search Parameters ---------- search_term : str ...
python
{ "resource": "" }
q239691
do_protsym_search
train
def do_protsym_search(point_group, min_rmsd=0.0, max_rmsd=7.0): '''Performs a protein symmetry search of the PDB This function can search the Protein Data Bank based on how closely entries match the user-specified symmetry group Parameters ---------- point_group : str The name of the ...
python
{ "resource": "" }
q239692
get_all
train
def get_all(): """Return a list of all PDB entries currently in the RCSB Protein Data Bank Returns ------- out : list of str A list of all of the PDB IDs currently in the RCSB PDB Examples -------- >>> print(get_all()[:10]) ['100D', '101D', '101M', '102D', '102L', '102M', '10...
python
{ "resource": "" }
q239693
get_info
train
def get_info(pdb_id, url_root='http://www.rcsb.org/pdb/rest/describeMol?structureId='): '''Look up all information about a given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest url_root : string The string root of the specific url f...
python
{ "resource": "" }
q239694
get_pdb_file
train
def get_pdb_file(pdb_id, filetype='pdb', compression=False): '''Get the full PDB file associated with a PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest filetype: string The file type. 'pdb' is the older file format, ...
python
{ "resource": "" }
q239695
get_all_info
train
def get_all_info(pdb_id): '''A wrapper for get_info that cleans up the output slighly Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing all the information stored in the entry ...
python
{ "resource": "" }
q239696
get_raw_blast
train
def get_raw_blast(pdb_id, output_form='HTML', chain_id='A'): '''Look up full BLAST page for a given PDB ID get_blast() uses this function internally Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string A single character ...
python
{ "resource": "" }
q239697
parse_blast
train
def parse_blast(blast_string): '''Clean up HTML BLAST results This function requires BeautifulSoup and the re module It goes throught the complicated output returned by the BLAST search and provides a list of matches, as well as the raw text file showing the alignments for each of the matches. ...
python
{ "resource": "" }
q239698
get_blast2
train
def get_blast2(pdb_id, chain_id='A', output_form='HTML'): '''Alternative way to look up BLAST for a given PDB ID. This function is a wrapper for get_raw_blast and parse_blast Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string ...
python
{ "resource": "" }
q239699
describe_pdb
train
def describe_pdb(pdb_id): """Get description and metadata of a PDB entry Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : string A text pdb description from PDB Examples -------- >>> describe_pdb(...
python
{ "resource": "" }