id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
47,000
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.cut_cuboid
def cut_cuboid( self, a=20, b=None, c=None, origin=None, outside_sliced=True, preserve_bonds=False): """Cut a cuboid specified by edge and radius. Args: a (float): Value of the a edge. b (float):...
python
def cut_cuboid( self, a=20, b=None, c=None, origin=None, outside_sliced=True, preserve_bonds=False): """Cut a cuboid specified by edge and radius. Args: a (float): Value of the a edge. b (float):...
[ "def", "cut_cuboid", "(", "self", ",", "a", "=", "20", ",", "b", "=", "None", ",", "c", "=", "None", ",", "origin", "=", "None", ",", "outside_sliced", "=", "True", ",", "preserve_bonds", "=", "False", ")", ":", "if", "origin", "is", "None", ":", ...
Cut a cuboid specified by edge and radius. Args: a (float): Value of the a edge. b (float): Value of the b edge. Takes value of a if None. c (float): Value of the c edge. Takes value of a if None. origin (list): Please note that you can also pass an ...
[ "Cut", "a", "cuboid", "specified", "by", "edge", "and", "radius", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L641-L683
47,001
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_barycenter
def get_barycenter(self): """Return the mass weighted average location. Args: None Returns: :class:`numpy.ndarray`: """ try: mass = self['mass'].values except KeyError: mass = self.add_data('mass')['mass'].values p...
python
def get_barycenter(self): """Return the mass weighted average location. Args: None Returns: :class:`numpy.ndarray`: """ try: mass = self['mass'].values except KeyError: mass = self.add_data('mass')['mass'].values p...
[ "def", "get_barycenter", "(", "self", ")", ":", "try", ":", "mass", "=", "self", "[", "'mass'", "]", ".", "values", "except", "KeyError", ":", "mass", "=", "self", ".", "add_data", "(", "'mass'", ")", "[", "'mass'", "]", ".", "values", "pos", "=", ...
Return the mass weighted average location. Args: None Returns: :class:`numpy.ndarray`:
[ "Return", "the", "mass", "weighted", "average", "location", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L696-L710
47,002
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_bond_lengths
def get_bond_lengths(self, indices): """Return the distances between given atoms. Calculates the distance between the atoms with indices ``i`` and ``b``. The indices can be given in three ways: * As simple list ``[i, b]`` * As list of lists: ``[[i1, b1], [i2, b2]...]`` ...
python
def get_bond_lengths(self, indices): """Return the distances between given atoms. Calculates the distance between the atoms with indices ``i`` and ``b``. The indices can be given in three ways: * As simple list ``[i, b]`` * As list of lists: ``[[i1, b1], [i2, b2]...]`` ...
[ "def", "get_bond_lengths", "(", "self", ",", "indices", ")", ":", "coords", "=", "[", "'x'", ",", "'y'", ",", "'z'", "]", "if", "isinstance", "(", "indices", ",", "pd", ".", "DataFrame", ")", ":", "i_pos", "=", "self", ".", "loc", "[", "indices", "...
Return the distances between given atoms. Calculates the distance between the atoms with indices ``i`` and ``b``. The indices can be given in three ways: * As simple list ``[i, b]`` * As list of lists: ``[[i1, b1], [i2, b2]...]`` * As :class:`pd.DataFrame` where ``i`` i...
[ "Return", "the", "distances", "between", "given", "atoms", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L712-L740
47,003
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_angle_degrees
def get_angle_degrees(self, indices): """Return the angles between given atoms. Calculates the angle in degrees between the atoms with indices ``i, b, a``. The indices can be given in three ways: * As simple list ``[i, b, a]`` * As list of lists: ``[[i1, b1, a1], [i2, b...
python
def get_angle_degrees(self, indices): """Return the angles between given atoms. Calculates the angle in degrees between the atoms with indices ``i, b, a``. The indices can be given in three ways: * As simple list ``[i, b, a]`` * As list of lists: ``[[i1, b1, a1], [i2, b...
[ "def", "get_angle_degrees", "(", "self", ",", "indices", ")", ":", "coords", "=", "[", "'x'", ",", "'y'", ",", "'z'", "]", "if", "isinstance", "(", "indices", ",", "pd", ".", "DataFrame", ")", ":", "i_pos", "=", "self", ".", "loc", "[", "indices", ...
Return the angles between given atoms. Calculates the angle in degrees between the atoms with indices ``i, b, a``. The indices can be given in three ways: * As simple list ``[i, b, a]`` * As list of lists: ``[[i1, b1, a1], [i2, b2, a2]...]`` * As :class:`pd.DataFrame` w...
[ "Return", "the", "angles", "between", "given", "atoms", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L742-L779
47,004
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_dihedral_degrees
def get_dihedral_degrees(self, indices, start_row=0): """Return the dihedrals between given atoms. Calculates the dihedral angle in degrees between the atoms with indices ``i, b, a, d``. The indices can be given in three ways: * As simple list ``[i, b, a, d]`` * As list...
python
def get_dihedral_degrees(self, indices, start_row=0): """Return the dihedrals between given atoms. Calculates the dihedral angle in degrees between the atoms with indices ``i, b, a, d``. The indices can be given in three ways: * As simple list ``[i, b, a, d]`` * As list...
[ "def", "get_dihedral_degrees", "(", "self", ",", "indices", ",", "start_row", "=", "0", ")", ":", "coords", "=", "[", "'x'", ",", "'y'", ",", "'z'", "]", "if", "isinstance", "(", "indices", ",", "pd", ".", "DataFrame", ")", ":", "i_pos", "=", "self",...
Return the dihedrals between given atoms. Calculates the dihedral angle in degrees between the atoms with indices ``i, b, a, d``. The indices can be given in three ways: * As simple list ``[i, b, a, d]`` * As list of lists: ``[[i1, b1, a1, d1], [i2, b2, a2, d2]...]`` * ...
[ "Return", "the", "dihedrals", "between", "given", "atoms", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L781-L840
47,005
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.fragmentate
def fragmentate(self, give_only_index=False, use_lookup=None): """Get the indices of non bonded parts in the molecule. Args: give_only_index (bool): If ``True`` a set of indices is returned. Otherwise a new Cartesian instance. use_lookup (bool...
python
def fragmentate(self, give_only_index=False, use_lookup=None): """Get the indices of non bonded parts in the molecule. Args: give_only_index (bool): If ``True`` a set of indices is returned. Otherwise a new Cartesian instance. use_lookup (bool...
[ "def", "fragmentate", "(", "self", ",", "give_only_index", "=", "False", ",", "use_lookup", "=", "None", ")", ":", "if", "use_lookup", "is", "None", ":", "use_lookup", "=", "settings", "[", "'defaults'", "]", "[", "'use_lookup'", "]", "fragments", "=", "["...
Get the indices of non bonded parts in the molecule. Args: give_only_index (bool): If ``True`` a set of indices is returned. Otherwise a new Cartesian instance. use_lookup (bool): Use a lookup variable for :meth:`~chemcoord.Cartesian.get_bonds`. ...
[ "Get", "the", "indices", "of", "non", "bonded", "parts", "in", "the", "molecule", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L842-L883
47,006
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.restrict_bond_dict
def restrict_bond_dict(self, bond_dict): """Restrict a bond dictionary to self. Args: bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`, to see examples for a bond_dict. Returns: bond dictionary """ return {j: bond_dict[j...
python
def restrict_bond_dict(self, bond_dict): """Restrict a bond dictionary to self. Args: bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`, to see examples for a bond_dict. Returns: bond dictionary """ return {j: bond_dict[j...
[ "def", "restrict_bond_dict", "(", "self", ",", "bond_dict", ")", ":", "return", "{", "j", ":", "bond_dict", "[", "j", "]", "&", "set", "(", "self", ".", "index", ")", "for", "j", "in", "self", ".", "index", "}" ]
Restrict a bond dictionary to self. Args: bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`, to see examples for a bond_dict. Returns: bond dictionary
[ "Restrict", "a", "bond", "dictionary", "to", "self", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L885-L895
47,007
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_fragment
def get_fragment(self, list_of_indextuples, give_only_index=False, use_lookup=None): """Get the indices of the atoms in a fragment. The list_of_indextuples contains all bondings from the molecule to the fragment. ``[(1,3), (2,4)]`` means for example that the fragmen...
python
def get_fragment(self, list_of_indextuples, give_only_index=False, use_lookup=None): """Get the indices of the atoms in a fragment. The list_of_indextuples contains all bondings from the molecule to the fragment. ``[(1,3), (2,4)]`` means for example that the fragmen...
[ "def", "get_fragment", "(", "self", ",", "list_of_indextuples", ",", "give_only_index", "=", "False", ",", "use_lookup", "=", "None", ")", ":", "if", "use_lookup", "is", "None", ":", "use_lookup", "=", "settings", "[", "'defaults'", "]", "[", "'use_lookup'", ...
Get the indices of the atoms in a fragment. The list_of_indextuples contains all bondings from the molecule to the fragment. ``[(1,3), (2,4)]`` means for example that the fragment is connected over two bonds. The first bond is from atom 1 in the molecule to atom 3 in the fragment. The s...
[ "Get", "the", "indices", "of", "the", "atoms", "in", "a", "fragment", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L897-L929
47,008
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_without
def get_without(self, fragments, use_lookup=None): """Return self without the specified fragments. Args: fragments: Either a list of :class:`~chemcoord.Cartesian` or a :class:`~chemcoord.Cartesian`. use_lookup (bool): Use a lookup variable for...
python
def get_without(self, fragments, use_lookup=None): """Return self without the specified fragments. Args: fragments: Either a list of :class:`~chemcoord.Cartesian` or a :class:`~chemcoord.Cartesian`. use_lookup (bool): Use a lookup variable for...
[ "def", "get_without", "(", "self", ",", "fragments", ",", "use_lookup", "=", "None", ")", ":", "if", "use_lookup", "is", "None", ":", "use_lookup", "=", "settings", "[", "'defaults'", "]", "[", "'use_lookup'", "]", "if", "pd", ".", "api", ".", "types", ...
Return self without the specified fragments. Args: fragments: Either a list of :class:`~chemcoord.Cartesian` or a :class:`~chemcoord.Cartesian`. use_lookup (bool): Use a lookup variable for :meth:`~chemcoord.Cartesian.get_bonds`. The default is ...
[ "Return", "self", "without", "the", "specified", "fragments", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L931-L958
47,009
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore._jit_pairwise_distances
def _jit_pairwise_distances(pos1, pos2): """Optimized function for calculating the distance between each pair of points in positions1 and positions2. Does use python mode as fallback, if a scalar and not an array is given. """ n1 = pos1.shape[0] n2 = pos2.shape[0...
python
def _jit_pairwise_distances(pos1, pos2): """Optimized function for calculating the distance between each pair of points in positions1 and positions2. Does use python mode as fallback, if a scalar and not an array is given. """ n1 = pos1.shape[0] n2 = pos2.shape[0...
[ "def", "_jit_pairwise_distances", "(", "pos1", ",", "pos2", ")", ":", "n1", "=", "pos1", ".", "shape", "[", "0", "]", "n2", "=", "pos2", ".", "shape", "[", "0", "]", "D", "=", "np", ".", "empty", "(", "(", "n1", ",", "n2", ")", ")", "for", "i...
Optimized function for calculating the distance between each pair of points in positions1 and positions2. Does use python mode as fallback, if a scalar and not an array is given.
[ "Optimized", "function", "for", "calculating", "the", "distance", "between", "each", "pair", "of", "points", "in", "positions1", "and", "positions2", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L962-L976
47,010
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_inertia
def get_inertia(self): """Calculate the inertia tensor and transforms along rotation axes. This function calculates the inertia tensor and returns a 4-tuple. The unit is ``amu * length-unit-of-xyz-file**2`` Args: None Returns: dict: The...
python
def get_inertia(self): """Calculate the inertia tensor and transforms along rotation axes. This function calculates the inertia tensor and returns a 4-tuple. The unit is ``amu * length-unit-of-xyz-file**2`` Args: None Returns: dict: The...
[ "def", "get_inertia", "(", "self", ")", ":", "def", "calculate_inertia_tensor", "(", "molecule", ")", ":", "masses", "=", "molecule", ".", "loc", "[", ":", ",", "'mass'", "]", ".", "values", "pos", "=", "molecule", ".", "loc", "[", ":", ",", "[", "'x...
Calculate the inertia tensor and transforms along rotation axes. This function calculates the inertia tensor and returns a 4-tuple. The unit is ``amu * length-unit-of-xyz-file**2`` Args: None Returns: dict: The returned dictionary has four poss...
[ "Calculate", "the", "inertia", "tensor", "and", "transforms", "along", "rotation", "axes", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1005-L1063
47,011
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.basistransform
def basistransform(self, new_basis, old_basis=None, orthonormalize=True): """Transform the frame to a new basis. This function transforms the cartesian coordinates from an old basis to a new one. Please note that old_basis and new_basis are supposed to have full R...
python
def basistransform(self, new_basis, old_basis=None, orthonormalize=True): """Transform the frame to a new basis. This function transforms the cartesian coordinates from an old basis to a new one. Please note that old_basis and new_basis are supposed to have full R...
[ "def", "basistransform", "(", "self", ",", "new_basis", ",", "old_basis", "=", "None", ",", "orthonormalize", "=", "True", ")", ":", "if", "old_basis", "is", "None", ":", "old_basis", "=", "np", ".", "identity", "(", "3", ")", "is_rotation_matrix", "=", ...
Transform the frame to a new basis. This function transforms the cartesian coordinates from an old basis to a new one. Please note that old_basis and new_basis are supposed to have full Rank and consist of three linear independent vectors. If rotate_only is True, it is asserted,...
[ "Transform", "the", "frame", "to", "a", "new", "basis", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1065-L1098
47,012
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.get_distance_to
def get_distance_to(self, origin=None, other_atoms=None, sort=False): """Return a Cartesian with a column for the distance from origin. """ if origin is None: origin = np.zeros(3) elif pd.api.types.is_list_like(origin): origin = np.array(origin, dtype='f8') ...
python
def get_distance_to(self, origin=None, other_atoms=None, sort=False): """Return a Cartesian with a column for the distance from origin. """ if origin is None: origin = np.zeros(3) elif pd.api.types.is_list_like(origin): origin = np.array(origin, dtype='f8') ...
[ "def", "get_distance_to", "(", "self", ",", "origin", "=", "None", ",", "other_atoms", "=", "None", ",", "sort", "=", "False", ")", ":", "if", "origin", "is", "None", ":", "origin", "=", "np", ".", "zeros", "(", "3", ")", "elif", "pd", ".", "api", ...
Return a Cartesian with a column for the distance from origin.
[ "Return", "a", "Cartesian", "with", "a", "column", "for", "the", "distance", "from", "origin", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1118-L1141
47,013
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.change_numbering
def change_numbering(self, rename_dict, inplace=False): """Return the reindexed version of Cartesian. Args: rename_dict (dict): A dictionary mapping integers on integers. Returns: Cartesian: A renamed copy according to the dictionary passed. """ output =...
python
def change_numbering(self, rename_dict, inplace=False): """Return the reindexed version of Cartesian. Args: rename_dict (dict): A dictionary mapping integers on integers. Returns: Cartesian: A renamed copy according to the dictionary passed. """ output =...
[ "def", "change_numbering", "(", "self", ",", "rename_dict", ",", "inplace", "=", "False", ")", ":", "output", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "new_index", "=", "[", "rename_dict", ".", "get", "(", "key", ",", "key",...
Return the reindexed version of Cartesian. Args: rename_dict (dict): A dictionary mapping integers on integers. Returns: Cartesian: A renamed copy according to the dictionary passed.
[ "Return", "the", "reindexed", "version", "of", "Cartesian", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1143-L1156
47,014
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.partition_chem_env
def partition_chem_env(self, n_sphere=4, use_lookup=None): """This function partitions the molecule into subsets of the same chemical environment. A chemical environment is specified by the number of surrounding atoms of a certain kind around an atom with a ...
python
def partition_chem_env(self, n_sphere=4, use_lookup=None): """This function partitions the molecule into subsets of the same chemical environment. A chemical environment is specified by the number of surrounding atoms of a certain kind around an atom with a ...
[ "def", "partition_chem_env", "(", "self", ",", "n_sphere", "=", "4", ",", "use_lookup", "=", "None", ")", ":", "if", "use_lookup", "is", "None", ":", "use_lookup", "=", "settings", "[", "'defaults'", "]", "[", "'use_lookup'", "]", "def", "get_chem_env", "(...
This function partitions the molecule into subsets of the same chemical environment. A chemical environment is specified by the number of surrounding atoms of a certain kind around an atom with a certain atomic number represented by a tuple of a string and a frozenset of tuples....
[ "This", "function", "partitions", "the", "molecule", "into", "subsets", "of", "the", "same", "chemical", "environment", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1158-L1219
47,015
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.align
def align(self, other, indices=None, ignore_hydrogens=False): """Align two Cartesians. Minimize the RMSD (root mean squared deviation) between ``self`` and ``other``. Returns a tuple of copies of ``self`` and ``other`` where both are centered around their centroid and ...
python
def align(self, other, indices=None, ignore_hydrogens=False): """Align two Cartesians. Minimize the RMSD (root mean squared deviation) between ``self`` and ``other``. Returns a tuple of copies of ``self`` and ``other`` where both are centered around their centroid and ...
[ "def", "align", "(", "self", ",", "other", ",", "indices", "=", "None", ",", "ignore_hydrogens", "=", "False", ")", ":", "m1", "=", "(", "self", "-", "self", ".", "get_centroid", "(", ")", ")", ".", "sort_index", "(", ")", "m2", "=", "(", "other", ...
Align two Cartesians. Minimize the RMSD (root mean squared deviation) between ``self`` and ``other``. Returns a tuple of copies of ``self`` and ``other`` where both are centered around their centroid and ``other`` is rotated unto ``self``. The rotation minimises the di...
[ "Align", "two", "Cartesians", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1221-L1271
47,016
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_core.py
CartesianCore.reindex_similar
def reindex_similar(self, other, n_sphere=4): """Reindex ``other`` to be similarly indexed as ``self``. Returns a reindexed copy of ``other`` that minimizes the distance for each atom to itself in the same chemical environemt from ``self`` to ``other``. Read more about the defin...
python
def reindex_similar(self, other, n_sphere=4): """Reindex ``other`` to be similarly indexed as ``self``. Returns a reindexed copy of ``other`` that minimizes the distance for each atom to itself in the same chemical environemt from ``self`` to ``other``. Read more about the defin...
[ "def", "reindex_similar", "(", "self", ",", "other", ",", "n_sphere", "=", "4", ")", ":", "def", "make_subset_similar", "(", "m1", ",", "subset1", ",", "m2", ",", "subset2", ",", "index_dct", ")", ":", "\"\"\"Changes index_dct INPLACE\"\"\"", "coords", "=", ...
Reindex ``other`` to be similarly indexed as ``self``. Returns a reindexed copy of ``other`` that minimizes the distance for each atom to itself in the same chemical environemt from ``self`` to ``other``. Read more about the definition of the chemical environment in :func:`Carte...
[ "Reindex", "other", "to", "be", "similarly", "indexed", "as", "self", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1273-L1342
47,017
petrjasek/eve-elastic
eve_elastic/elastic.py
parse_date
def parse_date(date_str): """Parse elastic datetime string.""" if not date_str: return None try: date = ciso8601.parse_datetime(date_str) if not date: date = arrow.get(date_str).datetime except TypeError: date = arrow.get(date_str[0]).datetime return date
python
def parse_date(date_str): """Parse elastic datetime string.""" if not date_str: return None try: date = ciso8601.parse_datetime(date_str) if not date: date = arrow.get(date_str).datetime except TypeError: date = arrow.get(date_str[0]).datetime return date
[ "def", "parse_date", "(", "date_str", ")", ":", "if", "not", "date_str", ":", "return", "None", "try", ":", "date", "=", "ciso8601", ".", "parse_datetime", "(", "date_str", ")", "if", "not", "date", ":", "date", "=", "arrow", ".", "get", "(", "date_str...
Parse elastic datetime string.
[ "Parse", "elastic", "datetime", "string", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L25-L36
47,018
petrjasek/eve-elastic
eve_elastic/elastic.py
get_dates
def get_dates(schema): """Return list of datetime fields for given schema.""" dates = [config.LAST_UPDATED, config.DATE_CREATED] for field, field_schema in schema.items(): if field_schema['type'] == 'datetime': dates.append(field) return dates
python
def get_dates(schema): """Return list of datetime fields for given schema.""" dates = [config.LAST_UPDATED, config.DATE_CREATED] for field, field_schema in schema.items(): if field_schema['type'] == 'datetime': dates.append(field) return dates
[ "def", "get_dates", "(", "schema", ")", ":", "dates", "=", "[", "config", ".", "LAST_UPDATED", ",", "config", ".", "DATE_CREATED", "]", "for", "field", ",", "field_schema", "in", "schema", ".", "items", "(", ")", ":", "if", "field_schema", "[", "'type'",...
Return list of datetime fields for given schema.
[ "Return", "list", "of", "datetime", "fields", "for", "given", "schema", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L39-L45
47,019
petrjasek/eve-elastic
eve_elastic/elastic.py
format_doc
def format_doc(hit, schema, dates): """Format given doc to match given schema.""" doc = hit.get('_source', {}) doc.setdefault(config.ID_FIELD, hit.get('_id')) doc.setdefault('_type', hit.get('_type')) if hit.get('highlight'): doc['es_highlight'] = hit.get('highlight') if hit.get('inner_...
python
def format_doc(hit, schema, dates): """Format given doc to match given schema.""" doc = hit.get('_source', {}) doc.setdefault(config.ID_FIELD, hit.get('_id')) doc.setdefault('_type', hit.get('_type')) if hit.get('highlight'): doc['es_highlight'] = hit.get('highlight') if hit.get('inner_...
[ "def", "format_doc", "(", "hit", ",", "schema", ",", "dates", ")", ":", "doc", "=", "hit", ".", "get", "(", "'_source'", ",", "{", "}", ")", "doc", ".", "setdefault", "(", "config", ".", "ID_FIELD", ",", "hit", ".", "get", "(", "'_id'", ")", ")",...
Format given doc to match given schema.
[ "Format", "given", "doc", "to", "match", "given", "schema", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L48-L67
47,020
petrjasek/eve-elastic
eve_elastic/elastic.py
set_filters
def set_filters(query, base_filters): """Put together all filters we have and set them as 'and' filter within filtered query. :param query: elastic query being constructed :param base_filters: all filters set outside of query (eg. resource config, sub_resource_lookup) """ filters = [f for f in ...
python
def set_filters(query, base_filters): """Put together all filters we have and set them as 'and' filter within filtered query. :param query: elastic query being constructed :param base_filters: all filters set outside of query (eg. resource config, sub_resource_lookup) """ filters = [f for f in ...
[ "def", "set_filters", "(", "query", ",", "base_filters", ")", ":", "filters", "=", "[", "f", "for", "f", "in", "base_filters", "if", "f", "is", "not", "None", "]", "query_filter", "=", "query", "[", "'query'", "]", "[", "'filtered'", "]", ".", "get", ...
Put together all filters we have and set them as 'and' filter within filtered query. :param query: elastic query being constructed :param base_filters: all filters set outside of query (eg. resource config, sub_resource_lookup)
[ "Put", "together", "all", "filters", "we", "have", "and", "set", "them", "as", "and", "filter", "within", "filtered", "query", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L154-L169
47,021
petrjasek/eve-elastic
eve_elastic/elastic.py
get_es
def get_es(url, **kwargs): """Create elasticsearch client instance. :param url: elasticsearch url """ urls = [url] if isinstance(url, str) else url kwargs.setdefault('serializer', ElasticJSONSerializer()) es = elasticsearch.Elasticsearch(urls, **kwargs) return es
python
def get_es(url, **kwargs): """Create elasticsearch client instance. :param url: elasticsearch url """ urls = [url] if isinstance(url, str) else url kwargs.setdefault('serializer', ElasticJSONSerializer()) es = elasticsearch.Elasticsearch(urls, **kwargs) return es
[ "def", "get_es", "(", "url", ",", "*", "*", "kwargs", ")", ":", "urls", "=", "[", "url", "]", "if", "isinstance", "(", "url", ",", "str", ")", "else", "url", "kwargs", ".", "setdefault", "(", "'serializer'", ",", "ElasticJSONSerializer", "(", ")", ")...
Create elasticsearch client instance. :param url: elasticsearch url
[ "Create", "elasticsearch", "client", "instance", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L179-L187
47,022
petrjasek/eve-elastic
eve_elastic/elastic.py
build_elastic_query
def build_elastic_query(doc): """ Build a query which follows ElasticSearch syntax from doc. 1. Converts {"q":"cricket"} to the below elastic query:: { "query": { "filtered": { "query": { "query_string": { ...
python
def build_elastic_query(doc): """ Build a query which follows ElasticSearch syntax from doc. 1. Converts {"q":"cricket"} to the below elastic query:: { "query": { "filtered": { "query": { "query_string": { ...
[ "def", "build_elastic_query", "(", "doc", ")", ":", "elastic_query", ",", "filters", "=", "{", "\"query\"", ":", "{", "\"filtered\"", ":", "{", "}", "}", "}", ",", "[", "]", "for", "key", "in", "doc", ".", "keys", "(", ")", ":", "if", "key", "==", ...
Build a query which follows ElasticSearch syntax from doc. 1. Converts {"q":"cricket"} to the below elastic query:: { "query": { "filtered": { "query": { "query_string": { "query": "cricket", ...
[ "Build", "a", "query", "which", "follows", "ElasticSearch", "syntax", "from", "doc", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L832-L892
47,023
petrjasek/eve-elastic
eve_elastic/elastic.py
_build_query_string
def _build_query_string(q, default_field=None, default_operator='AND'): """ Build ``query_string`` object from ``q``. :param q: q of type String :param default_field: default_field :return: dictionary object. """ def _is_phrase_search(query_string): clean_query = query_string.strip(...
python
def _build_query_string(q, default_field=None, default_operator='AND'): """ Build ``query_string`` object from ``q``. :param q: q of type String :param default_field: default_field :return: dictionary object. """ def _is_phrase_search(query_string): clean_query = query_string.strip(...
[ "def", "_build_query_string", "(", "q", ",", "default_field", "=", "None", ",", "default_operator", "=", "'AND'", ")", ":", "def", "_is_phrase_search", "(", "query_string", ")", ":", "clean_query", "=", "query_string", ".", "strip", "(", ")", "return", "clean_...
Build ``query_string`` object from ``q``. :param q: q of type String :param default_field: default_field :return: dictionary object.
[ "Build", "query_string", "object", "from", "q", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L895-L916
47,024
petrjasek/eve-elastic
eve_elastic/elastic.py
ElasticJSONSerializer.default
def default(self, value): """Convert mongo.ObjectId.""" if isinstance(value, ObjectId): return str(value) return super(ElasticJSONSerializer, self).default(value)
python
def default(self, value): """Convert mongo.ObjectId.""" if isinstance(value, ObjectId): return str(value) return super(ElasticJSONSerializer, self).default(value)
[ "def", "default", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "ObjectId", ")", ":", "return", "str", "(", "value", ")", "return", "super", "(", "ElasticJSONSerializer", ",", "self", ")", ".", "default", "(", "value", ")"...
Convert mongo.ObjectId.
[ "Convert", "mongo", ".", "ObjectId", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L118-L122
47,025
petrjasek/eve-elastic
eve_elastic/elastic.py
ElasticCursor.extra
def extra(self, response): """Add extra info to response.""" if 'facets' in self.hits: response['_facets'] = self.hits['facets'] if 'aggregations' in self.hits: response['_aggregations'] = self.hits['aggregations']
python
def extra(self, response): """Add extra info to response.""" if 'facets' in self.hits: response['_facets'] = self.hits['facets'] if 'aggregations' in self.hits: response['_aggregations'] = self.hits['aggregations']
[ "def", "extra", "(", "self", ",", "response", ")", ":", "if", "'facets'", "in", "self", ".", "hits", ":", "response", "[", "'_facets'", "]", "=", "self", ".", "hits", "[", "'facets'", "]", "if", "'aggregations'", "in", "self", ".", "hits", ":", "resp...
Add extra info to response.
[ "Add", "extra", "info", "to", "response", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L146-L151
47,026
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.init_index
def init_index(self, app=None): """Create indexes and put mapping.""" elasticindexes = self._get_indexes() for index, settings in elasticindexes.items(): es = settings['resource'] if not es.indices.exists(index): self.create_index(index, settings.get('ind...
python
def init_index(self, app=None): """Create indexes and put mapping.""" elasticindexes = self._get_indexes() for index, settings in elasticindexes.items(): es = settings['resource'] if not es.indices.exists(index): self.create_index(index, settings.get('ind...
[ "def", "init_index", "(", "self", ",", "app", "=", "None", ")", ":", "elasticindexes", "=", "self", ".", "_get_indexes", "(", ")", "for", "index", ",", "settings", "in", "elasticindexes", ".", "items", "(", ")", ":", "es", "=", "settings", "[", "'resou...
Create indexes and put mapping.
[ "Create", "indexes", "and", "put", "mapping", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L221-L237
47,027
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._get_indexes
def _get_indexes(self): """Based on the resource definition calculates the index definition""" indexes = {} for resource in self._get_elastic_resources(): try: index = self._resource_index(resource) except KeyError: # ignore missing conti...
python
def _get_indexes(self): """Based on the resource definition calculates the index definition""" indexes = {} for resource in self._get_elastic_resources(): try: index = self._resource_index(resource) except KeyError: # ignore missing conti...
[ "def", "_get_indexes", "(", "self", ")", ":", "indexes", "=", "{", "}", "for", "resource", "in", "self", ".", "_get_elastic_resources", "(", ")", ":", "try", ":", "index", "=", "self", ".", "_resource_index", "(", "resource", ")", "except", "KeyError", "...
Based on the resource definition calculates the index definition
[ "Based", "on", "the", "resource", "definition", "calculates", "the", "index", "definition" ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L239-L268
47,028
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._get_mapping
def _get_mapping(self, schema): """Get mapping for given resource or item schema. :param schema: resource or dict/list type item schema """ properties = {} for field, field_schema in schema.items(): field_mapping = self._get_field_mapping(field_schema) if...
python
def _get_mapping(self, schema): """Get mapping for given resource or item schema. :param schema: resource or dict/list type item schema """ properties = {} for field, field_schema in schema.items(): field_mapping = self._get_field_mapping(field_schema) if...
[ "def", "_get_mapping", "(", "self", ",", "schema", ")", ":", "properties", "=", "{", "}", "for", "field", ",", "field_schema", "in", "schema", ".", "items", "(", ")", ":", "field_mapping", "=", "self", ".", "_get_field_mapping", "(", "field_schema", ")", ...
Get mapping for given resource or item schema. :param schema: resource or dict/list type item schema
[ "Get", "mapping", "for", "given", "resource", "or", "item", "schema", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L275-L285
47,029
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._get_field_mapping
def _get_field_mapping(self, schema): """Get mapping for single field schema. :param schema: field schema """ if 'mapping' in schema: return schema['mapping'] elif schema['type'] == 'dict' and 'schema' in schema: return self._get_mapping(schema['schema'])...
python
def _get_field_mapping(self, schema): """Get mapping for single field schema. :param schema: field schema """ if 'mapping' in schema: return schema['mapping'] elif schema['type'] == 'dict' and 'schema' in schema: return self._get_mapping(schema['schema'])...
[ "def", "_get_field_mapping", "(", "self", ",", "schema", ")", ":", "if", "'mapping'", "in", "schema", ":", "return", "schema", "[", "'mapping'", "]", "elif", "schema", "[", "'type'", "]", "==", "'dict'", "and", "'schema'", "in", "schema", ":", "return", ...
Get mapping for single field schema. :param schema: field schema
[ "Get", "mapping", "for", "single", "field", "schema", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L287-L301
47,030
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.create_index
def create_index(self, index=None, settings=None, es=None): """Create new index and ignore if it exists already.""" if index is None: index = self.index if es is None: es = self.es try: alias = index index = generate_index_name(alias) ...
python
def create_index(self, index=None, settings=None, es=None): """Create new index and ignore if it exists already.""" if index is None: index = self.index if es is None: es = self.es try: alias = index index = generate_index_name(alias) ...
[ "def", "create_index", "(", "self", ",", "index", "=", "None", ",", "settings", "=", "None", ",", "es", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "self", ".", "index", "if", "es", "is", "None", ":", "es", "=", "self",...
Create new index and ignore if it exists already.
[ "Create", "new", "index", "and", "ignore", "if", "it", "exists", "already", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L303-L321
47,031
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.put_mapping
def put_mapping(self, app, index=None): """Put mapping for elasticsearch for current schema. It's not called automatically now, but rather left for user to call it whenever it makes sense. """ for resource, resource_config in self._get_elastic_resources().items(): datasource...
python
def put_mapping(self, app, index=None): """Put mapping for elasticsearch for current schema. It's not called automatically now, but rather left for user to call it whenever it makes sense. """ for resource, resource_config in self._get_elastic_resources().items(): datasource...
[ "def", "put_mapping", "(", "self", ",", "app", ",", "index", "=", "None", ")", ":", "for", "resource", ",", "resource_config", "in", "self", ".", "_get_elastic_resources", "(", ")", ".", "items", "(", ")", ":", "datasource", "=", "resource_config", ".", ...
Put mapping for elasticsearch for current schema. It's not called automatically now, but rather left for user to call it whenever it makes sense.
[ "Put", "mapping", "for", "elasticsearch", "for", "current", "schema", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L375-L400
47,032
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.get_mapping
def get_mapping(self, index, doc_type=None): """Get mapping for index. :param index: index name """ mapping = self.es.indices.get_mapping(index=index, doc_type=doc_type) return next(iter(mapping.values()))
python
def get_mapping(self, index, doc_type=None): """Get mapping for index. :param index: index name """ mapping = self.es.indices.get_mapping(index=index, doc_type=doc_type) return next(iter(mapping.values()))
[ "def", "get_mapping", "(", "self", ",", "index", ",", "doc_type", "=", "None", ")", ":", "mapping", "=", "self", ".", "es", ".", "indices", ".", "get_mapping", "(", "index", "=", "index", ",", "doc_type", "=", "doc_type", ")", "return", "next", "(", ...
Get mapping for index. :param index: index name
[ "Get", "mapping", "for", "index", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L402-L408
47,033
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.get_settings
def get_settings(self, index): """Get settings for index. :param index: index name """ settings = self.es.indices.get_settings(index=index) return next(iter(settings.values()))
python
def get_settings(self, index): """Get settings for index. :param index: index name """ settings = self.es.indices.get_settings(index=index) return next(iter(settings.values()))
[ "def", "get_settings", "(", "self", ",", "index", ")", ":", "settings", "=", "self", ".", "es", ".", "indices", ".", "get_settings", "(", "index", "=", "index", ")", "return", "next", "(", "iter", "(", "settings", ".", "values", "(", ")", ")", ")" ]
Get settings for index. :param index: index name
[ "Get", "settings", "for", "index", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L410-L416
47,034
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.get_index_by_alias
def get_index_by_alias(self, alias): """Get index name for given alias. If there is no alias assume it's an index. :param alias: alias name """ try: info = self.es.indices.get_alias(name=alias) return next(iter(info.keys())) except elasticsearch....
python
def get_index_by_alias(self, alias): """Get index name for given alias. If there is no alias assume it's an index. :param alias: alias name """ try: info = self.es.indices.get_alias(name=alias) return next(iter(info.keys())) except elasticsearch....
[ "def", "get_index_by_alias", "(", "self", ",", "alias", ")", ":", "try", ":", "info", "=", "self", ".", "es", ".", "indices", ".", "get_alias", "(", "name", "=", "alias", ")", "return", "next", "(", "iter", "(", "info", ".", "keys", "(", ")", ")", ...
Get index name for given alias. If there is no alias assume it's an index. :param alias: alias name
[ "Get", "index", "name", "for", "given", "alias", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L418-L429
47,035
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.should_aggregate
def should_aggregate(self, req): """Check the environment variable and the given argument parameter to decide if aggregations needed. argument value is expected to be '0' or '1' """ try: return self.app.config.get('ELASTICSEARCH_AUTO_AGGREGATIONS') or \ bo...
python
def should_aggregate(self, req): """Check the environment variable and the given argument parameter to decide if aggregations needed. argument value is expected to be '0' or '1' """ try: return self.app.config.get('ELASTICSEARCH_AUTO_AGGREGATIONS') or \ bo...
[ "def", "should_aggregate", "(", "self", ",", "req", ")", ":", "try", ":", "return", "self", ".", "app", ".", "config", ".", "get", "(", "'ELASTICSEARCH_AUTO_AGGREGATIONS'", ")", "or", "bool", "(", "req", ".", "args", "and", "int", "(", "req", ".", "arg...
Check the environment variable and the given argument parameter to decide if aggregations needed. argument value is expected to be '0' or '1'
[ "Check", "the", "environment", "variable", "and", "the", "given", "argument", "parameter", "to", "decide", "if", "aggregations", "needed", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L513-L522
47,036
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.should_highlight
def should_highlight(self, req): """ Check the given argument parameter to decide if highlights needed. argument value is expected to be '0' or '1' """ try: return bool(req.args and int(req.args.get('es_highlight', 0))) except (AttributeError, TypeError): ...
python
def should_highlight(self, req): """ Check the given argument parameter to decide if highlights needed. argument value is expected to be '0' or '1' """ try: return bool(req.args and int(req.args.get('es_highlight', 0))) except (AttributeError, TypeError): ...
[ "def", "should_highlight", "(", "self", ",", "req", ")", ":", "try", ":", "return", "bool", "(", "req", ".", "args", "and", "int", "(", "req", ".", "args", ".", "get", "(", "'es_highlight'", ",", "0", ")", ")", ")", "except", "(", "AttributeError", ...
Check the given argument parameter to decide if highlights needed. argument value is expected to be '0' or '1'
[ "Check", "the", "given", "argument", "parameter", "to", "decide", "if", "highlights", "needed", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L524-L533
47,037
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.should_project
def should_project(self, req): """ Check the given argument parameter to decide if projections needed. argument value is expected to be a list of strings """ try: return req.args and json.loads(req.args.get('projections', [])) except (AttributeError, TypeErro...
python
def should_project(self, req): """ Check the given argument parameter to decide if projections needed. argument value is expected to be a list of strings """ try: return req.args and json.loads(req.args.get('projections', [])) except (AttributeError, TypeErro...
[ "def", "should_project", "(", "self", ",", "req", ")", ":", "try", ":", "return", "req", ".", "args", "and", "json", ".", "loads", "(", "req", ".", "args", ".", "get", "(", "'projections'", ",", "[", "]", ")", ")", "except", "(", "AttributeError", ...
Check the given argument parameter to decide if projections needed. argument value is expected to be a list of strings
[ "Check", "the", "given", "argument", "parameter", "to", "decide", "if", "projections", "needed", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L535-L544
47,038
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.get_projected_fields
def get_projected_fields(self, req): """ Returns the projected fields from request. """ try: args = getattr(req, 'args', {}) return ','.join(json.loads(args.get('projections'))) except (AttributeError, TypeError): return None
python
def get_projected_fields(self, req): """ Returns the projected fields from request. """ try: args = getattr(req, 'args', {}) return ','.join(json.loads(args.get('projections'))) except (AttributeError, TypeError): return None
[ "def", "get_projected_fields", "(", "self", ",", "req", ")", ":", "try", ":", "args", "=", "getattr", "(", "req", ",", "'args'", ",", "{", "}", ")", "return", "','", ".", "join", "(", "json", ".", "loads", "(", "args", ".", "get", "(", "'projection...
Returns the projected fields from request.
[ "Returns", "the", "projected", "fields", "from", "request", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L546-L555
47,039
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.find_one
def find_one(self, resource, req, **lookup): """Find single document, if there is _id in lookup use that, otherwise filter.""" if config.ID_FIELD in lookup: return self._find_by_id(resource=resource, _id=lookup[config.ID_FIELD], parent=lookup.get('parent')) else: args = ...
python
def find_one(self, resource, req, **lookup): """Find single document, if there is _id in lookup use that, otherwise filter.""" if config.ID_FIELD in lookup: return self._find_by_id(resource=resource, _id=lookup[config.ID_FIELD], parent=lookup.get('parent')) else: args = ...
[ "def", "find_one", "(", "self", ",", "resource", ",", "req", ",", "*", "*", "lookup", ")", ":", "if", "config", ".", "ID_FIELD", "in", "lookup", ":", "return", "self", ".", "_find_by_id", "(", "resource", "=", "resource", ",", "_id", "=", "lookup", "...
Find single document, if there is _id in lookup use that, otherwise filter.
[ "Find", "single", "document", "if", "there", "is", "_id", "in", "lookup", "use", "that", "otherwise", "filter", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L557-L573
47,040
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._find_by_id
def _find_by_id(self, resource, _id, parent=None): """Find the document by Id. If parent is not provided then on routing exception try to find using search. """ def is_found(hit): if 'exists' in hit: hit['found'] = hit['exists'] return hit.get('fou...
python
def _find_by_id(self, resource, _id, parent=None): """Find the document by Id. If parent is not provided then on routing exception try to find using search. """ def is_found(hit): if 'exists' in hit: hit['found'] = hit['exists'] return hit.get('fou...
[ "def", "_find_by_id", "(", "self", ",", "resource", ",", "_id", ",", "parent", "=", "None", ")", ":", "def", "is_found", "(", "hit", ")", ":", "if", "'exists'", "in", "hit", ":", "hit", "[", "'found'", "]", "=", "hit", "[", "'exists'", "]", "return...
Find the document by Id. If parent is not provided then on routing exception try to find using search.
[ "Find", "the", "document", "by", "Id", ".", "If", "parent", "is", "not", "provided", "then", "on", "routing", "exception", "try", "to", "find", "using", "search", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L575-L611
47,041
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.find_one_raw
def find_one_raw(self, resource, _id): """Find document by id.""" return self._find_by_id(resource=resource, _id=_id)
python
def find_one_raw(self, resource, _id): """Find document by id.""" return self._find_by_id(resource=resource, _id=_id)
[ "def", "find_one_raw", "(", "self", ",", "resource", ",", "_id", ")", ":", "return", "self", ".", "_find_by_id", "(", "resource", "=", "resource", ",", "_id", "=", "_id", ")" ]
Find document by id.
[ "Find", "document", "by", "id", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L613-L615
47,042
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.find_list_of_ids
def find_list_of_ids(self, resource, ids, client_projection=None): """Find documents by ids.""" args = self._es_args(resource) return self._parse_hits(self.elastic(resource).mget(body={'ids': ids}, **args), resource)
python
def find_list_of_ids(self, resource, ids, client_projection=None): """Find documents by ids.""" args = self._es_args(resource) return self._parse_hits(self.elastic(resource).mget(body={'ids': ids}, **args), resource)
[ "def", "find_list_of_ids", "(", "self", ",", "resource", ",", "ids", ",", "client_projection", "=", "None", ")", ":", "args", "=", "self", ".", "_es_args", "(", "resource", ")", "return", "self", ".", "_parse_hits", "(", "self", ".", "elastic", "(", "res...
Find documents by ids.
[ "Find", "documents", "by", "ids", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L617-L620
47,043
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.insert
def insert(self, resource, doc_or_docs, **kwargs): """Insert document, it must be new if there is ``_id`` in it.""" ids = [] kwargs.update(self._es_args(resource)) for doc in doc_or_docs: self._update_parent_args(resource, kwargs, doc) _id = doc.pop('_id', None) ...
python
def insert(self, resource, doc_or_docs, **kwargs): """Insert document, it must be new if there is ``_id`` in it.""" ids = [] kwargs.update(self._es_args(resource)) for doc in doc_or_docs: self._update_parent_args(resource, kwargs, doc) _id = doc.pop('_id', None) ...
[ "def", "insert", "(", "self", ",", "resource", ",", "doc_or_docs", ",", "*", "*", "kwargs", ")", ":", "ids", "=", "[", "]", "kwargs", ".", "update", "(", "self", ".", "_es_args", "(", "resource", ")", ")", "for", "doc", "in", "doc_or_docs", ":", "s...
Insert document, it must be new if there is ``_id`` in it.
[ "Insert", "document", "it", "must", "be", "new", "if", "there", "is", "_id", "in", "it", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L622-L633
47,044
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.bulk_insert
def bulk_insert(self, resource, docs, **kwargs): """Bulk insert documents.""" kwargs.update(self._es_args(resource)) parent_type = self._get_parent_type(resource) if parent_type: for doc in docs: if doc.get(parent_type.get('field')): doc['_...
python
def bulk_insert(self, resource, docs, **kwargs): """Bulk insert documents.""" kwargs.update(self._es_args(resource)) parent_type = self._get_parent_type(resource) if parent_type: for doc in docs: if doc.get(parent_type.get('field')): doc['_...
[ "def", "bulk_insert", "(", "self", ",", "resource", ",", "docs", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_es_args", "(", "resource", ")", ")", "parent_type", "=", "self", ".", "_get_parent_type", "(", "resource", ...
Bulk insert documents.
[ "Bulk", "insert", "documents", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L635-L646
47,045
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.update
def update(self, resource, id_, updates): """Update document in index.""" args = self._es_args(resource, refresh=True) if self._get_retry_on_conflict(): args['retry_on_conflict'] = self._get_retry_on_conflict() updates.pop('_id', None) updates.pop('_type', None) ...
python
def update(self, resource, id_, updates): """Update document in index.""" args = self._es_args(resource, refresh=True) if self._get_retry_on_conflict(): args['retry_on_conflict'] = self._get_retry_on_conflict() updates.pop('_id', None) updates.pop('_type', None) ...
[ "def", "update", "(", "self", ",", "resource", ",", "id_", ",", "updates", ")", ":", "args", "=", "self", ".", "_es_args", "(", "resource", ",", "refresh", "=", "True", ")", "if", "self", ".", "_get_retry_on_conflict", "(", ")", ":", "args", "[", "'r...
Update document in index.
[ "Update", "document", "in", "index", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L648-L657
47,046
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.replace
def replace(self, resource, id_, document): """Replace document in index.""" args = self._es_args(resource, refresh=True) document.pop('_id', None) document.pop('_type', None) self._update_parent_args(resource, args, document) return self.elastic(resource).index(body=docu...
python
def replace(self, resource, id_, document): """Replace document in index.""" args = self._es_args(resource, refresh=True) document.pop('_id', None) document.pop('_type', None) self._update_parent_args(resource, args, document) return self.elastic(resource).index(body=docu...
[ "def", "replace", "(", "self", ",", "resource", ",", "id_", ",", "document", ")", ":", "args", "=", "self", ".", "_es_args", "(", "resource", ",", "refresh", "=", "True", ")", "document", ".", "pop", "(", "'_id'", ",", "None", ")", "document", ".", ...
Replace document in index.
[ "Replace", "document", "in", "index", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L659-L665
47,047
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.remove
def remove(self, resource, lookup=None, parent=None, **kwargs): """Remove docs for resource. :param resource: resource name :param lookup: filter :param parent: parent id """ kwargs.update(self._es_args(resource)) if parent: kwargs['parent'] = parent ...
python
def remove(self, resource, lookup=None, parent=None, **kwargs): """Remove docs for resource. :param resource: resource name :param lookup: filter :param parent: parent id """ kwargs.update(self._es_args(resource)) if parent: kwargs['parent'] = parent ...
[ "def", "remove", "(", "self", ",", "resource", ",", "lookup", "=", "None", ",", "parent", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_es_args", "(", "resource", ")", ")", "if", "parent", ":", "kwargs...
Remove docs for resource. :param resource: resource name :param lookup: filter :param parent: parent id
[ "Remove", "docs", "for", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L667-L684
47,048
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.is_empty
def is_empty(self, resource): """Test if there is no document for resource. :param resource: resource name """ args = self._es_args(resource) res = self.elastic(resource).count(body={'query': {'match_all': {}}}, **args) return res.get('count', 0) == 0
python
def is_empty(self, resource): """Test if there is no document for resource. :param resource: resource name """ args = self._es_args(resource) res = self.elastic(resource).count(body={'query': {'match_all': {}}}, **args) return res.get('count', 0) == 0
[ "def", "is_empty", "(", "self", ",", "resource", ")", ":", "args", "=", "self", ".", "_es_args", "(", "resource", ")", "res", "=", "self", ".", "elastic", "(", "resource", ")", ".", "count", "(", "body", "=", "{", "'query'", ":", "{", "'match_all'", ...
Test if there is no document for resource. :param resource: resource name
[ "Test", "if", "there", "is", "no", "document", "for", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L686-L693
47,049
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.put_settings
def put_settings(self, app=None, index=None, settings=None, es=None): """Modify index settings. Index must exist already. """ if not index: index = self.index if not app: app = self.app if not es: es = self.es if not setting...
python
def put_settings(self, app=None, index=None, settings=None, es=None): """Modify index settings. Index must exist already. """ if not index: index = self.index if not app: app = self.app if not es: es = self.es if not setting...
[ "def", "put_settings", "(", "self", ",", "app", "=", "None", ",", "index", "=", "None", ",", "settings", "=", "None", ",", "es", "=", "None", ")", ":", "if", "not", "index", ":", "index", "=", "self", ".", "index", "if", "not", "app", ":", "app",...
Modify index settings. Index must exist already.
[ "Modify", "index", "settings", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L695-L721
47,050
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._parse_hits
def _parse_hits(self, hits, resource): """Parse hits response into documents.""" datasource = self.get_datasource(resource) schema = {} schema.update(config.DOMAIN[datasource[0]].get('schema', {})) schema.update(config.DOMAIN[resource].get('schema', {})) dates = get_dates...
python
def _parse_hits(self, hits, resource): """Parse hits response into documents.""" datasource = self.get_datasource(resource) schema = {} schema.update(config.DOMAIN[datasource[0]].get('schema', {})) schema.update(config.DOMAIN[resource].get('schema', {})) dates = get_dates...
[ "def", "_parse_hits", "(", "self", ",", "hits", ",", "resource", ")", ":", "datasource", "=", "self", ".", "get_datasource", "(", "resource", ")", "schema", "=", "{", "}", "schema", ".", "update", "(", "config", ".", "DOMAIN", "[", "datasource", "[", "...
Parse hits response into documents.
[ "Parse", "hits", "response", "into", "documents", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L723-L733
47,051
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._es_args
def _es_args(self, resource, refresh=None, source_projections=None): """Get index and doctype args.""" datasource = self.get_datasource(resource) args = { 'index': self._resource_index(resource), 'doc_type': datasource[0], } if source_projections: ...
python
def _es_args(self, resource, refresh=None, source_projections=None): """Get index and doctype args.""" datasource = self.get_datasource(resource) args = { 'index': self._resource_index(resource), 'doc_type': datasource[0], } if source_projections: ...
[ "def", "_es_args", "(", "self", ",", "resource", ",", "refresh", "=", "None", ",", "source_projections", "=", "None", ")", ":", "datasource", "=", "self", ".", "get_datasource", "(", "resource", ")", "args", "=", "{", "'index'", ":", "self", ".", "_resou...
Get index and doctype args.
[ "Get", "index", "and", "doctype", "args", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L735-L747
47,052
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.get_parent_id
def get_parent_id(self, resource, document): """Get the Parent Id of the document :param resource: resource name :param document: document containing the parent id """ parent_type = self._get_parent_type(resource) if parent_type and document: return document....
python
def get_parent_id(self, resource, document): """Get the Parent Id of the document :param resource: resource name :param document: document containing the parent id """ parent_type = self._get_parent_type(resource) if parent_type and document: return document....
[ "def", "get_parent_id", "(", "self", ",", "resource", ",", "document", ")", ":", "parent_type", "=", "self", ".", "_get_parent_type", "(", "resource", ")", "if", "parent_type", "and", "document", ":", "return", "document", ".", "get", "(", "parent_type", "."...
Get the Parent Id of the document :param resource: resource name :param document: document containing the parent id
[ "Get", "the", "Parent", "Id", "of", "the", "document" ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L753-L763
47,053
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._fields
def _fields(self, resource): """Get projection fields for given resource.""" datasource = self.get_datasource(resource) keys = datasource[2].keys() return ','.join(keys) + ','.join([config.LAST_UPDATED, config.DATE_CREATED])
python
def _fields(self, resource): """Get projection fields for given resource.""" datasource = self.get_datasource(resource) keys = datasource[2].keys() return ','.join(keys) + ','.join([config.LAST_UPDATED, config.DATE_CREATED])
[ "def", "_fields", "(", "self", ",", "resource", ")", ":", "datasource", "=", "self", ".", "get_datasource", "(", "resource", ")", "keys", "=", "datasource", "[", "2", "]", ".", "keys", "(", ")", "return", "','", ".", "join", "(", "keys", ")", "+", ...
Get projection fields for given resource.
[ "Get", "projection", "fields", "for", "given", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L771-L775
47,054
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._resource_index
def _resource_index(self, resource): """Get index for given resource. by default it will be `self.index`, but it can be overriden via app.config :param resource: resource name """ datasource = self.get_datasource(resource) indexes = self._resource_config(resource, 'INDE...
python
def _resource_index(self, resource): """Get index for given resource. by default it will be `self.index`, but it can be overriden via app.config :param resource: resource name """ datasource = self.get_datasource(resource) indexes = self._resource_config(resource, 'INDE...
[ "def", "_resource_index", "(", "self", ",", "resource", ")", ":", "datasource", "=", "self", ".", "get_datasource", "(", "resource", ")", "indexes", "=", "self", ".", "_resource_config", "(", "resource", ",", "'INDEXES'", ")", "or", "{", "}", "default_index"...
Get index for given resource. by default it will be `self.index`, but it can be overriden via app.config :param resource: resource name
[ "Get", "index", "for", "given", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L781-L791
47,055
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._refresh_resource_index
def _refresh_resource_index(self, resource): """Refresh index for given resource. :param resource: resource name """ if self._resource_config(resource, 'FORCE_REFRESH', True): self.elastic(resource).indices.refresh(self._resource_index(resource))
python
def _refresh_resource_index(self, resource): """Refresh index for given resource. :param resource: resource name """ if self._resource_config(resource, 'FORCE_REFRESH', True): self.elastic(resource).indices.refresh(self._resource_index(resource))
[ "def", "_refresh_resource_index", "(", "self", ",", "resource", ")", ":", "if", "self", ".", "_resource_config", "(", "resource", ",", "'FORCE_REFRESH'", ",", "True", ")", ":", "self", ".", "elastic", "(", "resource", ")", ".", "indices", ".", "refresh", "...
Refresh index for given resource. :param resource: resource name
[ "Refresh", "index", "for", "given", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L793-L799
47,056
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic._resource_prefix
def _resource_prefix(self, resource=None): """Get elastic prefix for given resource. Resource can specify ``elastic_prefix`` which behaves same like ``mongo_prefix``. """ px = 'ELASTICSEARCH' if resource and config.DOMAIN[resource].get('elastic_prefix'): px = config....
python
def _resource_prefix(self, resource=None): """Get elastic prefix for given resource. Resource can specify ``elastic_prefix`` which behaves same like ``mongo_prefix``. """ px = 'ELASTICSEARCH' if resource and config.DOMAIN[resource].get('elastic_prefix'): px = config....
[ "def", "_resource_prefix", "(", "self", ",", "resource", "=", "None", ")", ":", "px", "=", "'ELASTICSEARCH'", "if", "resource", "and", "config", ".", "DOMAIN", "[", "resource", "]", ".", "get", "(", "'elastic_prefix'", ")", ":", "px", "=", "config", ".",...
Get elastic prefix for given resource. Resource can specify ``elastic_prefix`` which behaves same like ``mongo_prefix``.
[ "Get", "elastic", "prefix", "for", "given", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L801-L809
47,057
petrjasek/eve-elastic
eve_elastic/elastic.py
Elastic.elastic
def elastic(self, resource=None): """Get ElasticSearch instance for given resource.""" px = self._resource_prefix(resource) if px not in self.elastics: url = self._resource_config(resource, 'URL') assert url, 'no url for %s' % px self.elastics[px] = get_es(ur...
python
def elastic(self, resource=None): """Get ElasticSearch instance for given resource.""" px = self._resource_prefix(resource) if px not in self.elastics: url = self._resource_config(resource, 'URL') assert url, 'no url for %s' % px self.elastics[px] = get_es(ur...
[ "def", "elastic", "(", "self", ",", "resource", "=", "None", ")", ":", "px", "=", "self", ".", "_resource_prefix", "(", "resource", ")", "if", "px", "not", "in", "self", ".", "elastics", ":", "url", "=", "self", ".", "_resource_config", "(", "resource"...
Get ElasticSearch instance for given resource.
[ "Get", "ElasticSearch", "instance", "for", "given", "resource", "." ]
f146f31b348d22ac5559cf78717b3bb02efcb2d7
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L816-L825
47,058
gregreen/dustmaps
dustmaps/fetch_utils.py
get_md5sum
def get_md5sum(fname, chunk_size=1024): """ Returns the MD5 checksum of a file. Args: fname (str): Filename chunk_size (Optional[int]): Size (in Bytes) of the chunks that should be read in at once. Increasing chunk size reduces the number of reads required, but incre...
python
def get_md5sum(fname, chunk_size=1024): """ Returns the MD5 checksum of a file. Args: fname (str): Filename chunk_size (Optional[int]): Size (in Bytes) of the chunks that should be read in at once. Increasing chunk size reduces the number of reads required, but incre...
[ "def", "get_md5sum", "(", "fname", ",", "chunk_size", "=", "1024", ")", ":", "def", "iter_chunks", "(", "f", ")", ":", "while", "True", ":", "chunk", "=", "f", ".", "read", "(", "chunk_size", ")", "if", "not", "chunk", ":", "break", "yield", "chunk",...
Returns the MD5 checksum of a file. Args: fname (str): Filename chunk_size (Optional[int]): Size (in Bytes) of the chunks that should be read in at once. Increasing chunk size reduces the number of reads required, but increases the memory usage. Defaults to 1024. Return...
[ "Returns", "the", "MD5", "checksum", "of", "a", "file", "." ]
c8f571a71da0d951bf8ea865621bee14492bdfd9
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L61-L91
47,059
gregreen/dustmaps
dustmaps/fetch_utils.py
download_and_verify
def download_and_verify(url, md5sum, fname=None, chunk_size=1024, clobber=False, verbose=True): """ Download a file and verify the MD5 sum. Args: url (str): The URL to download. md5sum (str): The expected MD5 sum. fname (Optional[str])...
python
def download_and_verify(url, md5sum, fname=None, chunk_size=1024, clobber=False, verbose=True): """ Download a file and verify the MD5 sum. Args: url (str): The URL to download. md5sum (str): The expected MD5 sum. fname (Optional[str])...
[ "def", "download_and_verify", "(", "url", ",", "md5sum", ",", "fname", "=", "None", ",", "chunk_size", "=", "1024", ",", "clobber", "=", "False", ",", "verbose", "=", "True", ")", ":", "# Determine the filename", "if", "fname", "is", "None", ":", "fname", ...
Download a file and verify the MD5 sum. Args: url (str): The URL to download. md5sum (str): The expected MD5 sum. fname (Optional[str]): The filename to store the downloaded file in. If `None`, infer the filename from the URL. Defaults to `None`. chunk_size (Optional[int...
[ "Download", "a", "file", "and", "verify", "the", "MD5", "sum", "." ]
c8f571a71da0d951bf8ea865621bee14492bdfd9
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L177-L285
47,060
gregreen/dustmaps
dustmaps/fetch_utils.py
download
def download(url, fname=None): """ Downloads a file. Args: url (str): The URL to download. fname (Optional[str]): The filename to store the downloaded file in. If `None`, take the filename from the URL. Defaults to `None`. Returns: The filename the URL was downloa...
python
def download(url, fname=None): """ Downloads a file. Args: url (str): The URL to download. fname (Optional[str]): The filename to store the downloaded file in. If `None`, take the filename from the URL. Defaults to `None`. Returns: The filename the URL was downloa...
[ "def", "download", "(", "url", ",", "fname", "=", "None", ")", ":", "# Determine the filename", "if", "fname", "is", "None", ":", "fname", "=", "url", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "# Stream the URL as a file, copying to local disk", "wi...
Downloads a file. Args: url (str): The URL to download. fname (Optional[str]): The filename to store the downloaded file in. If `None`, take the filename from the URL. Defaults to `None`. Returns: The filename the URL was downloaded to. Raises: requests.excep...
[ "Downloads", "a", "file", "." ]
c8f571a71da0d951bf8ea865621bee14492bdfd9
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L288-L320
47,061
gregreen/dustmaps
dustmaps/fetch_utils.py
dataverse_download_doi
def dataverse_download_doi(doi, local_fname=None, file_requirements={}, clobber=False): """ Downloads a file from the Dataverse, using a DOI and set of metadata parameters to locate the file. Args: doi (str): Digit...
python
def dataverse_download_doi(doi, local_fname=None, file_requirements={}, clobber=False): """ Downloads a file from the Dataverse, using a DOI and set of metadata parameters to locate the file. Args: doi (str): Digit...
[ "def", "dataverse_download_doi", "(", "doi", ",", "local_fname", "=", "None", ",", "file_requirements", "=", "{", "}", ",", "clobber", "=", "False", ")", ":", "metadata", "=", "dataverse_search_doi", "(", "doi", ")", "def", "requirements_match", "(", "metadata...
Downloads a file from the Dataverse, using a DOI and set of metadata parameters to locate the file. Args: doi (str): Digital Object Identifier (DOI) containing the file. local_fname (Optional[str]): Local filename to download the file to. If `None`, then use the filename provided by...
[ "Downloads", "a", "file", "from", "the", "Dataverse", "using", "a", "DOI", "and", "set", "of", "metadata", "parameters", "to", "locate", "the", "file", "." ]
c8f571a71da0d951bf8ea865621bee14492bdfd9
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L355-L414
47,062
blockstack/virtualchain
virtualchain/lib/blockchain/address.py
address_reencode
def address_reencode(address, blockchain='bitcoin', **blockchain_opts): """ Reencode an address """ if blockchain == 'bitcoin': return btc_address_reencode(address, **blockchain_opts) else: raise ValueError("Unknown blockchain '{}'".format(blockchain))
python
def address_reencode(address, blockchain='bitcoin', **blockchain_opts): """ Reencode an address """ if blockchain == 'bitcoin': return btc_address_reencode(address, **blockchain_opts) else: raise ValueError("Unknown blockchain '{}'".format(blockchain))
[ "def", "address_reencode", "(", "address", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_address_reencode", "(", "address", ",", "*", "*", "blockchain_opts", ")", "el...
Reencode an address
[ "Reencode", "an", "address" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/address.py#L25-L32
47,063
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_multisig
def is_multisig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a multisig bundle? """ if blockchain == 'bitcoin': return btc_is_multisig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_multisig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a multisig bundle? """ if blockchain == 'bitcoin': return btc_is_multisig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_multisig", "(", "privkey_info", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_multisig", "(", "privkey_info", ",", "*", "*", "blockchain_opts", ")", "el...
Is the given private key bundle a multisig bundle?
[ "Is", "the", "given", "private", "key", "bundle", "a", "multisig", "bundle?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L28-L35
47,064
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_multisig_address
def is_multisig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a multisig address? """ if blockchain == 'bitcoin': return btc_is_multisig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_multisig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a multisig address? """ if blockchain == 'bitcoin': return btc_is_multisig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_multisig_address", "(", "addr", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_multisig_address", "(", "addr", ",", "*", "*", "blockchain_opts", ")", "el...
Is the given address a multisig address?
[ "Is", "the", "given", "address", "a", "multisig", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L38-L45
47,065
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_multisig_script
def is_multisig_script(script, blockchain='bitcoin', **blockchain_opts): """ Is the given script a multisig script? """ if blockchain == 'bitcoin': return btc_is_multisig_script(script, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_multisig_script(script, blockchain='bitcoin', **blockchain_opts): """ Is the given script a multisig script? """ if blockchain == 'bitcoin': return btc_is_multisig_script(script, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_multisig_script", "(", "script", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_multisig_script", "(", "script", ",", "*", "*", "blockchain_opts", ")", "...
Is the given script a multisig script?
[ "Is", "the", "given", "script", "a", "multisig", "script?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L48-L55
47,066
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_singlesig
def is_singlesig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a single-sig key bundle? """ if blockchain == 'bitcoin': return btc_is_singlesig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(block...
python
def is_singlesig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a single-sig key bundle? """ if blockchain == 'bitcoin': return btc_is_singlesig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(block...
[ "def", "is_singlesig", "(", "privkey_info", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_singlesig", "(", "privkey_info", ",", "*", "*", "blockchain_opts", ")", "...
Is the given private key bundle a single-sig key bundle?
[ "Is", "the", "given", "private", "key", "bundle", "a", "single", "-", "sig", "key", "bundle?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L58-L65
47,067
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_singlesig_address
def is_singlesig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a single-sig address? """ if blockchain == 'bitcoin': return btc_is_singlesig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_singlesig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a single-sig address? """ if blockchain == 'bitcoin': return btc_is_singlesig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_singlesig_address", "(", "addr", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_singlesig_address", "(", "addr", ",", "*", "*", "blockchain_opts", ")", "...
Is the given address a single-sig address?
[ "Is", "the", "given", "address", "a", "single", "-", "sig", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L78-L85
47,068
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
get_privkey_address
def get_privkey_address(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Get the address from a private key bundle """ if blockchain == 'bitcoin': return btc_get_privkey_address(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockc...
python
def get_privkey_address(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Get the address from a private key bundle """ if blockchain == 'bitcoin': return btc_get_privkey_address(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockc...
[ "def", "get_privkey_address", "(", "privkey_info", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_get_privkey_address", "(", "privkey_info", ",", "*", "*", "blockchain_opt...
Get the address from a private key bundle
[ "Get", "the", "address", "from", "a", "private", "key", "bundle" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L88-L95
47,069
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/zmat_functions.py
apply_grad_cartesian_tensor
def apply_grad_cartesian_tensor(grad_X, zmat_dist): """Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesi...
python
def apply_grad_cartesian_tensor(grad_X, zmat_dist): """Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesi...
[ "def", "apply_grad_cartesian_tensor", "(", "grad_X", ",", "zmat_dist", ")", ":", "columns", "=", "[", "'bond'", ",", "'angle'", ",", "'dihedral'", "]", "C_dist", "=", "zmat_dist", ".", "loc", "[", ":", ",", "columns", "]", ".", "values", ".", "T", "try",...
Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesian.get_grad_zmat()`. zmat_dist (:class:`~chemcoord....
[ "Apply", "the", "gradient", "for", "transformation", "to", "cartesian", "space", "onto", "zmat_dist", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/zmat_functions.py#L75-L98
47,070
anjianshi/flask-restful-extend
flask_restful_extend/model_converter.py
register_model_converter
def register_model_converter(model, app): """Add url converter for model Example: class Student(db.model): id = Column(Integer, primary_key=True) name = Column(String(50)) register_model_converter(Student) @route('/classmates/<Student:classmate>') def ...
python
def register_model_converter(model, app): """Add url converter for model Example: class Student(db.model): id = Column(Integer, primary_key=True) name = Column(String(50)) register_model_converter(Student) @route('/classmates/<Student:classmate>') def ...
[ "def", "register_model_converter", "(", "model", ",", "app", ")", ":", "if", "hasattr", "(", "model", ",", "'id'", ")", ":", "class", "Converter", "(", "_ModelConverter", ")", ":", "_model", "=", "model", "app", ".", "url_map", ".", "converters", "[", "m...
Add url converter for model Example: class Student(db.model): id = Column(Integer, primary_key=True) name = Column(String(50)) register_model_converter(Student) @route('/classmates/<Student:classmate>') def get_classmate_info(classmate): pass ...
[ "Add", "url", "converter", "for", "model" ]
cc168729bf341d4f9c0f6938be30463acbf770f1
https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/model_converter.py#L6-L26
47,071
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.iupacify
def iupacify(self): """Give the IUPAC conform representation. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\\sim` and use :math:`\\alpha` for an angle and :math:`\\delta` for a dih...
python
def iupacify(self): """Give the IUPAC conform representation. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\\sim` and use :math:`\\alpha` for an angle and :math:`\\delta` for a dih...
[ "def", "iupacify", "(", "self", ")", ":", "def", "convert_d", "(", "d", ")", ":", "r", "=", "d", "%", "360", "return", "r", "-", "(", "r", "//", "180", ")", "*", "360", "new", "=", "self", ".", "copy", "(", ")", "new", ".", "unsafe_loc", "[",...
Give the IUPAC conform representation. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\\sim` and use :math:`\\alpha` for an angle and :math:`\\delta` for a dihedral angle. Then the f...
[ "Give", "the", "IUPAC", "conform", "representation", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L280-L321
47,072
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.minimize_dihedrals
def minimize_dihedrals(self): r"""Give a representation of the dihedral with minimized absolute value. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\sim` and use :math:`\alpha` for...
python
def minimize_dihedrals(self): r"""Give a representation of the dihedral with minimized absolute value. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\sim` and use :math:`\alpha` for...
[ "def", "minimize_dihedrals", "(", "self", ")", ":", "new", "=", "self", ".", "copy", "(", ")", "def", "convert_d", "(", "d", ")", ":", "r", "=", "d", "%", "360", "return", "r", "-", "(", "r", "//", "180", ")", "*", "360", "new", ".", "unsafe_lo...
r"""Give a representation of the dihedral with minimized absolute value. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\sim` and use :math:`\alpha` for an angle and :math:`\delta` for a dih...
[ "r", "Give", "a", "representation", "of", "the", "dihedral", "with", "minimized", "absolute", "value", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L323-L372
47,073
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.change_numbering
def change_numbering(self, new_index=None): """Change numbering to a new index. Changes the numbering of index and all dependent numbering (bond_with...) to a new_index. The user has to make sure that the new_index consists of distinct elements. Args: ...
python
def change_numbering(self, new_index=None): """Change numbering to a new index. Changes the numbering of index and all dependent numbering (bond_with...) to a new_index. The user has to make sure that the new_index consists of distinct elements. Args: ...
[ "def", "change_numbering", "(", "self", ",", "new_index", "=", "None", ")", ":", "if", "(", "new_index", "is", "None", ")", ":", "new_index", "=", "range", "(", "len", "(", "self", ")", ")", "elif", "len", "(", "new_index", ")", "!=", "len", "(", "...
Change numbering to a new index. Changes the numbering of index and all dependent numbering (bond_with...) to a new_index. The user has to make sure that the new_index consists of distinct elements. Args: new_index (list): If None the new_index is taken from...
[ "Change", "numbering", "to", "a", "new", "index", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L445-L491
47,074
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore._insert_dummy_cart
def _insert_dummy_cart(self, exception, last_valid_cartesian=None): """Insert dummy atom into the already built cartesian of exception """ def get_normal_vec(cartesian, reference_labels): b_pos, a_pos, d_pos = cartesian._get_positions(reference_labels) BA = a_pos - b_pos ...
python
def _insert_dummy_cart(self, exception, last_valid_cartesian=None): """Insert dummy atom into the already built cartesian of exception """ def get_normal_vec(cartesian, reference_labels): b_pos, a_pos, d_pos = cartesian._get_positions(reference_labels) BA = a_pos - b_pos ...
[ "def", "_insert_dummy_cart", "(", "self", ",", "exception", ",", "last_valid_cartesian", "=", "None", ")", ":", "def", "get_normal_vec", "(", "cartesian", ",", "reference_labels", ")", ":", "b_pos", ",", "a_pos", ",", "d_pos", "=", "cartesian", ".", "_get_posi...
Insert dummy atom into the already built cartesian of exception
[ "Insert", "dummy", "atom", "into", "the", "already", "built", "cartesian", "of", "exception" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L493-L519
47,075
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.get_cartesian
def get_cartesian(self): """Return the molecule in cartesian coordinates. Raises an :class:`~exceptions.InvalidReference` exception, if the reference of the i-th atom is undefined. Args: None Returns: Cartesian: Reindexed version of the zmatrix. ...
python
def get_cartesian(self): """Return the molecule in cartesian coordinates. Raises an :class:`~exceptions.InvalidReference` exception, if the reference of the i-th atom is undefined. Args: None Returns: Cartesian: Reindexed version of the zmatrix. ...
[ "def", "get_cartesian", "(", "self", ")", ":", "def", "create_cartesian", "(", "positions", ",", "row", ")", ":", "xyz_frame", "=", "pd", ".", "DataFrame", "(", "columns", "=", "[", "'atom'", ",", "'x'", ",", "'y'", ",", "'z'", "]", ",", "index", "="...
Return the molecule in cartesian coordinates. Raises an :class:`~exceptions.InvalidReference` exception, if the reference of the i-th atom is undefined. Args: None Returns: Cartesian: Reindexed version of the zmatrix.
[ "Return", "the", "molecule", "in", "cartesian", "coordinates", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L620-L661
47,076
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.get_grad_cartesian
def get_grad_cartesian(self, as_function=True, chain=True, drop_auto_dummies=True): r"""Return the gradient for the transformation to a Cartesian. If ``as_function`` is True, a function is returned that can be directly applied onto instances of :class:`~Zmat`, which c...
python
def get_grad_cartesian(self, as_function=True, chain=True, drop_auto_dummies=True): r"""Return the gradient for the transformation to a Cartesian. If ``as_function`` is True, a function is returned that can be directly applied onto instances of :class:`~Zmat`, which c...
[ "def", "get_grad_cartesian", "(", "self", ",", "as_function", "=", "True", ",", "chain", "=", "True", ",", "drop_auto_dummies", "=", "True", ")", ":", "zmat", "=", "self", ".", "change_numbering", "(", ")", "c_table", "=", "zmat", ".", "loc", "[", ":", ...
r"""Return the gradient for the transformation to a Cartesian. If ``as_function`` is True, a function is returned that can be directly applied onto instances of :class:`~Zmat`, which contain the applied distortions in Zmatrix space. In this case the user does not have to worry about ind...
[ "r", "Return", "the", "gradient", "for", "the", "transformation", "to", "a", "Cartesian", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L663-L778
47,077
blockstack/virtualchain
virtualchain/lib/blockchain/transactions.py
tx_extend
def tx_extend(partial_tx_hex, new_inputs, new_outputs, blockchain='bitcoin', **blockchain_opts): """ Add a set of inputs and outputs to a tx. Return the new tx on success Raise on error """ if blockchain == 'bitcoin': return btc_tx_extend(partial_tx_hex, new_inputs, new_outputs, **blockc...
python
def tx_extend(partial_tx_hex, new_inputs, new_outputs, blockchain='bitcoin', **blockchain_opts): """ Add a set of inputs and outputs to a tx. Return the new tx on success Raise on error """ if blockchain == 'bitcoin': return btc_tx_extend(partial_tx_hex, new_inputs, new_outputs, **blockc...
[ "def", "tx_extend", "(", "partial_tx_hex", ",", "new_inputs", ",", "new_outputs", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_tx_extend", "(", "partial_tx_hex", ",", ...
Add a set of inputs and outputs to a tx. Return the new tx on success Raise on error
[ "Add", "a", "set", "of", "inputs", "and", "outputs", "to", "a", "tx", ".", "Return", "the", "new", "tx", "on", "success", "Raise", "on", "error" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/transactions.py#L110-L119
47,078
mdickinson/bigfloat
bigfloat/context.py
setcontext
def setcontext(context, _local=local): """ Set the current context to that given. Attributes provided by ``context`` override those in the current context. If ``context`` doesn't specify a particular attribute, the attribute from the current context shows through. """ oldcontext = getcont...
python
def setcontext(context, _local=local): """ Set the current context to that given. Attributes provided by ``context`` override those in the current context. If ``context`` doesn't specify a particular attribute, the attribute from the current context shows through. """ oldcontext = getcont...
[ "def", "setcontext", "(", "context", ",", "_local", "=", "local", ")", ":", "oldcontext", "=", "getcontext", "(", ")", "_local", ".", "__bigfloat_context__", "=", "oldcontext", "+", "context" ]
Set the current context to that given. Attributes provided by ``context`` override those in the current context. If ``context`` doesn't specify a particular attribute, the attribute from the current context shows through.
[ "Set", "the", "current", "context", "to", "that", "given", "." ]
e5fdd1048615191ed32a2b7460e14b3b3ff24662
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/context.py#L217-L227
47,079
mdickinson/bigfloat
bigfloat/context.py
_apply_function_in_context
def _apply_function_in_context(cls, f, args, context): """ Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context. """ rounding = context.rounding bf = mpfr.Mpfr_t.__new__(cls) mpfr.mp...
python
def _apply_function_in_context(cls, f, args, context): """ Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context. """ rounding = context.rounding bf = mpfr.Mpfr_t.__new__(cls) mpfr.mp...
[ "def", "_apply_function_in_context", "(", "cls", ",", "f", ",", "args", ",", "context", ")", ":", "rounding", "=", "context", ".", "rounding", "bf", "=", "mpfr", ".", "Mpfr_t", ".", "__new__", "(", "cls", ")", "mpfr", ".", "mpfr_init2", "(", "bf", ",",...
Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context.
[ "Apply", "an", "MPFR", "function", "f", "to", "the", "given", "arguments", "args", "rounding", "to", "the", "given", "context", ".", "Returns", "a", "new", "Mpfr", "object", "with", "precision", "taken", "from", "the", "current", "context", "." ]
e5fdd1048615191ed32a2b7460e14b3b3ff24662
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/context.py#L296-L327
47,080
blockstack/virtualchain
virtualchain/lib/config.py
get_logger
def get_logger(name=None): """ Get virtualchain's logger """ level = logging.CRITICAL if DEBUG: logging.disable(logging.NOTSET) level = logging.DEBUG if name is None: name = "<unknown>" log = logging.getLogger(name=name) log.setLevel( level ) console = logg...
python
def get_logger(name=None): """ Get virtualchain's logger """ level = logging.CRITICAL if DEBUG: logging.disable(logging.NOTSET) level = logging.DEBUG if name is None: name = "<unknown>" log = logging.getLogger(name=name) log.setLevel( level ) console = logg...
[ "def", "get_logger", "(", "name", "=", "None", ")", ":", "level", "=", "logging", ".", "CRITICAL", "if", "DEBUG", ":", "logging", ".", "disable", "(", "logging", ".", "NOTSET", ")", "level", "=", "logging", ".", "DEBUG", "if", "name", "is", "None", "...
Get virtualchain's logger
[ "Get", "virtualchain", "s", "logger" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L64-L91
47,081
blockstack/virtualchain
virtualchain/lib/config.py
get_config_filename
def get_config_filename(impl, working_dir): """ Get the absolute path to the config file. """ config_filename = impl.get_virtual_chain_name() + ".ini" return os.path.join(working_dir, config_filename)
python
def get_config_filename(impl, working_dir): """ Get the absolute path to the config file. """ config_filename = impl.get_virtual_chain_name() + ".ini" return os.path.join(working_dir, config_filename)
[ "def", "get_config_filename", "(", "impl", ",", "working_dir", ")", ":", "config_filename", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".ini\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "config_filename", ")" ]
Get the absolute path to the config file.
[ "Get", "the", "absolute", "path", "to", "the", "config", "file", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L107-L112
47,082
blockstack/virtualchain
virtualchain/lib/config.py
get_db_filename
def get_db_filename(impl, working_dir): """ Get the absolute path to the last-block file. """ db_filename = impl.get_virtual_chain_name() + ".db" return os.path.join(working_dir, db_filename)
python
def get_db_filename(impl, working_dir): """ Get the absolute path to the last-block file. """ db_filename = impl.get_virtual_chain_name() + ".db" return os.path.join(working_dir, db_filename)
[ "def", "get_db_filename", "(", "impl", ",", "working_dir", ")", ":", "db_filename", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".db\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "db_filename", ")" ]
Get the absolute path to the last-block file.
[ "Get", "the", "absolute", "path", "to", "the", "last", "-", "block", "file", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L115-L120
47,083
blockstack/virtualchain
virtualchain/lib/config.py
get_snapshots_filename
def get_snapshots_filename(impl, working_dir): """ Get the absolute path to the chain's consensus snapshots file. """ snapshots_filename = impl.get_virtual_chain_name() + ".snapshots" return os.path.join(working_dir, snapshots_filename)
python
def get_snapshots_filename(impl, working_dir): """ Get the absolute path to the chain's consensus snapshots file. """ snapshots_filename = impl.get_virtual_chain_name() + ".snapshots" return os.path.join(working_dir, snapshots_filename)
[ "def", "get_snapshots_filename", "(", "impl", ",", "working_dir", ")", ":", "snapshots_filename", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".snapshots\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "snapshots_filename", ...
Get the absolute path to the chain's consensus snapshots file.
[ "Get", "the", "absolute", "path", "to", "the", "chain", "s", "consensus", "snapshots", "file", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L123-L128
47,084
blockstack/virtualchain
virtualchain/lib/config.py
get_lockfile_filename
def get_lockfile_filename(impl, working_dir): """ Get the absolute path to the chain's indexing lockfile """ lockfile_name = impl.get_virtual_chain_name() + ".lock" return os.path.join(working_dir, lockfile_name)
python
def get_lockfile_filename(impl, working_dir): """ Get the absolute path to the chain's indexing lockfile """ lockfile_name = impl.get_virtual_chain_name() + ".lock" return os.path.join(working_dir, lockfile_name)
[ "def", "get_lockfile_filename", "(", "impl", ",", "working_dir", ")", ":", "lockfile_name", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".lock\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "lockfile_name", ")" ]
Get the absolute path to the chain's indexing lockfile
[ "Get", "the", "absolute", "path", "to", "the", "chain", "s", "indexing", "lockfile" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L139-L144
47,085
blockstack/virtualchain
virtualchain/lib/config.py
get_bitcoind_config
def get_bitcoind_config(config_file=None, impl=None): """ Set bitcoind options globally. Call this before trying to talk to bitcoind. """ loaded = False bitcoind_server = None bitcoind_port = None bitcoind_user = None bitcoind_passwd = None bitcoind_timeout = None bitcoind_...
python
def get_bitcoind_config(config_file=None, impl=None): """ Set bitcoind options globally. Call this before trying to talk to bitcoind. """ loaded = False bitcoind_server = None bitcoind_port = None bitcoind_user = None bitcoind_passwd = None bitcoind_timeout = None bitcoind_...
[ "def", "get_bitcoind_config", "(", "config_file", "=", "None", ",", "impl", "=", "None", ")", ":", "loaded", "=", "False", "bitcoind_server", "=", "None", "bitcoind_port", "=", "None", "bitcoind_user", "=", "None", "bitcoind_passwd", "=", "None", "bitcoind_timeo...
Set bitcoind options globally. Call this before trying to talk to bitcoind.
[ "Set", "bitcoind", "options", "globally", ".", "Call", "this", "before", "trying", "to", "talk", "to", "bitcoind", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L147-L228
47,086
emory-libraries/eulxml
eulxml/xmlmap/mods.py
OriginInfo.is_empty
def is_empty(self): """Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.""" return all(date.is_empty() for date in [self.created, self.issued]) \ and not se...
python
def is_empty(self): """Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.""" return all(date.is_empty() for date in [self.created, self.issued]) \ and not se...
[ "def", "is_empty", "(", "self", ")", ":", "return", "all", "(", "date", ".", "is_empty", "(", ")", "for", "date", "in", "[", "self", ".", "created", ",", "self", ".", "issued", "]", ")", "and", "not", "self", ".", "publisher" ]
Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.
[ "Returns", "True", "if", "all", "child", "date", "elements", "present", "are", "empty", "and", "other", "nodes", "are", "not", "set", ".", "Returns", "False", "if", "any", "child", "date", "elements", "are", "not", "empty", "or", "other", "nodes", "are", ...
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L116-L121
47,087
emory-libraries/eulxml
eulxml/xmlmap/mods.py
TitleInfo.is_empty
def is_empty(self): '''Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.''' return not bool(self.title or self.subtitle or self.part_number \ or self.part_name or self.non_sort or self.type)
python
def is_empty(self): '''Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.''' return not bool(self.title or self.subtitle or self.part_number \ or self.part_name or self.non_sort or self.type)
[ "def", "is_empty", "(", "self", ")", ":", "return", "not", "bool", "(", "self", ".", "title", "or", "self", ".", "subtitle", "or", "self", ".", "part_number", "or", "self", ".", "part_name", "or", "self", ".", "non_sort", "or", "self", ".", "type", "...
Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.
[ "Returns", "True", "if", "all", "titleInfo", "subfields", "are", "not", "set", "or", "empty", ";", "returns", "False", "if", "any", "of", "the", "fields", "are", "not", "empty", "." ]
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L242-L246
47,088
emory-libraries/eulxml
eulxml/xmlmap/mods.py
Part.is_empty
def is_empty(self): '''Returns True if details, extent, and type are not set or return True for ``is_empty``; returns False if any of the fields are not empty.''' return all(field.is_empty() for field in [self.details, self.extent] if field is not None) \ ...
python
def is_empty(self): '''Returns True if details, extent, and type are not set or return True for ``is_empty``; returns False if any of the fields are not empty.''' return all(field.is_empty() for field in [self.details, self.extent] if field is not None) \ ...
[ "def", "is_empty", "(", "self", ")", ":", "return", "all", "(", "field", ".", "is_empty", "(", ")", "for", "field", "in", "[", "self", ".", "details", ",", "self", ".", "extent", "]", "if", "field", "is", "not", "None", ")", "and", "not", "self", ...
Returns True if details, extent, and type are not set or return True for ``is_empty``; returns False if any of the fields are not empty.
[ "Returns", "True", "if", "details", "extent", "and", "type", "are", "not", "set", "or", "return", "True", "for", "is_empty", ";", "returns", "False", "if", "any", "of", "the", "fields", "are", "not", "empty", "." ]
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L294-L300
47,089
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/authproxy.py
AuthServiceProxy.getinfo
def getinfo(self): """ Backwards-compatibility for 0.14 and later """ try: old_getinfo = AuthServiceProxy(self.__service_url, 'getinfo', self.__timeout, self.__conn, True) res = old_getinfo() if 'error' not in res: # 0.13 and earlier ...
python
def getinfo(self): """ Backwards-compatibility for 0.14 and later """ try: old_getinfo = AuthServiceProxy(self.__service_url, 'getinfo', self.__timeout, self.__conn, True) res = old_getinfo() if 'error' not in res: # 0.13 and earlier ...
[ "def", "getinfo", "(", "self", ")", ":", "try", ":", "old_getinfo", "=", "AuthServiceProxy", "(", "self", ".", "__service_url", ",", "'getinfo'", ",", "self", ".", "__timeout", ",", "self", ".", "__conn", ",", "True", ")", "res", "=", "old_getinfo", "(",...
Backwards-compatibility for 0.14 and later
[ "Backwards", "-", "compatibility", "for", "0", ".", "14", "and", "later" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/authproxy.py#L203-L251
47,090
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_payment_script
def btc_make_payment_script( address, segwit=None, **ignored ): """ Make a pay-to-address script. """ if segwit is None: segwit = get_features('segwit') # is address bech32-encoded? witver, withash = segwit_addr_decode(address) if witver is not None and withash is not None: ...
python
def btc_make_payment_script( address, segwit=None, **ignored ): """ Make a pay-to-address script. """ if segwit is None: segwit = get_features('segwit') # is address bech32-encoded? witver, withash = segwit_addr_decode(address) if witver is not None and withash is not None: ...
[ "def", "btc_make_payment_script", "(", "address", ",", "segwit", "=", "None", ",", "*", "*", "ignored", ")", ":", "if", "segwit", "is", "None", ":", "segwit", "=", "get_features", "(", "'segwit'", ")", "# is address bech32-encoded?", "witver", ",", "withash", ...
Make a pay-to-address script.
[ "Make", "a", "pay", "-", "to", "-", "address", "script", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L281-L327
47,091
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_data_script
def btc_make_data_script( data, **ignored ): """ Make a data-bearing transaction output. Data must be a hex string Returns a hex string. """ if len(data) >= MAX_DATA_LEN * 2: raise ValueError("Data hex string is too long") # note: data is a hex string if len(data) % 2 != 0: ...
python
def btc_make_data_script( data, **ignored ): """ Make a data-bearing transaction output. Data must be a hex string Returns a hex string. """ if len(data) >= MAX_DATA_LEN * 2: raise ValueError("Data hex string is too long") # note: data is a hex string if len(data) % 2 != 0: ...
[ "def", "btc_make_data_script", "(", "data", ",", "*", "*", "ignored", ")", ":", "if", "len", "(", "data", ")", ">=", "MAX_DATA_LEN", "*", "2", ":", "raise", "ValueError", "(", "\"Data hex string is too long\"", ")", "# note: data is a hex string", "if", "len", ...
Make a data-bearing transaction output. Data must be a hex string Returns a hex string.
[ "Make", "a", "data", "-", "bearing", "transaction", "output", ".", "Data", "must", "be", "a", "hex", "string", "Returns", "a", "hex", "string", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L330-L342
47,092
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2sh_address
def btc_make_p2sh_address( script_hex ): """ Make a P2SH address from a hex script """ h = hashing.bin_hash160(binascii.unhexlify(script_hex)) addr = bin_hash160_to_address(h, version_byte=multisig_version_byte) return addr
python
def btc_make_p2sh_address( script_hex ): """ Make a P2SH address from a hex script """ h = hashing.bin_hash160(binascii.unhexlify(script_hex)) addr = bin_hash160_to_address(h, version_byte=multisig_version_byte) return addr
[ "def", "btc_make_p2sh_address", "(", "script_hex", ")", ":", "h", "=", "hashing", ".", "bin_hash160", "(", "binascii", ".", "unhexlify", "(", "script_hex", ")", ")", "addr", "=", "bin_hash160_to_address", "(", "h", ",", "version_byte", "=", "multisig_version_byt...
Make a P2SH address from a hex script
[ "Make", "a", "P2SH", "address", "from", "a", "hex", "script" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L375-L381
47,093
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2wpkh_address
def btc_make_p2wpkh_address( pubkey_hex ): """ Make a p2wpkh address from a hex pubkey """ pubkey_hex = keylib.key_formatting.compress(pubkey_hex) hash160_bin = hashing.bin_hash160(pubkey_hex.decode('hex')) return segwit_addr_encode(hash160_bin)
python
def btc_make_p2wpkh_address( pubkey_hex ): """ Make a p2wpkh address from a hex pubkey """ pubkey_hex = keylib.key_formatting.compress(pubkey_hex) hash160_bin = hashing.bin_hash160(pubkey_hex.decode('hex')) return segwit_addr_encode(hash160_bin)
[ "def", "btc_make_p2wpkh_address", "(", "pubkey_hex", ")", ":", "pubkey_hex", "=", "keylib", ".", "key_formatting", ".", "compress", "(", "pubkey_hex", ")", "hash160_bin", "=", "hashing", ".", "bin_hash160", "(", "pubkey_hex", ".", "decode", "(", "'hex'", ")", ...
Make a p2wpkh address from a hex pubkey
[ "Make", "a", "p2wpkh", "address", "from", "a", "hex", "pubkey" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L384-L390
47,094
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2sh_p2wpkh_redeem_script
def btc_make_p2sh_p2wpkh_redeem_script( pubkey_hex ): """ Make the redeem script for a p2sh-p2wpkh witness script """ pubkey_hash = hashing.bin_hash160(pubkey_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0014' + pubkey_hash]) return redeem_script
python
def btc_make_p2sh_p2wpkh_redeem_script( pubkey_hex ): """ Make the redeem script for a p2sh-p2wpkh witness script """ pubkey_hash = hashing.bin_hash160(pubkey_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0014' + pubkey_hash]) return redeem_script
[ "def", "btc_make_p2sh_p2wpkh_redeem_script", "(", "pubkey_hex", ")", ":", "pubkey_hash", "=", "hashing", ".", "bin_hash160", "(", "pubkey_hex", ".", "decode", "(", "'hex'", ")", ")", ".", "encode", "(", "'hex'", ")", "redeem_script", "=", "btc_script_serialize", ...
Make the redeem script for a p2sh-p2wpkh witness script
[ "Make", "the", "redeem", "script", "for", "a", "p2sh", "-", "p2wpkh", "witness", "script" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L393-L399
47,095
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2sh_p2wsh_redeem_script
def btc_make_p2sh_p2wsh_redeem_script( witness_script_hex ): """ Make the redeem script for a p2sh-p2wsh witness script """ witness_script_hash = hashing.bin_sha256(witness_script_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0020' + witness_script_hash]) return redeem_...
python
def btc_make_p2sh_p2wsh_redeem_script( witness_script_hex ): """ Make the redeem script for a p2sh-p2wsh witness script """ witness_script_hash = hashing.bin_sha256(witness_script_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0020' + witness_script_hash]) return redeem_...
[ "def", "btc_make_p2sh_p2wsh_redeem_script", "(", "witness_script_hex", ")", ":", "witness_script_hash", "=", "hashing", ".", "bin_sha256", "(", "witness_script_hex", ".", "decode", "(", "'hex'", ")", ")", ".", "encode", "(", "'hex'", ")", "redeem_script", "=", "bt...
Make the redeem script for a p2sh-p2wsh witness script
[ "Make", "the", "redeem", "script", "for", "a", "p2sh", "-", "p2wsh", "witness", "script" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L419-L425
47,096
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2sh_address
def btc_is_p2sh_address( address ): """ Is the given address a p2sh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == multisig_version_byte: return True else: return False
python
def btc_is_p2sh_address( address ): """ Is the given address a p2sh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == multisig_version_byte: return True else: return False
[ "def", "btc_is_p2sh_address", "(", "address", ")", ":", "vb", "=", "keylib", ".", "b58check", ".", "b58check_version_byte", "(", "address", ")", "if", "vb", "==", "multisig_version_byte", ":", "return", "True", "else", ":", "return", "False" ]
Is the given address a p2sh address?
[ "Is", "the", "given", "address", "a", "p2sh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L437-L445
47,097
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2pkh_address
def btc_is_p2pkh_address( address ): """ Is the given address a p2pkh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == version_byte: return True else: return False
python
def btc_is_p2pkh_address( address ): """ Is the given address a p2pkh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == version_byte: return True else: return False
[ "def", "btc_is_p2pkh_address", "(", "address", ")", ":", "vb", "=", "keylib", ".", "b58check", ".", "b58check_version_byte", "(", "address", ")", "if", "vb", "==", "version_byte", ":", "return", "True", "else", ":", "return", "False" ]
Is the given address a p2pkh address?
[ "Is", "the", "given", "address", "a", "p2pkh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L448-L456
47,098
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2wpkh_address
def btc_is_p2wpkh_address( address ): """ Is the given address a p2wpkh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 20: return False return True
python
def btc_is_p2wpkh_address( address ): """ Is the given address a p2wpkh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 20: return False return True
[ "def", "btc_is_p2wpkh_address", "(", "address", ")", ":", "wver", ",", "whash", "=", "segwit_addr_decode", "(", "address", ")", "if", "whash", "is", "None", ":", "return", "False", "if", "len", "(", "whash", ")", "!=", "20", ":", "return", "False", "retu...
Is the given address a p2wpkh address?
[ "Is", "the", "given", "address", "a", "p2wpkh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L459-L470
47,099
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2wsh_address
def btc_is_p2wsh_address( address ): """ Is the given address a p2wsh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 32: return False return True
python
def btc_is_p2wsh_address( address ): """ Is the given address a p2wsh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 32: return False return True
[ "def", "btc_is_p2wsh_address", "(", "address", ")", ":", "wver", ",", "whash", "=", "segwit_addr_decode", "(", "address", ")", "if", "whash", "is", "None", ":", "return", "False", "if", "len", "(", "whash", ")", "!=", "32", ":", "return", "False", "retur...
Is the given address a p2wsh address?
[ "Is", "the", "given", "address", "a", "p2wsh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L473-L484