_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q11400
imprints2marc
train
def imprints2marc(self, key, value): """Populate the ``260`` MARC field.""" return { 'a': value.get('place'), 'b': value.get('publisher'), 'c': value.get('date'), }
python
{ "resource": "" }
q11401
thesis_info
train
def thesis_info(self, key, value): """Populate the ``thesis_info`` key.""" def _get_degree_type(value): DEGREE_TYPES_MAP = { 'RAPPORT DE STAGE': 'other', 'INTERNSHIP REPORT': 'other', 'DIPLOMA': 'diploma', 'BACHELOR': 'bachelor', 'LAUREA': 'lau...
python
{ "resource": "" }
q11402
thesis_info2marc
train
def thesis_info2marc(self, key, value): """Populate the ``502`` MARC field. Also populates the ``500`` MARC field through side effects. """ def _get_b_value(value): DEGREE_TYPES_MAP = { 'bachelor': 'Bachelor', 'diploma': 'Diploma', 'habilitation': 'Habilitati...
python
{ "resource": "" }
q11403
abstracts
train
def abstracts(self, key, value): """Populate the ``abstracts`` key.""" result = [] source = force_single_element(value.get('9')) for a_value in force_list(value.get('a')): result.append({ 'source': source, 'value': a_value, }) return result
python
{ "resource": "" }
q11404
funding_info
train
def funding_info(self, key, value): """Populate the ``funding_info`` key.""" return { 'agency': value.get('a'), 'grant_number': value.get('c'), 'project_number': value.get('f'), }
python
{ "resource": "" }
q11405
funding_info2marc
train
def funding_info2marc(self, key, value): """Populate the ``536`` MARC field.""" return { 'a': value.get('agency'), 'c': value.get('grant_number'), 'f': value.get('project_number'), }
python
{ "resource": "" }
q11406
license
train
def license(self, key, value): """Populate the ``license`` key.""" def _get_license(value): a_values = force_list(value.get('a')) oa_licenses = [el for el in a_values if el == 'OA' or el == 'Open Access'] other_licenses = [el for el in a_values if el != 'OA' and el != 'Open Access'] ...
python
{ "resource": "" }
q11407
license2marc
train
def license2marc(self, key, value): """Populate the ``540`` MARC field.""" return { 'a': value.get('license'), 'b': value.get('imposing'), 'u': value.get('url'), '3': value.get('material'), }
python
{ "resource": "" }
q11408
copyright
train
def copyright(self, key, value): """Populate the ``copyright`` key.""" MATERIAL_MAP = { 'Article': 'publication', 'Published thesis as a book': 'publication', } material = value.get('e') or value.get('3') return { 'holder': value.get('d'), 'material': MATERIAL_MAP.g...
python
{ "resource": "" }
q11409
copyright2marc
train
def copyright2marc(self, key, value): """Populate the ``542`` MARC field.""" E_MAP = { 'publication': 'Article', } e_value = value.get('material') return { 'd': value.get('holder'), 'e': E_MAP.get(e_value), 'f': value.get('statement'), 'g': value.get('year')...
python
{ "resource": "" }
q11410
_private_notes2marc
train
def _private_notes2marc(self, key, value): """Populate the ``595`` MARC key. Also populates the `595_H` MARC key through side effects. """ def _is_from_hal(value): return value.get('source') == 'HAL' if not _is_from_hal(value): return { '9': value.get('source'), ...
python
{ "resource": "" }
q11411
_export_to2marc
train
def _export_to2marc(self, key, value): """Populate the ``595`` MARC field.""" def _is_for_cds(value): return 'CDS' in value def _is_for_hal(value): return 'HAL' in value and value['HAL'] def _is_not_for_hal(value): return 'HAL' in value and not value['HAL'] result = [] ...
python
{ "resource": "" }
q11412
_desy_bookkeeping
train
def _desy_bookkeeping(self, key, value): """Populate the ``_desy_bookkeeping`` key.""" return { 'date': normalize_date(value.get('d')), 'expert': force_single_element(value.get('a')), 'status': value.get('s'), }
python
{ "resource": "" }
q11413
_desy_bookkeeping2marc
train
def _desy_bookkeeping2marc(self, key, value): """Populate the ``595_D`` MARC field. Also populates the ``035`` MARC field through side effects. """ if 'identifier' not in value: return { 'a': value.get('expert'), 'd': value.get('date'), 's': value.get('status...
python
{ "resource": "" }
q11414
_dates
train
def _dates(self, key, value): """Don't populate any key through the return value. On the other hand, populates the ``date_proposed``, ``date_approved``, ``date_started``, ``date_cancelled``, and the ``date_completed`` keys through side effects. """ if value.get('q'): self['date_proposed...
python
{ "resource": "" }
q11415
experiment
train
def experiment(self, key, values): """Populate the ``experiment`` key. Also populates the ``legacy_name``, the ``accelerator``, and the ``institutions`` keys through side effects. """ experiment = self.get('experiment', {}) legacy_name = self.get('legacy_name', '') accelerator = self.get('a...
python
{ "resource": "" }
q11416
core
train
def core(self, key, value): """Populate the ``core`` key. Also populates the ``deleted`` and ``project_type`` keys through side effects. """ core = self.get('core') deleted = self.get('deleted') project_type = self.get('project_type', []) if not core: normalized_a_values = [el....
python
{ "resource": "" }
q11417
control_number
train
def control_number(endpoint): """Populate the ``control_number`` key. Also populates the ``self`` key through side effects. """ def _control_number(self, key, value): self['self'] = get_record_ref(int(value), endpoint) return int(value) return _control_number
python
{ "resource": "" }
q11418
acquisition_source
train
def acquisition_source(self, key, value): """Populate the ``acquisition_source`` key.""" def _get_datetime(value): d_value = force_single_element(value.get('d', '')) if d_value: try: date = PartialDate.loads(d_value) except ValueError: retu...
python
{ "resource": "" }
q11419
external_system_identifiers
train
def external_system_identifiers(endpoint): """Populate the ``external_system_identifiers`` key. Also populates the ``new_record`` key through side effects. """ @utils.flatten @utils.for_each_value def _external_system_identifiers(self, key, value): new_recid = maybe_int(value.get('d')) ...
python
{ "resource": "" }
q11420
deleted_records
train
def deleted_records(endpoint): """Populate the ``deleted_records`` key.""" @utils.for_each_value def _deleted_records(self, key, value): deleted_recid = maybe_int(value.get('a')) if deleted_recid: return get_record_ref(deleted_recid, endpoint) return _deleted_records
python
{ "resource": "" }
q11421
accelerator_experiments
train
def accelerator_experiments(self, key, value): """Populate the ``accelerator_experiments`` key.""" result = [] a_value = force_single_element(value.get('a')) e_values = [el for el in force_list(value.get('e')) if el != '-'] zero_values = force_list(value.get('0')) if a_value and not e_values: ...
python
{ "resource": "" }
q11422
keywords
train
def keywords(self, key, values): """Populate the ``keywords`` key. Also populates the ``energy_ranges`` key through side effects. """ keywords = self.get('keywords', []) energy_ranges = self.get('energy_ranges', []) for value in force_list(values): if value.get('a'): schema...
python
{ "resource": "" }
q11423
keywords2marc
train
def keywords2marc(self, key, values): """Populate the ``695`` MARC field. Also populates the ``084`` and ``6531`` MARC fields through side effects. """ result_695 = self.get('695', []) result_084 = self.get('084', []) result_6531 = self.get('6531', []) for value in values: schema =...
python
{ "resource": "" }
q11424
collaborations
train
def collaborations(self, key, value): """Populate the ``collaborations`` key.""" result = [] for g_value in force_list(value.get('g')): collaborations = normalize_collaboration(g_value) if len(collaborations) == 1: result.append({ 'record': get_record_ref(maybe_i...
python
{ "resource": "" }
q11425
publication_info
train
def publication_info(self, key, value): """Populate the ``publication_info`` key.""" def _get_cnum(value): w_value = force_single_element(value.get('w', '')) normalized_w_value = w_value.replace('/', '-').upper() return normalized_w_value def _get_material(value): schema = ...
python
{ "resource": "" }
q11426
publication_info2marc
train
def publication_info2marc(self, key, values): """Populate the ``773`` MARC field. Also populates the ``7731`` MARC field through side effects. """ result_773 = self.get('773', []) result_7731 = self.get('7731', []) for value in force_list(convert_new_publication_info_to_old(values)): p...
python
{ "resource": "" }
q11427
related_records2marc
train
def related_records2marc(self, key, value): """Populate the ``78708`` MARC field Also populates the ``78002``, ``78502`` MARC fields through side effects. """ if value.get('relation_freetext'): return { 'i': value.get('relation_freetext'), 'w': get_recid_from_ref(value.g...
python
{ "resource": "" }
q11428
proceedings
train
def proceedings(self, key, value): """Populate the ``proceedings`` key. Also populates the ``refereed`` key through side effects. """ proceedings = self.get('proceedings') refereed = self.get('refereed') if not proceedings: normalized_a_values = [el.upper() for el in force_list(value.g...
python
{ "resource": "" }
q11429
short_title
train
def short_title(self, key, value): """Populate the ``short_title`` key. Also populates the ``title_variants`` key through side effects. """ short_title = value.get('a') title_variants = self.get('title_variants', []) if value.get('u'): short_title = value.get('u') title_variant...
python
{ "resource": "" }
q11430
ranks
train
def ranks(self, key, value): """Populate the ``ranks`` key.""" return [normalize_rank(el) for el in force_list(value.get('a'))]
python
{ "resource": "" }
q11431
BaseProgram.new_parser
train
def new_parser(self): """ Create a command line argument parser Add a few default flags, such as --version for displaying the program version when invoked """ parser = argparse.ArgumentParser(description=self.description) parser.add_argument( '--version', help='show...
python
{ "resource": "" }
q11432
Program.help_function
train
def help_function(self, command=None): """ Show help for all available commands or just a single one """ if command: return self.registered[command].get( 'description', 'No help available' ) return ', '.join(sorted(self.registered))
python
{ "resource": "" }
q11433
Program.add_command
train
def add_command(self, command, function, description=None): """ Register a new function for command """ super(Program, self).add_command(command, function, description) self.service.register(command, function)
python
{ "resource": "" }
q11434
Response._show
train
def _show(self, res, err, prefix='', colored=False): """ Show result or error """ if self.kind is 'local': what = res if not err else err print(what) return if self.kind is 'remote': if colored: red, green, reset = Fore.RED, Fore....
python
{ "resource": "" }
q11435
CtlProgram.call
train
def call(self, command, *args): """ Execute local OR remote command and show response """ if not command: return # Look for local methods first try: res = self.registered[command]['function'](self, *args) return Response('local', res, None) ...
python
{ "resource": "" }
q11436
CtlProgram.parse_input
train
def parse_input(self, text): """ Parse ctl user input. Double quotes are used to group together multi words arguments. """ parts = util.split(text) command = parts[0] if text and parts else None command = command.lower() if command else None args = parts[1:] if len(parts...
python
{ "resource": "" }
q11437
CtlProgram.loop
train
def loop(self): """ Enter loop, read user input then run command. Repeat """ while True: text = compat.input('ctl > ') command, args = self.parse_input(text) if not command: continue response = self.call(command, *args) respons...
python
{ "resource": "" }
q11438
split
train
def split(text): """ Split text into arguments accounting for muti-word arguments which are double quoted """ # Cleanup text text = text.strip() text = re.sub('\s+', ' ', text) # collpse multiple spaces space, quote, parts = ' ', '"', [] part, quoted = '', False for char in text: ...
python
{ "resource": "" }
q11439
read_version
train
def read_version(): """ Read package version """ with open('./oi/version.py') as fh: for line in fh: if line.startswith('VERSION'): return line.split('=')[1].strip().strip("'")
python
{ "resource": "" }
q11440
PrettyGraph.strip_prefixes
train
def strip_prefixes(g: Graph): """ Remove the prefixes from the graph for aesthetics """ return re.sub(r'^@prefix .* .\n', '', g.serialize(format="turtle").decode(), flags=re.MULTILINE).strip()
python
{ "resource": "" }
q11441
_PickleJar.clear
train
def clear(self) -> None: """ Clear all cache entries for directory and, if it is a 'pure' directory, remove the directory itself """ if self._cache_directory is not None: # Safety - if there isn't a cache directory file, this probably isn't a valid cache assert os...
python
{ "resource": "" }
q11442
fhirtordf
train
def fhirtordf(argv: List[str], default_exit: bool = True) -> bool: """ Entry point for command line utility """ dlp = dirlistproc.DirectoryListProcessor(argv, description="Convert FHIR JSON into RDF", infile_suffix=".json"...
python
{ "resource": "" }
q11443
get_distutils_option
train
def get_distutils_option(option, commands): """ Returns the value of the given distutils option. Parameters ---------- option : str The name of the option commands : list of str The list of commands on which this option is available Returns ------- val : str or None ...
python
{ "resource": "" }
q11444
add_command_option
train
def add_command_option(command, name, doc, is_bool=False): """ Add a custom option to a setup command. Issues a warning if the option already exists on that command. Parameters ---------- command : str The name of the command as given on the command line name : str The nam...
python
{ "resource": "" }
q11445
ensure_sphinx_astropy_installed
train
def ensure_sphinx_astropy_installed(): """ Make sure that sphinx-astropy is available, installing it temporarily if not. This returns the available version of sphinx-astropy as well as any paths that should be added to sys.path for sphinx-astropy to be available. """ # We've split out the Sphin...
python
{ "resource": "" }
q11446
get_numpy_include_path
train
def get_numpy_include_path(): """ Gets the path to the numpy headers. """ # We need to go through this nonsense in case setuptools # downloaded and installed Numpy for us as part of the build or # install, since Numpy may still think it's in "setup mode", when # in fact we're ready to use it...
python
{ "resource": "" }
q11447
is_path_hidden
train
def is_path_hidden(filepath): """ Determines if a given file or directory is hidden. Parameters ---------- filepath : str The path to a file or directory Returns ------- hidden : bool Returns `True` if the file is hidden """ name = os.path.basename(os.path.absp...
python
{ "resource": "" }
q11448
walk_skip_hidden
train
def walk_skip_hidden(top, onerror=None, followlinks=False): """ A wrapper for `os.walk` that skips hidden files and directories. This function does not have the parameter `topdown` from `os.walk`: the directories must always be recursed top-down when using this function. See also -------- ...
python
{ "resource": "" }
q11449
write_if_different
train
def write_if_different(filename, data): """Write `data` to `filename`, if the content of the file is different. Parameters ---------- filename : str The file name to be written to. data : bytes The data to be written to `filename`. """ assert isinstance(data, bytes) if...
python
{ "resource": "" }
q11450
import_file
train
def import_file(filename, name=None): """ Imports a module from a single file as if it doesn't belong to a particular package. The returned module will have the optional ``name`` if given, or else a name generated from the filename. """ # Specifying a traditional dot-separated fully qualifi...
python
{ "resource": "" }
q11451
resolve_name
train
def resolve_name(name): """Resolve a name like ``module.object`` to an object and return it. Raise `ImportError` if the module or name is not found. """ parts = name.split('.') cursor = len(parts) - 1 module_name = parts[:cursor] attr_name = parts[-1] while cursor > 0: try: ...
python
{ "resource": "" }
q11452
find_data_files
train
def find_data_files(package, pattern): """ Include files matching ``pattern`` inside ``package``. Parameters ---------- package : str The package inside which to look for data files pattern : str Pattern (glob-style) to match for the data files (e.g. ``*.dat``). This sup...
python
{ "resource": "" }
q11453
get_pkg_version_module
train
def get_pkg_version_module(packagename, fromlist=None): """Returns the package's .version module generated by `astropy_helpers.version_helpers.generate_version_py`. Raises an ImportError if the version module is not found. If ``fromlist`` is an iterable, return a tuple of the members of the versio...
python
{ "resource": "" }
q11454
get_debug_option
train
def get_debug_option(packagename): """ Determines if the build is in debug mode. Returns ------- debug : bool True if the current build was started with the debug option, False otherwise. """ try: current_debug = get_pkg_version_module(packagename, ...
python
{ "resource": "" }
q11455
generate_hooked_command
train
def generate_hooked_command(cmd_name, cmd_cls, hooks): """ Returns a generated subclass of ``cmd_cls`` that runs the pre- and post-command hooks for that command before and after the ``cmd_cls.run`` method. """ def run(self, orig_run=cmd_cls.run): self.run_command_hooks('pre_hooks') ...
python
{ "resource": "" }
q11456
run_command_hooks
train
def run_command_hooks(cmd_obj, hook_kind): """Run hooks registered for that command and phase. *cmd_obj* is a finalized command object; *hook_kind* is either 'pre_hook' or 'post_hook'. """ hooks = getattr(cmd_obj, hook_kind, None) if not hooks: return for modname, hook in hooks: ...
python
{ "resource": "" }
q11457
update_package_files
train
def update_package_files(srcdir, extensions, package_data, packagenames, package_dirs): """ This function is deprecated and maintained for backward compatibility with affiliated packages. Affiliated packages should update their setup.py to use `get_package_info` instead. ""...
python
{ "resource": "" }
q11458
get_package_info
train
def get_package_info(srcdir='.', exclude=()): """ Collates all of the information for building all subpackages and returns a dictionary of keyword arguments that can be passed directly to `distutils.setup`. The purpose of this function is to allow subpackages to update the arguments to the pack...
python
{ "resource": "" }
q11459
iter_setup_packages
train
def iter_setup_packages(srcdir, packages): """ A generator that finds and imports all of the ``setup_package.py`` modules in the source packages. Returns ------- modgen : generator A generator that yields (modname, mod), where `mod` is the module and `modname` is the module name for...
python
{ "resource": "" }
q11460
get_cython_extensions
train
def get_cython_extensions(srcdir, packages, prevextensions=tuple(), extincludedirs=None): """ Looks for Cython files and generates Extensions if needed. Parameters ---------- srcdir : str Path to the root of the source directory to search. prevextensions : list...
python
{ "resource": "" }
q11461
pkg_config
train
def pkg_config(packages, default_libraries, executable='pkg-config'): """ Uses pkg-config to update a set of distutils Extension arguments to include the flags necessary to link against the given packages. If the pkg-config lookup fails, default_libraries is applied to libraries. Parameters ...
python
{ "resource": "" }
q11462
add_external_library
train
def add_external_library(library): """ Add a build option for selecting the internal or system copy of a library. Parameters ---------- library : str The name of the library. If the library is `foo`, the build option will be called `--use-system-foo`. """ for command in ['...
python
{ "resource": "" }
q11463
find_packages
train
def find_packages(where='.', exclude=(), invalidate_cache=False): """ This version of ``find_packages`` caches previous results to speed up subsequent calls. Use ``invalide_cache=True`` to ignore cached results from previous ``find_packages`` calls, and repeat the package search. """ if exclud...
python
{ "resource": "" }
q11464
_get_flag_value_from_var
train
def _get_flag_value_from_var(flag, var, delim=' '): """ Extract flags from an environment variable. Parameters ---------- flag : str The flag to extract, for example '-I' or '-L' var : str The environment variable to extract the flag from, e.g. CFLAGS or LDFLAGS. delim : str...
python
{ "resource": "" }
q11465
get_openmp_flags
train
def get_openmp_flags(): """ Utility for returning compiler and linker flags possibly needed for OpenMP support. Returns ------- result : `{'compiler_flags':<flags>, 'linker_flags':<flags>}` Notes ----- The flags returned are not tested for validity, use `check_openmp_support(op...
python
{ "resource": "" }
q11466
check_openmp_support
train
def check_openmp_support(openmp_flags=None): """ Check whether OpenMP test code can be compiled and run. Parameters ---------- openmp_flags : dict, optional This should be a dictionary with keys ``compiler_flags`` and ``linker_flags`` giving the compiliation and linking flags respec...
python
{ "resource": "" }
q11467
is_openmp_supported
train
def is_openmp_supported(): """ Determine whether the build compiler has OpenMP support. """ log_threshold = log.set_threshold(log.FATAL) ret = check_openmp_support() log.set_threshold(log_threshold) return ret
python
{ "resource": "" }
q11468
generate_openmp_enabled_py
train
def generate_openmp_enabled_py(packagename, srcdir='.', disable_openmp=None): """ Generate ``package.openmp_enabled.is_openmp_enabled``, which can then be used to determine, post build, whether the package was built with or without OpenMP support. """ if packagename.lower() == 'astropy': ...
python
{ "resource": "" }
q11469
HugeTable.GetValue
train
def GetValue(self, row, col): """ Find the matching value from pandas DataFrame, return it. """ if len(self.dataframe): return str(self.dataframe.iloc[row, col]) return ''
python
{ "resource": "" }
q11470
HugeTable.SetValue
train
def SetValue(self, row, col, value): """ Set value in the pandas DataFrame """ self.dataframe.iloc[row, col] = value
python
{ "resource": "" }
q11471
HugeTable.SetColumnValues
train
def SetColumnValues(self, col, value): """ Custom method to efficiently set all values in a column. Parameters ---------- col : str or int name or index position of column value : list-like values to assign to all cells in the column ...
python
{ "resource": "" }
q11472
HugeTable.GetColLabelValue
train
def GetColLabelValue(self, col): """ Get col label from dataframe """ if len(self.dataframe): return self.dataframe.columns[col] return ''
python
{ "resource": "" }
q11473
HugeTable.SetColLabelValue
train
def SetColLabelValue(self, col, value): """ Set col label value in dataframe """ if len(self.dataframe): col_name = str(self.dataframe.columns[col]) self.dataframe.rename(columns={col_name: str(value)}, inplace=True) return None
python
{ "resource": "" }
q11474
BaseMagicGrid.set_scrollbars
train
def set_scrollbars(self): """ Set to always have vertical scrollbar. Have horizontal scrollbar unless grid has very few rows. Older versions of wxPython will choke on this, in which case nothing happens. """ try: if len(self.row_labels) < 5: ...
python
{ "resource": "" }
q11475
BaseMagicGrid.on_edit_grid
train
def on_edit_grid(self, event): """sets self.changes to true when user edits the grid. provides down and up key functionality for exiting the editor""" if not self.changes: self.changes = {event.Row} else: self.changes.add(event.Row) #self.changes = True ...
python
{ "resource": "" }
q11476
BaseMagicGrid.do_paste
train
def do_paste(self, event): """ Read clipboard into dataframe Paste data into grid, adding extra rows if needed and ignoring extra columns. """ # find where the user has clicked col_ind = self.GetGridCursorCol() row_ind = self.GetGridCursorRow() # r...
python
{ "resource": "" }
q11477
BaseMagicGrid.update_changes_after_row_delete
train
def update_changes_after_row_delete(self, row_num): """ Update self.changes so that row numbers for edited rows are still correct. I.e., if row 4 was edited and then row 2 was deleted, row 4 becomes row 3. This function updates self.changes to reflect that. """ if row_num...
python
{ "resource": "" }
q11478
BaseMagicGrid.paint_invalid_cell
train
def paint_invalid_cell(self, row, col, color='MEDIUM VIOLET RED', skip_cell=False): """ Take row, column, and turn it color """ self.SetColLabelRenderer(col, MyColLabelRenderer('#1101e0')) # SetCellRenderer doesn't work with table-based grid (HugeGrid c...
python
{ "resource": "" }
q11479
HugeMagicGrid.add_col
train
def add_col(self, label): """ Update table dataframe, and append a new column Parameters ---------- label : str Returns --------- last_col: int index column number of added col """ self.table.dataframe[label] = '' self...
python
{ "resource": "" }
q11480
HugeMagicGrid.remove_col
train
def remove_col(self, col_num): """ update table dataframe, and remove a column. resize grid to display correctly """ label_value = self.GetColLabelValue(col_num).strip('**').strip('^^') self.col_labels.remove(label_value) del self.table.dataframe[label_value] ...
python
{ "resource": "" }
q11481
main
train
def main(): """ NAME plotdi_a.py DESCRIPTION plots equal area projection from dec inc data and fisher mean, cone of confidence INPUT FORMAT takes dec, inc, alpha95 as first three columns in space delimited file SYNTAX plotdi_a.py [-i][-f FILE] OPTIONS -f ...
python
{ "resource": "" }
q11482
main
train
def main(): """ NAME di_rot.py DESCRIPTION rotates set of directions to new coordinate system SYNTAX di_rot.py [command line options] OPTIONS -h prints help message and quits -f specify input file, default is standard input -F specify output file, d...
python
{ "resource": "" }
q11483
Fit.get
train
def get(self,coordinate_system): """ Return the pmagpy paramters dictionary associated with this fit and the given coordinate system @param: coordinate_system -> the coordinate system who's parameters to return """ if coordinate_system == 'DA-DIR' or coordinate_system == ...
python
{ "resource": "" }
q11484
Fit.has_values
train
def has_values(self, name, tmin, tmax): """ A basic fit equality checker compares name and bounds of 2 fits @param: name -> name of the other fit @param: tmin -> lower bound of the other fit @param: tmax -> upper bound of the other fit @return: boolean comaparing 2 fits ...
python
{ "resource": "" }
q11485
get_n_tail
train
def get_n_tail(tmax, tail_temps): """determines number of included tail checks in best fit segment""" #print "tail_temps: {0}, tmax: {0}".format(tail_temps, tmax) t_index = 0 adj_tmax = 0 if tmax < tail_temps[0]: return 0 try: t_index = list(tail_temps).index(tmax) except: # ...
python
{ "resource": "" }
q11486
main
train
def main(): """ NAME dir_redo.py DESCRIPTION converts the Cogne DIR format to PmagPy redo file SYNTAX dir_redo.py [-h] [command line options] OPTIONS -h: prints help message and quits -f FILE: specify input file -F FILE: specify output file, defaul...
python
{ "resource": "" }
q11487
MagMainFrame.set_dm
train
def set_dm(self, num): """ Make GUI changes based on data model num. Get info from WD in appropriate format. """ #enable or disable self.btn1a if self.data_model_num == 3: self.btn1a.Enable() else: self.btn1a.Disable() # # s...
python
{ "resource": "" }
q11488
MagMainFrame.get_wd_data
train
def get_wd_data(self): """ Show dialog to get user input for which directory to set as working directory. Called by self.get_dm_and_wd """ wait = wx.BusyInfo('Reading in data from current working directory, please wait...') #wx.Yield() print('-I- Read in a...
python
{ "resource": "" }
q11489
MagMainFrame.get_wd_data2
train
def get_wd_data2(self): """ Get 2.5 data from self.WD and put it into ErMagicBuilder object. Called by get_dm_and_wd """ wait = wx.BusyInfo('Reading in data from current working directory, please wait...') #wx.Yield() print('-I- Read in any available data ...
python
{ "resource": "" }
q11490
MagMainFrame.get_dir
train
def get_dir(self): """ Choose a working directory dialog. Called by self.get_dm_and_wd. """ if "-WD" in sys.argv and self.FIRST_RUN: ind = sys.argv.index('-WD') self.WD = os.path.abspath(sys.argv[ind+1]) os.chdir(self.WD) self.WD = ...
python
{ "resource": "" }
q11491
MagMainFrame.on_btn_thellier_gui
train
def on_btn_thellier_gui(self, event): """ Open Thellier GUI """ if not self.check_for_meas_file(): return if not self.check_for_uncombined_files(): return outstring = "thellier_gui.py -WD %s"%self.WD print("-I- running python script:\n %s"%...
python
{ "resource": "" }
q11492
MagMainFrame.on_btn_demag_gui
train
def on_btn_demag_gui(self, event): """ Open Demag GUI """ if not self.check_for_meas_file(): return if not self.check_for_uncombined_files(): return outstring = "demag_gui.py -WD %s"%self.WD print("-I- running python script:\n %s"%(outstri...
python
{ "resource": "" }
q11493
MagMainFrame.on_btn_convert_3
train
def on_btn_convert_3(self, event): """ Open dialog for rough conversion of 2.5 files to 3.0 files. Offer link to earthref for proper upgrade. """ dia = pw.UpgradeDialog(None) dia.Center() res = dia.ShowModal() if res == wx.ID_CANCEL: we...
python
{ "resource": "" }
q11494
MagMainFrame.on_btn_metadata
train
def on_btn_metadata(self, event): """ Initiate the series of windows to add metadata to the contribution. """ # make sure we have a measurements file if not self.check_for_meas_file(): return # make sure all files of the same type have been combined ...
python
{ "resource": "" }
q11495
MagMainFrame.on_btn_orientation
train
def on_btn_orientation(self, event): """ Create and fill wxPython grid for entering orientation data. """ wait = wx.BusyInfo('Compiling required data, please wait...') wx.SafeYield() #dw, dh = wx.DisplaySize() size = wx.DisplaySize() size = (size[0...
python
{ "resource": "" }
q11496
MagMainFrame.on_btn_unpack
train
def on_btn_unpack(self, event): """ Create dialog to choose a file to unpack with download magic. Then run download_magic and create self.contribution. """ dlg = wx.FileDialog( None, message = "choose txt file to unpack", defaultDir=self.WD, ...
python
{ "resource": "" }
q11497
MagMainFrame.on_end_validation
train
def on_end_validation(self, event): """ Switch back from validation mode to main Pmag GUI mode. Hide validation frame and show main frame. """ self.Enable() self.Show() self.magic_gui_frame.Destroy()
python
{ "resource": "" }
q11498
MagMainFrame.on_menu_exit
train
def on_menu_exit(self, event): """ Exit the GUI """ # also delete appropriate copy file try: self.help_window.Destroy() except: pass if '-i' in sys.argv: self.Destroy() try: sys.exit() # can raise TypeError i...
python
{ "resource": "" }
q11499
MagMainFrame.check_for_meas_file
train
def check_for_meas_file(self): """ Check the working directory for a measurement file. If not found, show a warning and return False. Otherwise return True. """ if self.data_model_num == 2: meas_file_name = "magic_measurements.txt" dm = "2.5" ...
python
{ "resource": "" }