_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q34500
cors_allow_any
train
def cors_allow_any(request, response): """ Add headers to permit CORS requests from any origin, with or without credentials, with any headers. """ origin = request.META.get('HTTP_ORIGIN') if not origin: return response # From the CORS spec: The string "*" cannot be used for a resour...
python
{ "resource": "" }
q34501
create_token
train
def create_token(user, client, scope, id_token_dic=None): """ Create and populate a Token object. Return a Token object. """ token = Token() token.user = user token.client = client token.access_token = uuid.uuid4().hex if id_token_dic is not None: token.id_token = id_token_d...
python
{ "resource": "" }
q34502
create_code
train
def create_code(user, client, scope, nonce, is_authentication, code_challenge=None, code_challenge_method=None): """ Create and populate a Code object. Return a Code object. """ code = Code() code.user = user code.client = client code.code = uuid.uuid4().hex if code...
python
{ "resource": "" }
q34503
get_client_alg_keys
train
def get_client_alg_keys(client): """ Takes a client and returns the set of keys associated with it. Returns a list of keys. """ if client.jwt_alg == 'RS256': keys = [] for rsakey in RSAKey.objects.all(): keys.append(jwk_RSAKey(key=importKey(rsakey.key), kid=rsakey.kid)) ...
python
{ "resource": "" }
q34504
read_gbasis
train
def read_gbasis(basis_lines, fname): '''Reads gbasis-formatted file data and converts it to a dictionary with the usual BSE fields Note that the gbasis format does not store all the fields we have, so some fields are left blank ''' skipchars = '!#' basis_lines = [l for l in basis_...
python
{ "resource": "" }
q34505
read_molcas
train
def read_molcas(basis_lines, fname): '''Reads molcas-formatted file data and converts it to a dictionary with the usual BSE fields Note that the turbomole format does not store all the fields we have, so some fields are left blank ''' skipchars = '*#$' basis_lines = [l for l in ba...
python
{ "resource": "" }
q34506
_read_plain_json
train
def _read_plain_json(file_path, check_bse): """ Reads a JSON file A simple wrapper around json.load that only takes the file name If the file does not exist, an exception is thrown. If the file does exist, but there is a problem with the JSON formatting, the filename is added to the exception ...
python
{ "resource": "" }
q34507
_write_plain_json
train
def _write_plain_json(file_path, js): """ Write information to a JSON file This makes sure files are created with the proper encoding and consistent indenting Parameters ---------- file_path : str Full path to the file to write to. It will be overwritten if it exists js : dict ...
python
{ "resource": "" }
q34508
read_notes_file
train
def read_notes_file(file_path): """ Returns the contents of a notes file. If the notes file does not exist, None is returned """ if not os.path.isfile(file_path): return None with open(file_path, 'r', encoding=_default_encoding) as f: return f.read()
python
{ "resource": "" }
q34509
_whole_basis_types
train
def _whole_basis_types(basis): ''' Get a list of all the types of features in this basis set. ''' all_types = set() for v in basis['elements'].values(): if 'electron_shells' in v: for sh in v['electron_shells']: all_types.add(sh['function_type']) if 'e...
python
{ "resource": "" }
q34510
compose_elemental_basis
train
def compose_elemental_basis(file_relpath, data_dir): """ Creates an 'elemental' basis from an elemental json file This function reads the info from the given file, and reads all the component basis set information from the files listed therein. It then composes all the information together into one...
python
{ "resource": "" }
q34511
compose_table_basis
train
def compose_table_basis(file_relpath, data_dir): """ Creates a 'table' basis from an table json file This function reads the info from the given file, and reads all the elemental basis set information from the files listed therein. It then composes all the information together into one 'table' basi...
python
{ "resource": "" }
q34512
create_skel
train
def create_skel(role): ''' Create the skeleton of a dictionary or JSON file A dictionary is returned that contains the "molssi_bse_schema" key and other required keys, depending on the role role can be either 'component', 'element', or 'table' ''' role = role.lower() if not role in _s...
python
{ "resource": "" }
q34513
process_notes
train
def process_notes(notes, ref_data): '''Add reference information to the bottom of a notes file `:ref:` tags are removed and the actual reference data is appended ''' ref_keys = ref_data.keys() found_refs = set() for k in ref_keys: if k in notes: found_refs.add(k) # Th...
python
{ "resource": "" }
q34514
_validate_extra_component
train
def _validate_extra_component(bs_data): '''Extra checks for component basis files''' assert len(bs_data['elements']) > 0 # Make sure size of the coefficient matrix matches the number of exponents for el in bs_data['elements'].values(): if not 'electron_shells' in el: continue ...
python
{ "resource": "" }
q34515
validate_data
train
def validate_data(file_type, bs_data): """ Validates json basis set data against a schema Parameters ---------- file_type : str Type of file to read. May be 'component', 'element', 'table', or 'references' bs_data: Data to be validated Raises ------ RuntimeError ...
python
{ "resource": "" }
q34516
validate_file
train
def validate_file(file_type, file_path): """ Validates a file against a schema Parameters ---------- file_type : str Type of file to read. May be 'component', 'element', 'table', or 'references' file_path: Full path to the file to be validated Raises ------ RuntimeE...
python
{ "resource": "" }
q34517
validate_data_dir
train
def validate_data_dir(data_dir): """ Validates all files in a data_dir """ all_meta, all_table, all_element, all_component = fileio.get_all_filelist(data_dir) for f in all_meta: full_path = os.path.join(data_dir, f) validate_file('metadata', full_path) for f in all_table: ...
python
{ "resource": "" }
q34518
sort_basis_dict
train
def sort_basis_dict(bs): """Sorts a basis set dictionary into a standard order This, for example, allows the written file to be more easily read by humans by, for example, putting the name and description before more detailed fields. This is generally for cosmetic reasons. However, users will generall...
python
{ "resource": "" }
q34519
sort_shell
train
def sort_shell(shell, use_copy=True): """ Sort a basis set shell into a standard order If use_copy is True, the input shells are not modified. """ if use_copy: shell = copy.deepcopy(shell) # Transpose of coefficients tmp_c = list(map(list, zip(*shell['coefficients']))) # For ...
python
{ "resource": "" }
q34520
sort_shells
train
def sort_shells(shells, use_copy=True): """ Sort a list of basis set shells into a standard order The order within a shell is by decreasing value of the exponent. The order of the shell list is in increasing angular momentum, and then by decreasing number of primitives, then decreasing value of th...
python
{ "resource": "" }
q34521
sort_potentials
train
def sort_potentials(potentials, use_copy=True): """ Sort a list of ECP potentials into a standard order The order within a potential is not modified. The order of the shell list is in increasing angular momentum, with the largest angular momentum being moved to the front. If use_copy is True,...
python
{ "resource": "" }
q34522
sort_basis
train
def sort_basis(basis, use_copy=True): """ Sorts all the information in a basis set into a standard order If use_copy is True, the input basis set is not modified. """ if use_copy: basis = copy.deepcopy(basis) for k, el in basis['elements'].items(): if 'electron_shells' in el: ...
python
{ "resource": "" }
q34523
sort_single_reference
train
def sort_single_reference(ref_entry): """Sorts a dictionary containing data for a single reference into a standard order """ # yapf: disable _keyorder = [ # Schema stuff # This function gets called on the schema 'entry', too 'schema_type', 'schema_version', # Type of th...
python
{ "resource": "" }
q34524
sort_references_dict
train
def sort_references_dict(refs): """Sorts a reference dictionary into a standard order The keys of the references are also sorted, and the keys for the data for each reference are put in a more canonical order. """ if _use_odict: refs_sorted = OrderedDict() else: refs_sorted = d...
python
{ "resource": "" }
q34525
read_dalton
train
def read_dalton(basis_lines, fname): '''Reads Dalton-formatted file data and converts it to a dictionary with the usual BSE fields Note that the nwchem format does not store all the fields we have, so some fields are left blank ''' skipchars = '$' basis_lines = [l for l in basis_l...
python
{ "resource": "" }
q34526
find_range
train
def find_range(coeffs): ''' Find the range in a list of coefficients where the coefficient is nonzero ''' coeffs = [float(x) != 0 for x in coeffs] first = coeffs.index(True) coeffs.reverse() last = len(coeffs) - coeffs.index(True) - 1 return first, last
python
{ "resource": "" }
q34527
_ref_bib
train
def _ref_bib(key, ref): '''Convert a single reference to bibtex format ''' s = '' s += '@{}{{{},\n'.format(ref['type'], key) entry_lines = [] for k, v in ref.items(): if k == 'type': continue # Handle authors/editors if k == 'authors': entry_lin...
python
{ "resource": "" }
q34528
write_bib
train
def write_bib(refs): '''Converts references to bibtex ''' full_str = '' lib_citation_desc, lib_citations = get_library_citation() full_str += '%' * 80 + '\n' full_str += textwrap.indent(lib_citation_desc, '% ') full_str += '%' * 80 + '\n\n' for k, r in lib_citations.items(): ...
python
{ "resource": "" }
q34529
write_turbomole
train
def write_turbomole(basis): '''Converts a basis set to Gaussian format ''' s = '$basis\n' s += '*\n' # TM basis sets are completely uncontracted basis = manip.uncontract_general(basis, True) basis = manip.uncontract_spdf(basis, 0, False) basis = sort.sort_basis(basis, False) # Ele...
python
{ "resource": "" }
q34530
compact_references
train
def compact_references(basis_dict, ref_data): """ Creates a mapping of elements to reference keys A list is returned, with each element of the list being a dictionary with entries 'reference_info' containing data for (possibly) multiple references, and 'elements' which is a list of element Z number...
python
{ "resource": "" }
q34531
reference_text
train
def reference_text(ref): '''Convert a single reference to plain text format Parameters ---------- ref : dict Information about a single reference ''' ref_wrap = textwrap.TextWrapper(initial_indent='', subsequent_indent=' ' * 8) s = '' if ref['type'] == 'unpublished': s...
python
{ "resource": "" }
q34532
_determine_leftpad
train
def _determine_leftpad(column, point_place): '''Find how many spaces to put before a column of numbers so that all the decimal points line up This function takes a column of decimal numbers, and returns a vector containing the number of spaces to place before each number so that (when possible) ...
python
{ "resource": "" }
q34533
electron_shell_str
train
def electron_shell_str(shell, shellidx=None): '''Return a string representing the data for an electron shell If shellidx (index of the shell) is not None, it will also be printed ''' am = shell['angular_momentum'] amchar = lut.amint_to_char(am) amchar = amchar.upper() shellidx_str = '' ...
python
{ "resource": "" }
q34534
ecp_pot_str
train
def ecp_pot_str(pot): '''Return a string representing the data for an ECP potential ''' am = pot['angular_momentum'] amchar = lut.amint_to_char(am) rexponents = pot['r_exponents'] gexponents = pot['gaussian_exponents'] coefficients = pot['coefficients'] point_places = [0, 10, 33] ...
python
{ "resource": "" }
q34535
element_data_str
train
def element_data_str(z, eldata): '''Return a string with all data for an element This includes shell and ECP potential data Parameters ---------- z : int or str Element Z-number eldata: dict Data for the element to be printed ''' sym = lut.element_sym_from_Z(z, True) ...
python
{ "resource": "" }
q34536
component_basis_str
train
def component_basis_str(basis, elements=None): '''Print a component basis set If elements is not None, only the specified elements will be printed (see :func:`bse.misc.expand_elements`) ''' s = "Description: " + basis['description'] + '\n' eldata = basis['elements'] # Filter to the given...
python
{ "resource": "" }
q34537
write_molpro
train
def write_molpro(basis): '''Converts a basis set to Molpro format ''' # Uncontract all, and make as generally-contracted as possible basis = manip.uncontract_spdf(basis, 0, True) basis = manip.make_general(basis, False) basis = sort.sort_basis(basis, True) s = '' # Elements for which ...
python
{ "resource": "" }
q34538
convert_basis
train
def convert_basis(basis_dict, fmt, header=None): ''' Returns the basis set data as a string representing the data in the specified output format ''' # make converters case insensitive fmt = fmt.lower() if fmt not in _converter_map: raise RuntimeError('Unknown basis set format "{}"'....
python
{ "resource": "" }
q34539
get_formats
train
def get_formats(function_types=None): ''' Returns the available formats mapped to display name. This is returned as an ordered dictionary, with the most common at the top, followed by the rest in alphabetical order If a list is specified for function_types, only those formats supporting the gi...
python
{ "resource": "" }
q34540
get_format_extension
train
def get_format_extension(fmt): ''' Returns the recommended extension for a given format ''' if fmt is None: return 'dict' fmt = fmt.lower() if fmt not in _converter_map: raise RuntimeError('Unknown basis set format "{}"'.format(fmt)) return _converter_map[fmt]['extension']
python
{ "resource": "" }
q34541
_make_graph
train
def _make_graph(bsname, version=None, data_dir=None): ''' Create a DOT graph file of the files included in a basis set ''' if not graphviz_avail: raise RuntimeError("graphviz package is not installed") data_dir = api.fix_data_dir(data_dir) md = api._get_basis_metadata(bsname, data_dir...
python
{ "resource": "" }
q34542
get_library_citation
train
def get_library_citation(): '''Return a descriptive string and reference data for what users of the library should cite''' all_ref_data = api.get_reference_data() lib_refs_data = {k: all_ref_data[k] for k in _lib_refs} return (_lib_refs_desc, lib_refs_data)
python
{ "resource": "" }
q34543
format_columns
train
def format_columns(lines, prefix=''): ''' Create a simple column output Parameters ---------- lines : list List of lines to format. Each line is a tuple/list with each element corresponding to a column prefix : str Characters to insert at the beginning of each line ...
python
{ "resource": "" }
q34544
write_nwchem
train
def write_nwchem(basis): '''Converts a basis set to NWChem format ''' # Uncontract all but SP basis = manip.uncontract_spdf(basis, 1, True) basis = sort.sort_basis(basis, True) s = '' # Elements for which we have electron basis electron_elements = [k for k, v in basis['elements'].item...
python
{ "resource": "" }
q34545
contraction_string
train
def contraction_string(element): """ Forms a string specifying the contractions for an element ie, (16s,10p) -> [4s,3p] """ # Does not have electron shells (ECP only?) if 'electron_shells' not in element: return "" cont_map = dict() for sh in element['electron_shells']: ...
python
{ "resource": "" }
q34546
expand_elements
train
def expand_elements(compact_el, as_str=False): """ Create a list of integers given a string or list of compacted elements This is partly the opposite of compact_elements, but is more flexible. compact_el can be a list or a string. If compact_el is a list, each element is processed individually as ...
python
{ "resource": "" }
q34547
elements_in_files
train
def elements_in_files(filelist): '''Get a list of what elements exist in JSON files This works on table, element, and component data files Parameters ---------- filelist : list A list of paths to json files Returns ------- dict Keys are the file path, value is a compac...
python
{ "resource": "" }
q34548
_fix_uncontracted
train
def _fix_uncontracted(basis): ''' Forces the contraction coefficient of uncontracted shells to 1.0 ''' for el in basis['elements'].values(): if 'electron_shells' not in el: continue for sh in el['electron_shells']: if len(sh['coefficients']) == 1 and len(sh['coe...
python
{ "resource": "" }
q34549
write_bsedebug
train
def write_bsedebug(basis): '''Converts a basis set to BSE Debug format ''' s = '' for el, eldata in basis['elements'].items(): s += element_data_str(el, eldata) return s
python
{ "resource": "" }
q34550
_bsecurate_cli_get_reader_formats
train
def _bsecurate_cli_get_reader_formats(args): '''Handles the get-file-types subcommand''' all_formats = curate.get_reader_formats() if args.no_description: liststr = all_formats.keys() else: liststr = format_columns(all_formats.items()) return '\n'.join(liststr)
python
{ "resource": "" }
q34551
_bsecurate_cli_elements_in_files
train
def _bsecurate_cli_elements_in_files(args): '''Handles the elements-in-files subcommand''' data = curate.elements_in_files(args.files) return '\n'.join(format_columns(data.items()))
python
{ "resource": "" }
q34552
_bsecurate_cli_component_file_refs
train
def _bsecurate_cli_component_file_refs(args): '''Handles the component-file-refs subcommand''' data = curate.component_file_refs(args.files) s = '' for cfile, cdata in data.items(): s += cfile + '\n' rows = [] for el, refs in cdata: rows.append((' ' + el, ' '.joi...
python
{ "resource": "" }
q34553
_bsecurate_cli_print_component_file
train
def _bsecurate_cli_print_component_file(args): '''Handles the print-component-file subcommand''' data = fileio.read_json_basis(args.file) return printing.component_basis_str(data, elements=args.elements)
python
{ "resource": "" }
q34554
_bsecurate_cli_compare_basis_sets
train
def _bsecurate_cli_compare_basis_sets(args): '''Handles compare-basis-sets subcommand''' ret = curate.compare_basis_sets(args.basis1, args.basis2, args.version1, args.version2, args.uncontract_general, args.data_dir, args.data_dir) if ret: return "No difference found" else: ret...
python
{ "resource": "" }
q34555
_bsecurate_cli_compare_basis_files
train
def _bsecurate_cli_compare_basis_files(args): '''Handles compare-basis-files subcommand''' ret = curate.compare_basis_files(args.file1, args.file2, args.readfmt1, args.readfmt2, args.uncontract_general) if ret: return "No difference found" else: return "DIFFERENCES FOUND. SEE ABOVE"
python
{ "resource": "" }
q34556
_bsecurate_cli_view_graph
train
def _bsecurate_cli_view_graph(args): '''Handles the view-graph subcommand''' curate.view_graph(args.basis, args.version, args.data_dir) return ''
python
{ "resource": "" }
q34557
_bsecurate_cli_make_graph_file
train
def _bsecurate_cli_make_graph_file(args): '''Handles the make-graph-file subcommand''' curate.make_graph_file(args.basis, args.outfile, args.render, args.version, args.data_dir) return ''
python
{ "resource": "" }
q34558
element_data_from_Z
train
def element_data_from_Z(Z): '''Obtain elemental data given a Z number An exception is thrown if the Z number is not found ''' # Z may be a str if isinstance(Z, str) and Z.isdecimal(): Z = int(Z) if Z not in _element_Z_map: raise KeyError('No element data for Z = {}'.format(Z))...
python
{ "resource": "" }
q34559
element_data_from_sym
train
def element_data_from_sym(sym): '''Obtain elemental data given an elemental symbol The given symbol is not case sensitive An exception is thrown if the symbol is not found ''' sym_lower = sym.lower() if sym_lower not in _element_sym_map: raise KeyError('No element data for symbol \'{}...
python
{ "resource": "" }
q34560
element_data_from_name
train
def element_data_from_name(name): '''Obtain elemental data given an elemental name The given name is not case sensitive An exception is thrown if the name is not found ''' name_lower = name.lower() if name_lower not in _element_name_map: raise KeyError('No element data for name \'{}\'...
python
{ "resource": "" }
q34561
element_name_from_Z
train
def element_name_from_Z(Z, normalize=False): '''Obtain an element's name from its Z number An exception is thrown if the Z number is not found If normalize is True, the first letter will be capitalized ''' r = element_data_from_Z(Z)[2] if normalize: return r.capitalize() else: ...
python
{ "resource": "" }
q34562
element_sym_from_Z
train
def element_sym_from_Z(Z, normalize=False): '''Obtain an element's symbol from its Z number An exception is thrown if the Z number is not found If normalize is True, the first letter will be capitalized ''' r = element_data_from_Z(Z)[0] if normalize: return r.capitalize() else: ...
python
{ "resource": "" }
q34563
convert_references
train
def convert_references(ref_data, fmt): ''' Returns the basis set references as a string representing the data in the specified output format ''' # Make fmt case insensitive fmt = fmt.lower() if fmt not in _converter_map: raise RuntimeError('Unknown reference format "{}"'.format(fmt)...
python
{ "resource": "" }
q34564
_get_basis_metadata
train
def _get_basis_metadata(name, data_dir): '''Get metadata for a single basis set If the basis doesn't exist, an exception is raised ''' # Transform the name into an internal representation tr_name = misc.transform_basis_name(name) # Get the metadata for all basis sets metadata = get_metada...
python
{ "resource": "" }
q34565
_header_string
train
def _header_string(basis_dict): '''Creates a header with information about a basis set Information includes description, revision, etc, but not references ''' tw = textwrap.TextWrapper(initial_indent='', subsequent_indent=' ' * 20) header = '-' * 70 + '\n' header += ' Basis Set Exchange\n' ...
python
{ "resource": "" }
q34566
get_basis
train
def get_basis(name, elements=None, version=None, fmt=None, uncontract_general=False, uncontract_spdf=False, uncontract_segmented=False, make_general=False, optimize_general=False, data_dir=None,...
python
{ "resource": "" }
q34567
lookup_basis_by_role
train
def lookup_basis_by_role(primary_basis, role, data_dir=None): '''Lookup the name of an auxiliary basis set given a primary basis set and role Parameters ---------- primary_basis : str The primary (orbital) basis set that we want the auxiliary basis set for. This is not case sensitive. ...
python
{ "resource": "" }
q34568
get_metadata
train
def get_metadata(data_dir=None): '''Obtain the metadata for all basis sets The metadata includes information such as the display name of the basis set, its versions, and what elements are included in the basis set The data is read from the METADATA.json file in the `data_dir` directory. Parameter...
python
{ "resource": "" }
q34569
get_reference_data
train
def get_reference_data(data_dir=None): '''Obtain information for all stored references This is a nested dictionary with all the data for all the references The reference data is read from the REFERENCES.json file in the given `data_dir` directory. ''' data_dir = fix_data_dir(data_dir) ref...
python
{ "resource": "" }
q34570
get_basis_family
train
def get_basis_family(basis_name, data_dir=None): '''Lookup a family by a basis set name ''' data_dir = fix_data_dir(data_dir) bs_data = _get_basis_metadata(basis_name, data_dir) return bs_data['family']
python
{ "resource": "" }
q34571
get_families
train
def get_families(data_dir=None): '''Return a list of all basis set families''' data_dir = fix_data_dir(data_dir) metadata = get_metadata(data_dir) families = set() for v in metadata.values(): families.add(v['family']) return sorted(list(families))
python
{ "resource": "" }
q34572
filter_basis_sets
train
def filter_basis_sets(substr=None, family=None, role=None, data_dir=None): '''Filter basis sets by some criteria All parameters are ANDed together and are not case sensitive. Parameters ---------- substr : str Substring to search for in the basis set name family : str Family th...
python
{ "resource": "" }
q34573
_family_notes_path
train
def _family_notes_path(family, data_dir): '''Form a path to the notes for a family''' data_dir = fix_data_dir(data_dir) family = family.lower() if not family in get_families(data_dir): raise RuntimeError("Family '{}' does not exist".format(family)) file_name = 'NOTES.' + family.lower() ...
python
{ "resource": "" }
q34574
_basis_notes_path
train
def _basis_notes_path(name, data_dir): '''Form a path to the notes for a basis set''' data_dir = fix_data_dir(data_dir) bs_data = _get_basis_metadata(name, data_dir) # the notes file is the same as the base file name, with a .notes extension filebase = bs_data['basename'] file_path = os.path.j...
python
{ "resource": "" }
q34575
get_family_notes
train
def get_family_notes(family, data_dir=None): '''Return a string representing the notes about a basis set family If the notes are not found, an empty string is returned ''' file_path = _family_notes_path(family, data_dir) notes_str = fileio.read_notes_file(file_path) if notes_str is None: ...
python
{ "resource": "" }
q34576
has_family_notes
train
def has_family_notes(family, data_dir=None): '''Check if notes exist for a given family Returns True if they exist, false otherwise ''' file_path = _family_notes_path(family, data_dir) return os.path.isfile(file_path)
python
{ "resource": "" }
q34577
get_basis_notes
train
def get_basis_notes(name, data_dir=None): '''Return a string representing the notes about a specific basis set If the notes are not found, an empty string is returned ''' file_path = _basis_notes_path(name, data_dir) notes_str = fileio.read_notes_file(file_path) if notes_str is None: ...
python
{ "resource": "" }
q34578
has_basis_notes
train
def has_basis_notes(family, data_dir=None): '''Check if notes exist for a given basis set Returns True if they exist, false otherwise ''' file_path = _basis_notes_path(family, data_dir) return os.path.isfile(file_path)
python
{ "resource": "" }
q34579
get_schema
train
def get_schema(schema_type): '''Get a schema that can validate BSE JSON files The schema_type represents the type of BSE JSON file to be validated, and can be 'component', 'element', 'table', 'metadata', or 'references'. ''' schema_file = "{}-schema.json".format(schema_type) file_path = ...
python
{ "resource": "" }
q34580
_cli_check_data_dir
train
def _cli_check_data_dir(data_dir): '''Checks that the data dir exists and contains METADATA.json''' if data_dir is None: return None data_dir = os.path.expanduser(data_dir) data_dir = os.path.expandvars(data_dir) if not os.path.isdir(data_dir): raise RuntimeError("Data directory '{...
python
{ "resource": "" }
q34581
_cli_check_format
train
def _cli_check_format(fmt): '''Checks that a basis set format exists and if not, raises a helpful exception''' if fmt is None: return None fmt = fmt.lower() if not fmt in api.get_formats(): errstr = "Format '" + fmt + "' does not exist.\n" errstr += "For a complete list of form...
python
{ "resource": "" }
q34582
_cli_check_ref_format
train
def _cli_check_ref_format(fmt): '''Checks that a reference format exists and if not, raises a helpful exception''' if fmt is None: return None fmt = fmt.lower() if not fmt in api.get_reference_formats(): errstr = "Reference format '" + fmt + "' does not exist.\n" errstr += "For...
python
{ "resource": "" }
q34583
_cli_check_role
train
def _cli_check_role(role): '''Checks that a basis set role exists and if not, raises a helpful exception''' if role is None: return None role = role.lower() if not role in api.get_roles(): errstr = "Role format '" + role + "' does not exist.\n" errstr += "For a complete list of...
python
{ "resource": "" }
q34584
_cli_check_basis
train
def _cli_check_basis(name, data_dir): '''Checks that a basis set exists and if not, raises a helpful exception''' if name is None: return None name = misc.transform_basis_name(name) metadata = api.get_metadata(data_dir) if not name in metadata: errstr = "Basis set '" + name + "' do...
python
{ "resource": "" }
q34585
_cli_check_family
train
def _cli_check_family(family, data_dir): '''Checks that a basis set family exists and if not, raises a helpful exception''' if family is None: return None family = family.lower() if not family in api.get_families(data_dir): errstr = "Basis set family '" + family + "' does not exist.\n"...
python
{ "resource": "" }
q34586
_cli_check_readfmt
train
def _cli_check_readfmt(readfmt): '''Checks that a file type exists and if not, raises a helpful exception''' if readfmt is None: return None readfmt = readfmt.lower() if not readfmt in curate.get_reader_formats(): errstr = "Reader for file type '" + readfmt + "' does not exist.\n" ...
python
{ "resource": "" }
q34587
_create_readme
train
def _create_readme(fmt, reffmt): ''' Creates the readme file for the bundle Returns a str representing the readme file ''' now = datetime.datetime.utcnow() timestamp = now.strftime('%Y-%m-%d %H:%M:%S UTC') # yapf: disable outstr = _readme_str.format(timestamp=timestamp, ...
python
{ "resource": "" }
q34588
_add_to_tbz
train
def _add_to_tbz(tfile, filename, data_str): ''' Adds string data to a tarfile ''' # Create a bytesio object for adding to a tarfile # https://stackoverflow.com/a/52724508 encoded_data = data_str.encode('utf-8') ti = tarfile.TarInfo(name=filename) ti.size = len(encoded_data) tfile.ad...
python
{ "resource": "" }
q34589
_bundle_generic
train
def _bundle_generic(bfile, addhelper, fmt, reffmt, data_dir): ''' Loop over all basis sets and add data to an archive Parameters ---------- bfile : object An object that gets passed through to the addhelper function addhelper : function A function that takes bfile and adds data ...
python
{ "resource": "" }
q34590
create_bundle
train
def create_bundle(outfile, fmt, reffmt, archive_type=None, data_dir=None): ''' Create a single archive file containing all basis sets in a given format Parameters ---------- outfile : str Path to the file to create. Existing files will be overwritten fmt : str Format of the ...
python
{ "resource": "" }
q34591
get_archive_types
train
def get_archive_types(): ''' Return information related to the types of archives available ''' ret = copy.deepcopy(_bundle_types) for k, v in ret.items(): v.pop('handler') return ret
python
{ "resource": "" }
q34592
merge_element_data
train
def merge_element_data(dest, sources, use_copy=True): """ Merges the basis set data for an element from multiple sources into dest. The destination is not modified, and a (shallow) copy of dest is returned with the data from sources added. If use_copy is True, then the data merged into dest wi...
python
{ "resource": "" }
q34593
prune_shell
train
def prune_shell(shell, use_copy=True): """ Removes exact duplicates of primitives, and condenses duplicate exponents into general contractions Also removes primitives if all coefficients are zero """ new_exponents = [] new_coefficients = [] exponents = shell['exponents'] nprim = l...
python
{ "resource": "" }
q34594
prune_basis
train
def prune_basis(basis, use_copy=True): """ Removes primitives that have a zero coefficient, and removes duplicate primitives and shells This only finds EXACT duplicates, and is meant to be used after other manipulations If use_copy is True, the input basis set is not modified. """ if ...
python
{ "resource": "" }
q34595
uncontract_spdf
train
def uncontract_spdf(basis, max_am=0, use_copy=True): """ Removes sp, spd, spdf, etc, contractions from a basis set The general contractions are replaced by uncontracted versions Contractions up to max_am will be left in place. For example, if max_am = 1, spd will be split into sp and d The in...
python
{ "resource": "" }
q34596
uncontract_general
train
def uncontract_general(basis, use_copy=True): """ Removes the general contractions from a basis set The input basis set is not modified. The returned basis may have functions with coefficients of zero and may have duplicate shells. If use_copy is True, the input basis set is not modified. ...
python
{ "resource": "" }
q34597
uncontract_segmented
train
def uncontract_segmented(basis, use_copy=True): """ Removes the segmented contractions from a basis set This implicitly removes general contractions as well, but will leave sp, spd, ... orbitals alone The input basis set is not modified. The returned basis may have functions with coefficients ...
python
{ "resource": "" }
q34598
make_general
train
def make_general(basis, use_copy=True): """ Makes one large general contraction for each angular momentum If use_copy is True, the input basis set is not modified. The output of this function is not pretty. If you want to make it nicer, use sort_basis afterwards. """ zero = '0.00000000' ...
python
{ "resource": "" }
q34599
optimize_general
train
def optimize_general(basis, use_copy=True): """ Optimizes the general contraction using the method of Hashimoto et al .. seealso :: | T. Hashimoto, K. Hirao, H. Tatewaki | 'Comment on Dunning's correlation-consistent basis set' | Chemical Physics Letters v243, Issues 1-2...
python
{ "resource": "" }