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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
atztogo/phonopy | phonopy/api_phonopy.py | Phonopy.run_thermal_displacement_matrices | def run_thermal_displacement_matrices(self,
t_min=0,
t_max=1000,
t_step=10,
temperatures=None,
freq_min=None,
... | python | def run_thermal_displacement_matrices(self,
t_min=0,
t_max=1000,
t_step=10,
temperatures=None,
freq_min=None,
... | [
"def",
"run_thermal_displacement_matrices",
"(",
"self",
",",
"t_min",
"=",
"0",
",",
"t_max",
"=",
"1000",
",",
"t_step",
"=",
"10",
",",
"temperatures",
"=",
"None",
",",
"freq_min",
"=",
"None",
",",
"freq_max",
"=",
"None",
")",
":",
"if",
"self",
... | Prepare thermal displacement matrices
Parameters
----------
t_min, t_max, t_step : float, optional
Minimum and maximum temperatures and the interval in this
temperature range. Default valuues are 0, 1000, and 10.
freq_min, freq_max : float, optional
P... | [
"Prepare",
"thermal",
"displacement",
"matrices"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L2016-L2066 | train |
atztogo/phonopy | phonopy/api_phonopy.py | Phonopy.set_modulations | def set_modulations(self,
dimension,
phonon_modes,
delta_q=None,
derivative_order=None,
nac_q_direction=None):
"""Generate atomic displacements of phonon modes.
The design of this fea... | python | def set_modulations(self,
dimension,
phonon_modes,
delta_q=None,
derivative_order=None,
nac_q_direction=None):
"""Generate atomic displacements of phonon modes.
The design of this fea... | [
"def",
"set_modulations",
"(",
"self",
",",
"dimension",
",",
"phonon_modes",
",",
"delta_q",
"=",
"None",
",",
"derivative_order",
"=",
"None",
",",
"nac_q_direction",
"=",
"None",
")",
":",
"if",
"self",
".",
"_dynamical_matrix",
"is",
"None",
":",
"msg",
... | Generate atomic displacements of phonon modes.
The design of this feature is not very satisfactory, and thus API.
Therefore it should be reconsidered someday in the fugure.
Parameters
----------
dimension : array_like
Supercell dimension with respect to the primitive... | [
"Generate",
"atomic",
"displacements",
"of",
"phonon",
"modes",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L2204-L2242 | train |
atztogo/phonopy | phonopy/api_phonopy.py | Phonopy.set_irreps | def set_irreps(self,
q,
is_little_cogroup=False,
nac_q_direction=None,
degeneracy_tolerance=1e-4):
"""Identify ir-reps of phonon modes.
The design of this API is not very satisfactory and is expceted
to be redesined in ... | python | def set_irreps(self,
q,
is_little_cogroup=False,
nac_q_direction=None,
degeneracy_tolerance=1e-4):
"""Identify ir-reps of phonon modes.
The design of this API is not very satisfactory and is expceted
to be redesined in ... | [
"def",
"set_irreps",
"(",
"self",
",",
"q",
",",
"is_little_cogroup",
"=",
"False",
",",
"nac_q_direction",
"=",
"None",
",",
"degeneracy_tolerance",
"=",
"1e-4",
")",
":",
"if",
"self",
".",
"_dynamical_matrix",
"is",
"None",
":",
"msg",
"=",
"(",
"\"Dyna... | Identify ir-reps of phonon modes.
The design of this API is not very satisfactory and is expceted
to be redesined in the next major versions once the use case
of the API for ir-reps feature becomes clearer. | [
"Identify",
"ir",
"-",
"reps",
"of",
"phonon",
"modes",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L2267-L2294 | train |
atztogo/phonopy | phonopy/api_phonopy.py | Phonopy.init_dynamic_structure_factor | def init_dynamic_structure_factor(self,
Qpoints,
T,
atomic_form_factor_func=None,
scattering_lengths=None,
freq_min=None,
... | python | def init_dynamic_structure_factor(self,
Qpoints,
T,
atomic_form_factor_func=None,
scattering_lengths=None,
freq_min=None,
... | [
"def",
"init_dynamic_structure_factor",
"(",
"self",
",",
"Qpoints",
",",
"T",
",",
"atomic_form_factor_func",
"=",
"None",
",",
"scattering_lengths",
"=",
"None",
",",
"freq_min",
"=",
"None",
",",
"freq_max",
"=",
"None",
")",
":",
"if",
"self",
".",
"_mes... | Initialize dynamic structure factor calculation.
*******************************************************************
This is still an experimental feature. API can be changed without
notification.
*******************************************************************
Need to cal... | [
"Initialize",
"dynamic",
"structure",
"factor",
"calculation",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L2378-L2445 | train |
atztogo/phonopy | phonopy/api_phonopy.py | Phonopy.run_dynamic_structure_factor | def run_dynamic_structure_factor(self,
Qpoints,
T,
atomic_form_factor_func=None,
scattering_lengths=None,
freq_min=None,
... | python | def run_dynamic_structure_factor(self,
Qpoints,
T,
atomic_form_factor_func=None,
scattering_lengths=None,
freq_min=None,
... | [
"def",
"run_dynamic_structure_factor",
"(",
"self",
",",
"Qpoints",
",",
"T",
",",
"atomic_form_factor_func",
"=",
"None",
",",
"scattering_lengths",
"=",
"None",
",",
"freq_min",
"=",
"None",
",",
"freq_max",
"=",
"None",
")",
":",
"self",
".",
"init_dynamic_... | Run dynamic structure factor calculation
See the detail of parameters at
Phonopy.init_dynamic_structure_factor(). | [
"Run",
"dynamic",
"structure",
"factor",
"calculation"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L2447-L2468 | train |
atztogo/phonopy | phonopy/api_phonopy.py | Phonopy.save | def save(self,
filename="phonopy_params.yaml",
settings=None):
"""Save parameters in Phonopy instants into file.
Parameters
----------
filename: str, optional
File name. Default is "phonopy_params.yaml"
settings: dict, optional
I... | python | def save(self,
filename="phonopy_params.yaml",
settings=None):
"""Save parameters in Phonopy instants into file.
Parameters
----------
filename: str, optional
File name. Default is "phonopy_params.yaml"
settings: dict, optional
I... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"\"phonopy_params.yaml\"",
",",
"settings",
"=",
"None",
")",
":",
"phpy_yaml",
"=",
"PhonopyYaml",
"(",
"calculator",
"=",
"self",
".",
"_calculator",
",",
"settings",
"=",
"settings",
")",
"phpy_yaml",
".",... | Save parameters in Phonopy instants into file.
Parameters
----------
filename: str, optional
File name. Default is "phonopy_params.yaml"
settings: dict, optional
It is described which parameters are written out. Only
the settings expected to be update... | [
"Save",
"parameters",
"in",
"Phonopy",
"instants",
"into",
"file",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L2520-L2545 | train |
atztogo/phonopy | phonopy/phonon/mesh.py | length2mesh | def length2mesh(length, lattice, rotations=None):
"""Convert length to mesh for q-point sampling
This conversion for each reciprocal axis follows VASP convention by
N = max(1, int(l * |a|^* + 0.5))
'int' means rounding down, not rounding to nearest integer.
Parameters
----------
length... | python | def length2mesh(length, lattice, rotations=None):
"""Convert length to mesh for q-point sampling
This conversion for each reciprocal axis follows VASP convention by
N = max(1, int(l * |a|^* + 0.5))
'int' means rounding down, not rounding to nearest integer.
Parameters
----------
length... | [
"def",
"length2mesh",
"(",
"length",
",",
"lattice",
",",
"rotations",
"=",
"None",
")",
":",
"rec_lattice",
"=",
"np",
".",
"linalg",
".",
"inv",
"(",
"lattice",
")",
"rec_lat_lengths",
"=",
"np",
".",
"sqrt",
"(",
"np",
".",
"diagonal",
"(",
"np",
... | Convert length to mesh for q-point sampling
This conversion for each reciprocal axis follows VASP convention by
N = max(1, int(l * |a|^* + 0.5))
'int' means rounding down, not rounding to nearest integer.
Parameters
----------
length : float
Length having the unit of direct space l... | [
"Convert",
"length",
"to",
"mesh",
"for",
"q",
"-",
"point",
"sampling"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/phonon/mesh.py#L41-L80 | train |
atztogo/phonopy | phonopy/phonon/thermal_displacement.py | ThermalMotion._get_population | def _get_population(self, freq, t): # freq in THz
"""Return phonon population number
Three types of combinations of array inputs are possible.
- single freq and single t
- single freq and len(t) > 1
- len(freq) > 1 and single t
"""
condition = t > 1.0
i... | python | def _get_population(self, freq, t): # freq in THz
"""Return phonon population number
Three types of combinations of array inputs are possible.
- single freq and single t
- single freq and len(t) > 1
- len(freq) > 1 and single t
"""
condition = t > 1.0
i... | [
"def",
"_get_population",
"(",
"self",
",",
"freq",
",",
"t",
")",
":",
"# freq in THz",
"condition",
"=",
"t",
">",
"1.0",
"if",
"type",
"(",
"condition",
")",
"==",
"bool",
"or",
"type",
"(",
"condition",
")",
"==",
"np",
".",
"bool_",
":",
"if",
... | Return phonon population number
Three types of combinations of array inputs are possible.
- single freq and single t
- single freq and len(t) > 1
- len(freq) > 1 and single t | [
"Return",
"phonon",
"population",
"number"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/phonon/thermal_displacement.py#L101-L120 | train |
atztogo/phonopy | phonopy/phonon/thermal_displacement.py | ThermalDisplacements._project_eigenvectors | def _project_eigenvectors(self):
"""Eigenvectors are projected along Cartesian direction"""
self._p_eigenvectors = []
for vecs_q in self._eigenvectors:
p_vecs_q = []
for vecs in vecs_q.T:
p_vecs_q.append(np.dot(vecs.reshape(-1, 3),
... | python | def _project_eigenvectors(self):
"""Eigenvectors are projected along Cartesian direction"""
self._p_eigenvectors = []
for vecs_q in self._eigenvectors:
p_vecs_q = []
for vecs in vecs_q.T:
p_vecs_q.append(np.dot(vecs.reshape(-1, 3),
... | [
"def",
"_project_eigenvectors",
"(",
"self",
")",
":",
"self",
".",
"_p_eigenvectors",
"=",
"[",
"]",
"for",
"vecs_q",
"in",
"self",
".",
"_eigenvectors",
":",
"p_vecs_q",
"=",
"[",
"]",
"for",
"vecs",
"in",
"vecs_q",
".",
"T",
":",
"p_vecs_q",
".",
"a... | Eigenvectors are projected along Cartesian direction | [
"Eigenvectors",
"are",
"projected",
"along",
"Cartesian",
"direction"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/phonon/thermal_displacement.py#L226-L236 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_symmetry | def get_symmetry(cell, symprec=1e-5, angle_tolerance=-1.0):
"""This gives crystal symmetry operations from a crystal structure.
Args:
cell: Crystal structrue given either in Atoms object or tuple.
In the case given by a tuple, it has to follow the form below,
(Lattice parameters... | python | def get_symmetry(cell, symprec=1e-5, angle_tolerance=-1.0):
"""This gives crystal symmetry operations from a crystal structure.
Args:
cell: Crystal structrue given either in Atoms object or tuple.
In the case given by a tuple, it has to follow the form below,
(Lattice parameters... | [
"def",
"get_symmetry",
"(",
"cell",
",",
"symprec",
"=",
"1e-5",
",",
"angle_tolerance",
"=",
"-",
"1.0",
")",
":",
"_set_no_error",
"(",
")",
"lattice",
",",
"positions",
",",
"numbers",
",",
"magmoms",
"=",
"_expand_cell",
"(",
"cell",
")",
"if",
"latt... | This gives crystal symmetry operations from a crystal structure.
Args:
cell: Crystal structrue given either in Atoms object or tuple.
In the case given by a tuple, it has to follow the form below,
(Lattice parameters in a 3x3 array (see the detail below),
Fractional ato... | [
"This",
"gives",
"crystal",
"symmetry",
"operations",
"from",
"a",
"crystal",
"structure",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L51-L120 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_symmetry_dataset | def get_symmetry_dataset(cell,
symprec=1e-5,
angle_tolerance=-1.0,
hall_number=0):
"""Search symmetry dataset from an input cell.
Args:
cell, symprec, angle_tolerance:
See the docstring of get_symmetry.
hall_... | python | def get_symmetry_dataset(cell,
symprec=1e-5,
angle_tolerance=-1.0,
hall_number=0):
"""Search symmetry dataset from an input cell.
Args:
cell, symprec, angle_tolerance:
See the docstring of get_symmetry.
hall_... | [
"def",
"get_symmetry_dataset",
"(",
"cell",
",",
"symprec",
"=",
"1e-5",
",",
"angle_tolerance",
"=",
"-",
"1.0",
",",
"hall_number",
"=",
"0",
")",
":",
"_set_no_error",
"(",
")",
"lattice",
",",
"positions",
",",
"numbers",
",",
"_",
"=",
"_expand_cell",... | Search symmetry dataset from an input cell.
Args:
cell, symprec, angle_tolerance:
See the docstring of get_symmetry.
hall_number: If a serial number of Hall symbol (>0) is given,
the database corresponding to the Hall symbol is made.
Return:
A dictionar... | [
"Search",
"symmetry",
"dataset",
"from",
"an",
"input",
"cell",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L123-L235 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_spacegroup | def get_spacegroup(cell, symprec=1e-5, angle_tolerance=-1.0, symbol_type=0):
"""Return space group in international table symbol and number as a string.
If it fails, None is returned.
"""
_set_no_error()
dataset = get_symmetry_dataset(cell,
symprec=symprec,
... | python | def get_spacegroup(cell, symprec=1e-5, angle_tolerance=-1.0, symbol_type=0):
"""Return space group in international table symbol and number as a string.
If it fails, None is returned.
"""
_set_no_error()
dataset = get_symmetry_dataset(cell,
symprec=symprec,
... | [
"def",
"get_spacegroup",
"(",
"cell",
",",
"symprec",
"=",
"1e-5",
",",
"angle_tolerance",
"=",
"-",
"1.0",
",",
"symbol_type",
"=",
"0",
")",
":",
"_set_no_error",
"(",
")",
"dataset",
"=",
"get_symmetry_dataset",
"(",
"cell",
",",
"symprec",
"=",
"sympre... | Return space group in international table symbol and number as a string.
If it fails, None is returned. | [
"Return",
"space",
"group",
"in",
"international",
"table",
"symbol",
"and",
"number",
"as",
"a",
"string",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L238-L255 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_hall_number_from_symmetry | def get_hall_number_from_symmetry(rotations, translations, symprec=1e-5):
"""Hall number is obtained from a set of symmetry operations.
If it fails, None is returned.
"""
r = np.array(rotations, dtype='intc', order='C')
t = np.array(translations, dtype='double', order='C')
hall_number = spg.ha... | python | def get_hall_number_from_symmetry(rotations, translations, symprec=1e-5):
"""Hall number is obtained from a set of symmetry operations.
If it fails, None is returned.
"""
r = np.array(rotations, dtype='intc', order='C')
t = np.array(translations, dtype='double', order='C')
hall_number = spg.ha... | [
"def",
"get_hall_number_from_symmetry",
"(",
"rotations",
",",
"translations",
",",
"symprec",
"=",
"1e-5",
")",
":",
"r",
"=",
"np",
".",
"array",
"(",
"rotations",
",",
"dtype",
"=",
"'intc'",
",",
"order",
"=",
"'C'",
")",
"t",
"=",
"np",
".",
"arra... | Hall number is obtained from a set of symmetry operations.
If it fails, None is returned. | [
"Hall",
"number",
"is",
"obtained",
"from",
"a",
"set",
"of",
"symmetry",
"operations",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L258-L267 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_spacegroup_type | def get_spacegroup_type(hall_number):
"""Translate Hall number to space group type information.
If it fails, None is returned.
"""
_set_no_error()
keys = ('number',
'international_short',
'international_full',
'international',
'schoenflies',
... | python | def get_spacegroup_type(hall_number):
"""Translate Hall number to space group type information.
If it fails, None is returned.
"""
_set_no_error()
keys = ('number',
'international_short',
'international_full',
'international',
'schoenflies',
... | [
"def",
"get_spacegroup_type",
"(",
"hall_number",
")",
":",
"_set_no_error",
"(",
")",
"keys",
"=",
"(",
"'number'",
",",
"'international_short'",
",",
"'international_full'",
",",
"'international'",
",",
"'schoenflies'",
",",
"'hall_symbol'",
",",
"'choice'",
",",
... | Translate Hall number to space group type information.
If it fails, None is returned. | [
"Translate",
"Hall",
"number",
"to",
"space",
"group",
"type",
"information",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L270-L298 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_pointgroup | def get_pointgroup(rotations):
"""Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11... | python | def get_pointgroup(rotations):
"""Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11... | [
"def",
"get_pointgroup",
"(",
"rotations",
")",
":",
"_set_no_error",
"(",
")",
"# (symbol, pointgroup_number, transformation_matrix)",
"pointgroup",
"=",
"spg",
".",
"pointgroup",
"(",
"np",
".",
"array",
"(",
"rotations",
",",
"dtype",
"=",
"'intc'",
",",
"order... | Return point group in international table symbol and number.
The symbols are mapped to the numbers as follows:
1 "1 "
2 "-1 "
3 "2 "
4 "m "
5 "2/m "
6 "222 "
7 "mm2 "
8 "mmm "
9 "4 "
10 "-4 "
11 "4/m "
12 "422 "
13 "4mm... | [
"Return",
"point",
"group",
"in",
"international",
"table",
"symbol",
"and",
"number",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L301-L343 | train |
atztogo/phonopy | phonopy/structure/spglib.py | standardize_cell | def standardize_cell(cell,
to_primitive=False,
no_idealize=False,
symprec=1e-5,
angle_tolerance=-1.0):
"""Return standardized cell.
Args:
cell, symprec, angle_tolerance:
See the docstring of get_symmetry.
... | python | def standardize_cell(cell,
to_primitive=False,
no_idealize=False,
symprec=1e-5,
angle_tolerance=-1.0):
"""Return standardized cell.
Args:
cell, symprec, angle_tolerance:
See the docstring of get_symmetry.
... | [
"def",
"standardize_cell",
"(",
"cell",
",",
"to_primitive",
"=",
"False",
",",
"no_idealize",
"=",
"False",
",",
"symprec",
"=",
"1e-5",
",",
"angle_tolerance",
"=",
"-",
"1.0",
")",
":",
"_set_no_error",
"(",
")",
"lattice",
",",
"_positions",
",",
"_num... | Return standardized cell.
Args:
cell, symprec, angle_tolerance:
See the docstring of get_symmetry.
to_primitive:
bool: If True, the standardized primitive cell is created.
no_idealize:
bool: If True, it is disabled to idealize lengths and angles of
... | [
"Return",
"standardized",
"cell",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L346-L394 | train |
atztogo/phonopy | phonopy/structure/spglib.py | find_primitive | def find_primitive(cell, symprec=1e-5, angle_tolerance=-1.0):
"""Primitive cell is searched in the input cell.
The primitive cell is returned by a tuple of (lattice, positions, numbers).
If it fails, None is returned.
"""
_set_no_error()
lattice, positions, numbers, _ = _expand_cell(cell)
... | python | def find_primitive(cell, symprec=1e-5, angle_tolerance=-1.0):
"""Primitive cell is searched in the input cell.
The primitive cell is returned by a tuple of (lattice, positions, numbers).
If it fails, None is returned.
"""
_set_no_error()
lattice, positions, numbers, _ = _expand_cell(cell)
... | [
"def",
"find_primitive",
"(",
"cell",
",",
"symprec",
"=",
"1e-5",
",",
"angle_tolerance",
"=",
"-",
"1.0",
")",
":",
"_set_no_error",
"(",
")",
"lattice",
",",
"positions",
",",
"numbers",
",",
"_",
"=",
"_expand_cell",
"(",
"cell",
")",
"if",
"lattice"... | Primitive cell is searched in the input cell.
The primitive cell is returned by a tuple of (lattice, positions, numbers).
If it fails, None is returned. | [
"Primitive",
"cell",
"is",
"searched",
"in",
"the",
"input",
"cell",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L432-L456 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_symmetry_from_database | def get_symmetry_from_database(hall_number):
"""Return symmetry operations corresponding to a Hall symbol.
The Hall symbol is given by the serial number in between 1 and 530.
The symmetry operations are given by a dictionary whose keys are
'rotations' and 'translations'.
If it fails, None is return... | python | def get_symmetry_from_database(hall_number):
"""Return symmetry operations corresponding to a Hall symbol.
The Hall symbol is given by the serial number in between 1 and 530.
The symmetry operations are given by a dictionary whose keys are
'rotations' and 'translations'.
If it fails, None is return... | [
"def",
"get_symmetry_from_database",
"(",
"hall_number",
")",
":",
"_set_no_error",
"(",
")",
"rotations",
"=",
"np",
".",
"zeros",
"(",
"(",
"192",
",",
"3",
",",
"3",
")",
",",
"dtype",
"=",
"'intc'",
")",
"translations",
"=",
"np",
".",
"zeros",
"("... | Return symmetry operations corresponding to a Hall symbol.
The Hall symbol is given by the serial number in between 1 and 530.
The symmetry operations are given by a dictionary whose keys are
'rotations' and 'translations'.
If it fails, None is returned. | [
"Return",
"symmetry",
"operations",
"corresponding",
"to",
"a",
"Hall",
"symbol",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L459-L480 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_grid_point_from_address | def get_grid_point_from_address(grid_address, mesh):
"""Return grid point index by tranlating grid address"""
_set_no_error()
return spg.grid_point_from_address(np.array(grid_address, dtype='intc'),
np.array(mesh, dtype='intc')) | python | def get_grid_point_from_address(grid_address, mesh):
"""Return grid point index by tranlating grid address"""
_set_no_error()
return spg.grid_point_from_address(np.array(grid_address, dtype='intc'),
np.array(mesh, dtype='intc')) | [
"def",
"get_grid_point_from_address",
"(",
"grid_address",
",",
"mesh",
")",
":",
"_set_no_error",
"(",
")",
"return",
"spg",
".",
"grid_point_from_address",
"(",
"np",
".",
"array",
"(",
"grid_address",
",",
"dtype",
"=",
"'intc'",
")",
",",
"np",
".",
"arr... | Return grid point index by tranlating grid address | [
"Return",
"grid",
"point",
"index",
"by",
"tranlating",
"grid",
"address"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L486-L491 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_ir_reciprocal_mesh | def get_ir_reciprocal_mesh(mesh,
cell,
is_shift=None,
is_time_reversal=True,
symprec=1e-5,
is_dense=False):
"""Return k-points mesh and k-point map to the irreducible k-points.
... | python | def get_ir_reciprocal_mesh(mesh,
cell,
is_shift=None,
is_time_reversal=True,
symprec=1e-5,
is_dense=False):
"""Return k-points mesh and k-point map to the irreducible k-points.
... | [
"def",
"get_ir_reciprocal_mesh",
"(",
"mesh",
",",
"cell",
",",
"is_shift",
"=",
"None",
",",
"is_time_reversal",
"=",
"True",
",",
"symprec",
"=",
"1e-5",
",",
"is_dense",
"=",
"False",
")",
":",
"_set_no_error",
"(",
")",
"lattice",
",",
"positions",
","... | Return k-points mesh and k-point map to the irreducible k-points.
The symmetry is serched from the input cell.
Parameters
----------
mesh : array_like
Uniform sampling mesh numbers.
dtype='intc', shape=(3,)
cell : spglib cell tuple
Crystal structure.
is_shift : array_li... | [
"Return",
"k",
"-",
"points",
"mesh",
"and",
"k",
"-",
"point",
"map",
"to",
"the",
"irreducible",
"k",
"-",
"points",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L494-L559 | train |
atztogo/phonopy | phonopy/structure/spglib.py | get_stabilized_reciprocal_mesh | def get_stabilized_reciprocal_mesh(mesh,
rotations,
is_shift=None,
is_time_reversal=True,
qpoints=None,
is_dense=False):
"""Return k-point ma... | python | def get_stabilized_reciprocal_mesh(mesh,
rotations,
is_shift=None,
is_time_reversal=True,
qpoints=None,
is_dense=False):
"""Return k-point ma... | [
"def",
"get_stabilized_reciprocal_mesh",
"(",
"mesh",
",",
"rotations",
",",
"is_shift",
"=",
"None",
",",
"is_time_reversal",
"=",
"True",
",",
"qpoints",
"=",
"None",
",",
"is_dense",
"=",
"False",
")",
":",
"_set_no_error",
"(",
")",
"if",
"is_dense",
":"... | Return k-point map to the irreducible k-points and k-point grid points.
The symmetry is searched from the input rotation matrices in real space.
Parameters
----------
mesh : array_like
Uniform sampling mesh numbers.
dtype='intc', shape=(3,)
rotations : array_like
Rotation m... | [
"Return",
"k",
"-",
"point",
"map",
"to",
"the",
"irreducible",
"k",
"-",
"points",
"and",
"k",
"-",
"point",
"grid",
"points",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L562-L631 | train |
atztogo/phonopy | phonopy/structure/spglib.py | relocate_BZ_grid_address | def relocate_BZ_grid_address(grid_address,
mesh,
reciprocal_lattice, # column vectors
is_shift=None,
is_dense=False):
"""Grid addresses are relocated to be inside first Brillouin zone.
Number of... | python | def relocate_BZ_grid_address(grid_address,
mesh,
reciprocal_lattice, # column vectors
is_shift=None,
is_dense=False):
"""Grid addresses are relocated to be inside first Brillouin zone.
Number of... | [
"def",
"relocate_BZ_grid_address",
"(",
"grid_address",
",",
"mesh",
",",
"reciprocal_lattice",
",",
"# column vectors",
"is_shift",
"=",
"None",
",",
"is_dense",
"=",
"False",
")",
":",
"_set_no_error",
"(",
")",
"if",
"is_shift",
"is",
"None",
":",
"_is_shift"... | Grid addresses are relocated to be inside first Brillouin zone.
Number of ir-grid-points inside Brillouin zone is returned.
It is assumed that the following arrays have the shapes of
bz_grid_address : (num_grid_points_in_FBZ, 3)
bz_map (prod(mesh * 2), )
Note that the shape of grid_address... | [
"Grid",
"addresses",
"are",
"relocated",
"to",
"be",
"inside",
"first",
"Brillouin",
"zone",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L751-L806 | train |
atztogo/phonopy | phonopy/structure/spglib.py | delaunay_reduce | def delaunay_reduce(lattice, eps=1e-5):
"""Run Delaunay reduction
Args:
lattice: Lattice parameters in the form of
[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
symprec:
float: Tolerance to check if volume is close to zero or not and
... | python | def delaunay_reduce(lattice, eps=1e-5):
"""Run Delaunay reduction
Args:
lattice: Lattice parameters in the form of
[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
symprec:
float: Tolerance to check if volume is close to zero or not and
... | [
"def",
"delaunay_reduce",
"(",
"lattice",
",",
"eps",
"=",
"1e-5",
")",
":",
"_set_no_error",
"(",
")",
"delaunay_lattice",
"=",
"np",
".",
"array",
"(",
"np",
".",
"transpose",
"(",
"lattice",
")",
",",
"dtype",
"=",
"'double'",
",",
"order",
"=",
"'C... | Run Delaunay reduction
Args:
lattice: Lattice parameters in the form of
[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
symprec:
float: Tolerance to check if volume is close to zero or not and
if two basis vectors are orthogon... | [
"Run",
"Delaunay",
"reduction"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L809-L841 | train |
atztogo/phonopy | phonopy/structure/spglib.py | niggli_reduce | def niggli_reduce(lattice, eps=1e-5):
"""Run Niggli reduction
Args:
lattice: Lattice parameters in the form of
[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
eps:
float: Tolerance to check if difference of norms of two basis
... | python | def niggli_reduce(lattice, eps=1e-5):
"""Run Niggli reduction
Args:
lattice: Lattice parameters in the form of
[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
eps:
float: Tolerance to check if difference of norms of two basis
... | [
"def",
"niggli_reduce",
"(",
"lattice",
",",
"eps",
"=",
"1e-5",
")",
":",
"_set_no_error",
"(",
")",
"niggli_lattice",
"=",
"np",
".",
"array",
"(",
"np",
".",
"transpose",
"(",
"lattice",
")",
",",
"dtype",
"=",
"'double'",
",",
"order",
"=",
"'C'",
... | Run Niggli reduction
Args:
lattice: Lattice parameters in the form of
[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
eps:
float: Tolerance to check if difference of norms of two basis
vectors is close to zero or not and if tw... | [
"Run",
"Niggli",
"reduction"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/spglib.py#L844-L877 | train |
atztogo/phonopy | phonopy/file_IO.py | get_FORCE_SETS_lines | def get_FORCE_SETS_lines(dataset, forces=None):
"""Generate FORCE_SETS string
See the format of dataset in the docstring of
Phonopy.set_displacement_dataset. Optionally for the type-1 (traditional)
format, forces can be given. In this case, sets of forces are
unnecessary to be stored in the dataset... | python | def get_FORCE_SETS_lines(dataset, forces=None):
"""Generate FORCE_SETS string
See the format of dataset in the docstring of
Phonopy.set_displacement_dataset. Optionally for the type-1 (traditional)
format, forces can be given. In this case, sets of forces are
unnecessary to be stored in the dataset... | [
"def",
"get_FORCE_SETS_lines",
"(",
"dataset",
",",
"forces",
"=",
"None",
")",
":",
"if",
"'first_atoms'",
"in",
"dataset",
":",
"return",
"_get_FORCE_SETS_lines_type1",
"(",
"dataset",
",",
"forces",
"=",
"forces",
")",
"elif",
"'forces'",
"in",
"dataset",
"... | Generate FORCE_SETS string
See the format of dataset in the docstring of
Phonopy.set_displacement_dataset. Optionally for the type-1 (traditional)
format, forces can be given. In this case, sets of forces are
unnecessary to be stored in the dataset. | [
"Generate",
"FORCE_SETS",
"string"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/file_IO.py#L52-L65 | train |
atztogo/phonopy | phonopy/file_IO.py | write_FORCE_CONSTANTS | def write_FORCE_CONSTANTS(force_constants,
filename='FORCE_CONSTANTS',
p2s_map=None):
"""Write force constants in text file format.
Parameters
----------
force_constants: ndarray
Force constants
shape=(n_satom,n_satom,3,3) or (n_patom,... | python | def write_FORCE_CONSTANTS(force_constants,
filename='FORCE_CONSTANTS',
p2s_map=None):
"""Write force constants in text file format.
Parameters
----------
force_constants: ndarray
Force constants
shape=(n_satom,n_satom,3,3) or (n_patom,... | [
"def",
"write_FORCE_CONSTANTS",
"(",
"force_constants",
",",
"filename",
"=",
"'FORCE_CONSTANTS'",
",",
"p2s_map",
"=",
"None",
")",
":",
"lines",
"=",
"get_FORCE_CONSTANTS_lines",
"(",
"force_constants",
",",
"p2s_map",
"=",
"p2s_map",
")",
"with",
"open",
"(",
... | Write force constants in text file format.
Parameters
----------
force_constants: ndarray
Force constants
shape=(n_satom,n_satom,3,3) or (n_patom,n_satom,3,3)
dtype=double
filename: str
Filename to be saved
p2s_map: ndarray
Primitive atom indices in supercell... | [
"Write",
"force",
"constants",
"in",
"text",
"file",
"format",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/file_IO.py#L243-L264 | train |
atztogo/phonopy | phonopy/file_IO.py | write_force_constants_to_hdf5 | def write_force_constants_to_hdf5(force_constants,
filename='force_constants.hdf5',
p2s_map=None,
physical_unit=None,
compression=None):
"""Write force constants in hdf5 format.
... | python | def write_force_constants_to_hdf5(force_constants,
filename='force_constants.hdf5',
p2s_map=None,
physical_unit=None,
compression=None):
"""Write force constants in hdf5 format.
... | [
"def",
"write_force_constants_to_hdf5",
"(",
"force_constants",
",",
"filename",
"=",
"'force_constants.hdf5'",
",",
"p2s_map",
"=",
"None",
",",
"physical_unit",
"=",
"None",
",",
"compression",
"=",
"None",
")",
":",
"try",
":",
"import",
"h5py",
"except",
"Im... | Write force constants in hdf5 format.
Parameters
----------
force_constants: ndarray
Force constants
shape=(n_satom,n_satom,3,3) or (n_patom,n_satom,3,3)
dtype=double
filename: str
Filename to be saved
p2s_map: ndarray
Primitive atom indices in supercell inde... | [
"Write",
"force",
"constants",
"in",
"hdf5",
"format",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/file_IO.py#L285-L326 | train |
atztogo/phonopy | phonopy/phonon/band_structure.py | get_band_qpoints | def get_band_qpoints(band_paths, npoints=51, rec_lattice=None):
"""Generate qpoints for band structure path
Note
----
Behavior changes with and without rec_lattice given.
Parameters
----------
band_paths: list of array_likes
Sets of end points of paths
dtype='double'
... | python | def get_band_qpoints(band_paths, npoints=51, rec_lattice=None):
"""Generate qpoints for band structure path
Note
----
Behavior changes with and without rec_lattice given.
Parameters
----------
band_paths: list of array_likes
Sets of end points of paths
dtype='double'
... | [
"def",
"get_band_qpoints",
"(",
"band_paths",
",",
"npoints",
"=",
"51",
",",
"rec_lattice",
"=",
"None",
")",
":",
"npts",
"=",
"_get_npts",
"(",
"band_paths",
",",
"npoints",
",",
"rec_lattice",
")",
"qpoints_of_paths",
"=",
"[",
"]",
"c",
"=",
"0",
"f... | Generate qpoints for band structure path
Note
----
Behavior changes with and without rec_lattice given.
Parameters
----------
band_paths: list of array_likes
Sets of end points of paths
dtype='double'
shape=(sets of paths, paths, 3)
example:
[[[0, ... | [
"Generate",
"qpoints",
"for",
"band",
"structure",
"path"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/phonon/band_structure.py#L70-L112 | train |
atztogo/phonopy | phonopy/phonon/band_structure.py | get_band_qpoints_by_seekpath | def get_band_qpoints_by_seekpath(primitive, npoints, is_const_interval=False):
"""q-points along BZ high symmetry paths are generated using seekpath.
Parameters
----------
primitive : PhonopyAtoms
Primitive cell.
npoints : int
Number of q-points sampled along a path including end po... | python | def get_band_qpoints_by_seekpath(primitive, npoints, is_const_interval=False):
"""q-points along BZ high symmetry paths are generated using seekpath.
Parameters
----------
primitive : PhonopyAtoms
Primitive cell.
npoints : int
Number of q-points sampled along a path including end po... | [
"def",
"get_band_qpoints_by_seekpath",
"(",
"primitive",
",",
"npoints",
",",
"is_const_interval",
"=",
"False",
")",
":",
"try",
":",
"import",
"seekpath",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"\"You need to install seekpath.\"",
")",
"band_path... | q-points along BZ high symmetry paths are generated using seekpath.
Parameters
----------
primitive : PhonopyAtoms
Primitive cell.
npoints : int
Number of q-points sampled along a path including end points.
is_const_interval : bool, optional
When True, q-points are sampled i... | [
"q",
"-",
"points",
"along",
"BZ",
"high",
"symmetry",
"paths",
"are",
"generated",
"using",
"seekpath",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/phonon/band_structure.py#L115-L165 | train |
atztogo/phonopy | phonopy/harmonic/dynmat_to_fc.py | get_commensurate_points | def get_commensurate_points(supercell_matrix): # wrt primitive cell
"""Commensurate q-points are returned.
Parameters
----------
supercell_matrix : array_like
Supercell matrix with respect to primitive cell basis vectors.
shape=(3, 3)
dtype=intc
"""
smat = np.array(su... | python | def get_commensurate_points(supercell_matrix): # wrt primitive cell
"""Commensurate q-points are returned.
Parameters
----------
supercell_matrix : array_like
Supercell matrix with respect to primitive cell basis vectors.
shape=(3, 3)
dtype=intc
"""
smat = np.array(su... | [
"def",
"get_commensurate_points",
"(",
"supercell_matrix",
")",
":",
"# wrt primitive cell",
"smat",
"=",
"np",
".",
"array",
"(",
"supercell_matrix",
",",
"dtype",
"=",
"int",
")",
"rec_primitive",
"=",
"PhonopyAtoms",
"(",
"numbers",
"=",
"[",
"1",
"]",
",",... | Commensurate q-points are returned.
Parameters
----------
supercell_matrix : array_like
Supercell matrix with respect to primitive cell basis vectors.
shape=(3, 3)
dtype=intc | [
"Commensurate",
"q",
"-",
"points",
"are",
"returned",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/dynmat_to_fc.py#L42-L62 | train |
atztogo/phonopy | phonopy/harmonic/dynmat_to_fc.py | get_commensurate_points_in_integers | def get_commensurate_points_in_integers(supercell_matrix):
"""Commensurate q-points in integer representation are returned.
A set of integer representation of lattice points is transformed to
the equivalent set of lattice points in fractional coordinates with
respect to supercell basis vectors by
... | python | def get_commensurate_points_in_integers(supercell_matrix):
"""Commensurate q-points in integer representation are returned.
A set of integer representation of lattice points is transformed to
the equivalent set of lattice points in fractional coordinates with
respect to supercell basis vectors by
... | [
"def",
"get_commensurate_points_in_integers",
"(",
"supercell_matrix",
")",
":",
"smat",
"=",
"np",
".",
"array",
"(",
"supercell_matrix",
",",
"dtype",
"=",
"int",
")",
"snf",
"=",
"SNF3x3",
"(",
"smat",
".",
"T",
")",
"snf",
".",
"run",
"(",
")",
"D",
... | Commensurate q-points in integer representation are returned.
A set of integer representation of lattice points is transformed to
the equivalent set of lattice points in fractional coordinates with
respect to supercell basis vectors by
integer_lattice_points / det(supercell_matrix)
Parameters
... | [
"Commensurate",
"q",
"-",
"points",
"in",
"integer",
"representation",
"are",
"returned",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/dynmat_to_fc.py#L65-L97 | train |
atztogo/phonopy | phonopy/interface/vasp.py | write_vasp | def write_vasp(filename, cell, direct=True):
"""Write crystal structure to a VASP POSCAR style file.
Parameters
----------
filename : str
Filename.
cell : PhonopyAtoms
Crystal structure.
direct : bool, optional
In 'Direct' or not in VASP POSCAR format. Default is True.
... | python | def write_vasp(filename, cell, direct=True):
"""Write crystal structure to a VASP POSCAR style file.
Parameters
----------
filename : str
Filename.
cell : PhonopyAtoms
Crystal structure.
direct : bool, optional
In 'Direct' or not in VASP POSCAR format. Default is True.
... | [
"def",
"write_vasp",
"(",
"filename",
",",
"cell",
",",
"direct",
"=",
"True",
")",
":",
"lines",
"=",
"get_vasp_structure_lines",
"(",
"cell",
",",
"direct",
"=",
"direct",
")",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"w",
":",
"w",
... | Write crystal structure to a VASP POSCAR style file.
Parameters
----------
filename : str
Filename.
cell : PhonopyAtoms
Crystal structure.
direct : bool, optional
In 'Direct' or not in VASP POSCAR format. Default is True. | [
"Write",
"crystal",
"structure",
"to",
"a",
"VASP",
"POSCAR",
"style",
"file",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/vasp.py#L249-L265 | train |
atztogo/phonopy | phonopy/interface/qe.py | PwscfIn._set_lattice | def _set_lattice(self):
"""Calculate and set lattice parameters.
Invoked by CELL_PARAMETERS tag.
"""
unit = self._values[0]
if unit == 'alat':
if not self._tags['celldm(1)']:
print("celldm(1) has to be specified when using alat.")
sy... | python | def _set_lattice(self):
"""Calculate and set lattice parameters.
Invoked by CELL_PARAMETERS tag.
"""
unit = self._values[0]
if unit == 'alat':
if not self._tags['celldm(1)']:
print("celldm(1) has to be specified when using alat.")
sy... | [
"def",
"_set_lattice",
"(",
"self",
")",
":",
"unit",
"=",
"self",
".",
"_values",
"[",
"0",
"]",
"if",
"unit",
"==",
"'alat'",
":",
"if",
"not",
"self",
".",
"_tags",
"[",
"'celldm(1)'",
"]",
":",
"print",
"(",
"\"celldm(1) has to be specified when using ... | Calculate and set lattice parameters.
Invoked by CELL_PARAMETERS tag. | [
"Calculate",
"and",
"set",
"lattice",
"parameters",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/qe.py#L278-L302 | train |
atztogo/phonopy | phonopy/interface/qe.py | PH_Q2R.run | def run(self, cell, is_full_fc=False, parse_fc=True):
"""Make supercell force constants readable for phonopy
Note
----
Born effective charges and dielectric constant tensor are read
from QE output file if they exist. But this means
dipole-dipole contributions are removed... | python | def run(self, cell, is_full_fc=False, parse_fc=True):
"""Make supercell force constants readable for phonopy
Note
----
Born effective charges and dielectric constant tensor are read
from QE output file if they exist. But this means
dipole-dipole contributions are removed... | [
"def",
"run",
"(",
"self",
",",
"cell",
",",
"is_full_fc",
"=",
"False",
",",
"parse_fc",
"=",
"True",
")",
":",
"with",
"open",
"(",
"self",
".",
"_filename",
")",
"as",
"f",
":",
"fc_dct",
"=",
"self",
".",
"_parse_q2r",
"(",
"f",
")",
"self",
... | Make supercell force constants readable for phonopy
Note
----
Born effective charges and dielectric constant tensor are read
from QE output file if they exist. But this means
dipole-dipole contributions are removed from force constants
and this force constants matrix is ... | [
"Make",
"supercell",
"force",
"constants",
"readable",
"for",
"phonopy"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/qe.py#L416-L447 | train |
atztogo/phonopy | phonopy/interface/qe.py | PH_Q2R._parse_q2r | def _parse_q2r(self, f):
"""Parse q2r output file
The format of q2r output is described at the mailing list below:
http://www.democritos.it/pipermail/pw_forum/2005-April/002408.html
http://www.democritos.it/pipermail/pw_forum/2008-September/010099.html
http://www.democritos.it/p... | python | def _parse_q2r(self, f):
"""Parse q2r output file
The format of q2r output is described at the mailing list below:
http://www.democritos.it/pipermail/pw_forum/2005-April/002408.html
http://www.democritos.it/pipermail/pw_forum/2008-September/010099.html
http://www.democritos.it/p... | [
"def",
"_parse_q2r",
"(",
"self",
",",
"f",
")",
":",
"natom",
",",
"dim",
",",
"epsilon",
",",
"borns",
"=",
"self",
".",
"_parse_parameters",
"(",
"f",
")",
"fc_dct",
"=",
"{",
"'fc'",
":",
"self",
".",
"_parse_fc",
"(",
"f",
",",
"natom",
",",
... | Parse q2r output file
The format of q2r output is described at the mailing list below:
http://www.democritos.it/pipermail/pw_forum/2005-April/002408.html
http://www.democritos.it/pipermail/pw_forum/2008-September/010099.html
http://www.democritos.it/pipermail/pw_forum/2009-August/013613... | [
"Parse",
"q2r",
"output",
"file"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/qe.py#L457-L473 | train |
atztogo/phonopy | phonopy/interface/qe.py | PH_Q2R._parse_fc | def _parse_fc(self, f, natom, dim):
"""Parse force constants part
Physical unit of force cosntants in the file is Ry/au^2.
"""
ndim = np.prod(dim)
fc = np.zeros((natom, natom * ndim, 3, 3), dtype='double', order='C')
for k, l, i, j in np.ndindex((3, 3, natom, natom)):
... | python | def _parse_fc(self, f, natom, dim):
"""Parse force constants part
Physical unit of force cosntants in the file is Ry/au^2.
"""
ndim = np.prod(dim)
fc = np.zeros((natom, natom * ndim, 3, 3), dtype='double', order='C')
for k, l, i, j in np.ndindex((3, 3, natom, natom)):
... | [
"def",
"_parse_fc",
"(",
"self",
",",
"f",
",",
"natom",
",",
"dim",
")",
":",
"ndim",
"=",
"np",
".",
"prod",
"(",
"dim",
")",
"fc",
"=",
"np",
".",
"zeros",
"(",
"(",
"natom",
",",
"natom",
"*",
"ndim",
",",
"3",
",",
"3",
")",
",",
"dtyp... | Parse force constants part
Physical unit of force cosntants in the file is Ry/au^2. | [
"Parse",
"force",
"constants",
"part"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/qe.py#L507-L522 | train |
atztogo/phonopy | phonopy/interface/cp2k.py | get_cp2k_structure | def get_cp2k_structure(atoms):
"""Convert the atoms structure to a CP2K input file skeleton string"""
from cp2k_tools.generator import dict2cp2k
# CP2K's default unit is angstrom, convert it, but still declare it explictly:
cp2k_cell = {sym: ('[angstrom]',) + tuple(coords) for sym, coords in zip(('a',... | python | def get_cp2k_structure(atoms):
"""Convert the atoms structure to a CP2K input file skeleton string"""
from cp2k_tools.generator import dict2cp2k
# CP2K's default unit is angstrom, convert it, but still declare it explictly:
cp2k_cell = {sym: ('[angstrom]',) + tuple(coords) for sym, coords in zip(('a',... | [
"def",
"get_cp2k_structure",
"(",
"atoms",
")",
":",
"from",
"cp2k_tools",
".",
"generator",
"import",
"dict2cp2k",
"# CP2K's default unit is angstrom, convert it, but still declare it explictly:",
"cp2k_cell",
"=",
"{",
"sym",
":",
"(",
"'[angstrom]'",
",",
")",
"+",
"... | Convert the atoms structure to a CP2K input file skeleton string | [
"Convert",
"the",
"atoms",
"structure",
"to",
"a",
"CP2K",
"input",
"file",
"skeleton",
"string"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/cp2k.py#L126-L156 | train |
atztogo/phonopy | phonopy/api_qha.py | PhonopyQHA.plot_qha | def plot_qha(self, thin_number=10, volume_temp_exp=None):
"""Returns matplotlib.pyplot of QHA fitting curves at temperatures"""
return self._qha.plot(thin_number=thin_number,
volume_temp_exp=volume_temp_exp) | python | def plot_qha(self, thin_number=10, volume_temp_exp=None):
"""Returns matplotlib.pyplot of QHA fitting curves at temperatures"""
return self._qha.plot(thin_number=thin_number,
volume_temp_exp=volume_temp_exp) | [
"def",
"plot_qha",
"(",
"self",
",",
"thin_number",
"=",
"10",
",",
"volume_temp_exp",
"=",
"None",
")",
":",
"return",
"self",
".",
"_qha",
".",
"plot",
"(",
"thin_number",
"=",
"thin_number",
",",
"volume_temp_exp",
"=",
"volume_temp_exp",
")"
] | Returns matplotlib.pyplot of QHA fitting curves at temperatures | [
"Returns",
"matplotlib",
".",
"pyplot",
"of",
"QHA",
"fitting",
"curves",
"at",
"temperatures"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_qha.py#L137-L140 | train |
atztogo/phonopy | phonopy/harmonic/force_constants.py | get_fc2 | def get_fc2(supercell,
symmetry,
dataset,
atom_list=None,
decimals=None):
"""Force constants are computed.
Force constants, Phi, are calculated from sets for forces, F, and
atomic displacement, d:
Phi = -F / d
This is solved by matrix pseudo-inversi... | python | def get_fc2(supercell,
symmetry,
dataset,
atom_list=None,
decimals=None):
"""Force constants are computed.
Force constants, Phi, are calculated from sets for forces, F, and
atomic displacement, d:
Phi = -F / d
This is solved by matrix pseudo-inversi... | [
"def",
"get_fc2",
"(",
"supercell",
",",
"symmetry",
",",
"dataset",
",",
"atom_list",
"=",
"None",
",",
"decimals",
"=",
"None",
")",
":",
"if",
"atom_list",
"is",
"None",
":",
"fc_dim0",
"=",
"supercell",
".",
"get_number_of_atoms",
"(",
")",
"else",
"... | Force constants are computed.
Force constants, Phi, are calculated from sets for forces, F, and
atomic displacement, d:
Phi = -F / d
This is solved by matrix pseudo-inversion.
Crystal symmetry is included when creating F and d matrices.
Returns
-------
ndarray
Force constants... | [
"Force",
"constants",
"are",
"computed",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/force_constants.py#L58-L113 | train |
atztogo/phonopy | phonopy/harmonic/force_constants.py | set_permutation_symmetry | def set_permutation_symmetry(force_constants):
"""Enforce permutation symmetry to force cosntants by
Phi_ij_ab = Phi_ji_ba
i, j: atom index
a, b: Cartesian axis index
This is not necessary for harmonic phonon calculation because this
condition is imposed when making dynamical matrix Hermite i... | python | def set_permutation_symmetry(force_constants):
"""Enforce permutation symmetry to force cosntants by
Phi_ij_ab = Phi_ji_ba
i, j: atom index
a, b: Cartesian axis index
This is not necessary for harmonic phonon calculation because this
condition is imposed when making dynamical matrix Hermite i... | [
"def",
"set_permutation_symmetry",
"(",
"force_constants",
")",
":",
"fc_copy",
"=",
"force_constants",
".",
"copy",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"force_constants",
".",
"shape",
"[",
"0",
"]",
")",
":",
"for",
"j",
"in",
"range",
"(",
"forc... | Enforce permutation symmetry to force cosntants by
Phi_ij_ab = Phi_ji_ba
i, j: atom index
a, b: Cartesian axis index
This is not necessary for harmonic phonon calculation because this
condition is imposed when making dynamical matrix Hermite in
dynamical_matrix.py. | [
"Enforce",
"permutation",
"symmetry",
"to",
"force",
"cosntants",
"by"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/force_constants.py#L462-L480 | train |
atztogo/phonopy | phonopy/harmonic/force_constants.py | similarity_transformation | def similarity_transformation(rot, mat):
""" R x M x R^-1 """
return np.dot(rot, np.dot(mat, np.linalg.inv(rot))) | python | def similarity_transformation(rot, mat):
""" R x M x R^-1 """
return np.dot(rot, np.dot(mat, np.linalg.inv(rot))) | [
"def",
"similarity_transformation",
"(",
"rot",
",",
"mat",
")",
":",
"return",
"np",
".",
"dot",
"(",
"rot",
",",
"np",
".",
"dot",
"(",
"mat",
",",
"np",
".",
"linalg",
".",
"inv",
"(",
"rot",
")",
")",
")"
] | R x M x R^-1 | [
"R",
"x",
"M",
"x",
"R^",
"-",
"1"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/force_constants.py#L529-L531 | train |
atztogo/phonopy | phonopy/harmonic/force_constants.py | _get_sym_mappings_from_permutations | def _get_sym_mappings_from_permutations(permutations, atom_list_done):
"""This can be thought of as computing 'map_atom_disp' and 'map_sym'
for all atoms, except done using permutations instead of by
computing overlaps.
Input:
* permutations, shape [num_rot][num_pos]
* atom_list_done
... | python | def _get_sym_mappings_from_permutations(permutations, atom_list_done):
"""This can be thought of as computing 'map_atom_disp' and 'map_sym'
for all atoms, except done using permutations instead of by
computing overlaps.
Input:
* permutations, shape [num_rot][num_pos]
* atom_list_done
... | [
"def",
"_get_sym_mappings_from_permutations",
"(",
"permutations",
",",
"atom_list_done",
")",
":",
"assert",
"permutations",
".",
"ndim",
"==",
"2",
"num_pos",
"=",
"permutations",
".",
"shape",
"[",
"1",
"]",
"# filled with -1",
"map_atoms",
"=",
"np",
".",
"z... | This can be thought of as computing 'map_atom_disp' and 'map_sym'
for all atoms, except done using permutations instead of by
computing overlaps.
Input:
* permutations, shape [num_rot][num_pos]
* atom_list_done
Output:
* map_atoms, shape [num_pos].
Maps each atom in the... | [
"This",
"can",
"be",
"thought",
"of",
"as",
"computing",
"map_atom_disp",
"and",
"map_sym",
"for",
"all",
"atoms",
"except",
"done",
"using",
"permutations",
"instead",
"of",
"by",
"computing",
"overlaps",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/force_constants.py#L778-L826 | train |
atztogo/phonopy | phonopy/harmonic/displacement.py | get_least_displacements | def get_least_displacements(symmetry,
is_plusminus='auto',
is_diagonal=True,
is_trigonal=False,
log_level=0):
"""Return a set of displacements
Returns
-------
array_like
List of direc... | python | def get_least_displacements(symmetry,
is_plusminus='auto',
is_diagonal=True,
is_trigonal=False,
log_level=0):
"""Return a set of displacements
Returns
-------
array_like
List of direc... | [
"def",
"get_least_displacements",
"(",
"symmetry",
",",
"is_plusminus",
"=",
"'auto'",
",",
"is_diagonal",
"=",
"True",
",",
"is_trigonal",
"=",
"False",
",",
"log_level",
"=",
"0",
")",
":",
"displacements",
"=",
"[",
"]",
"if",
"is_diagonal",
":",
"directi... | Return a set of displacements
Returns
-------
array_like
List of directions with respect to axes. This gives only the
symmetrically non equivalent directions. The format is like:
[[0, 1, 0, 0],
[7, 1, 0, 1], ...]
where each list is defined by:
First... | [
"Return",
"a",
"set",
"of",
"displacements"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/harmonic/displacement.py#L74-L127 | train |
atztogo/phonopy | phonopy/interface/FHIaims.py | read_aims | def read_aims(filename):
"""Method to read FHI-aims geometry files in phonopy context."""
lines = open(filename, 'r').readlines()
cell = []
is_frac = []
positions = []
symbols = []
magmoms = []
for line in lines:
fields = line.split()
if not len(fields):
con... | python | def read_aims(filename):
"""Method to read FHI-aims geometry files in phonopy context."""
lines = open(filename, 'r').readlines()
cell = []
is_frac = []
positions = []
symbols = []
magmoms = []
for line in lines:
fields = line.split()
if not len(fields):
con... | [
"def",
"read_aims",
"(",
"filename",
")",
":",
"lines",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
".",
"readlines",
"(",
")",
"cell",
"=",
"[",
"]",
"is_frac",
"=",
"[",
"]",
"positions",
"=",
"[",
"]",
"symbols",
"=",
"[",
"]",
"magmoms",
"... | Method to read FHI-aims geometry files in phonopy context. | [
"Method",
"to",
"read",
"FHI",
"-",
"aims",
"geometry",
"files",
"in",
"phonopy",
"context",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/FHIaims.py#L49-L92 | train |
atztogo/phonopy | phonopy/interface/FHIaims.py | write_aims | def write_aims(filename, atoms):
"""Method to write FHI-aims geometry files in phonopy context."""
lines = ""
lines += "# geometry.in for FHI-aims \n"
lines += "# | generated by phonopy.FHIaims.write_aims() \n"
lattice_vector_line = "lattice_vector " + "%16.16f "*3 + "\n"
for vec in atoms.get_... | python | def write_aims(filename, atoms):
"""Method to write FHI-aims geometry files in phonopy context."""
lines = ""
lines += "# geometry.in for FHI-aims \n"
lines += "# | generated by phonopy.FHIaims.write_aims() \n"
lattice_vector_line = "lattice_vector " + "%16.16f "*3 + "\n"
for vec in atoms.get_... | [
"def",
"write_aims",
"(",
"filename",
",",
"atoms",
")",
":",
"lines",
"=",
"\"\"",
"lines",
"+=",
"\"# geometry.in for FHI-aims \\n\"",
"lines",
"+=",
"\"# | generated by phonopy.FHIaims.write_aims() \\n\"",
"lattice_vector_line",
"=",
"\"lattice_vector \"",
"+",
"\"%16.16... | Method to write FHI-aims geometry files in phonopy context. | [
"Method",
"to",
"write",
"FHI",
"-",
"aims",
"geometry",
"files",
"in",
"phonopy",
"context",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/FHIaims.py#L95-L121 | train |
atztogo/phonopy | phonopy/interface/FHIaims.py | read_aims_output | def read_aims_output(filename):
""" Read FHI-aims output and
return geometry, energy and forces from last self-consistency iteration"""
lines = open(filename, 'r').readlines()
l = 0
N = 0
while l < len(lines):
line = lines[l]
if "| Number of atoms" in line:
N =... | python | def read_aims_output(filename):
""" Read FHI-aims output and
return geometry, energy and forces from last self-consistency iteration"""
lines = open(filename, 'r').readlines()
l = 0
N = 0
while l < len(lines):
line = lines[l]
if "| Number of atoms" in line:
N =... | [
"def",
"read_aims_output",
"(",
"filename",
")",
":",
"lines",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
".",
"readlines",
"(",
")",
"l",
"=",
"0",
"N",
"=",
"0",
"while",
"l",
"<",
"len",
"(",
"lines",
")",
":",
"line",
"=",
"lines",
"[",
... | Read FHI-aims output and
return geometry, energy and forces from last self-consistency iteration | [
"Read",
"FHI",
"-",
"aims",
"output",
"and",
"return",
"geometry",
"energy",
"and",
"forces",
"from",
"last",
"self",
"-",
"consistency",
"iteration"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/FHIaims.py#L132-L178 | train |
atztogo/phonopy | phonopy/structure/symmetry.py | find_primitive | def find_primitive(cell, symprec=1e-5):
"""
A primitive cell is searched in the input cell. When a primitive
cell is found, an object of Atoms class of the primitive cell is
returned. When not, None is returned.
"""
lattice, positions, numbers = spg.find_primitive(cell.totuple(), symprec)
if... | python | def find_primitive(cell, symprec=1e-5):
"""
A primitive cell is searched in the input cell. When a primitive
cell is found, an object of Atoms class of the primitive cell is
returned. When not, None is returned.
"""
lattice, positions, numbers = spg.find_primitive(cell.totuple(), symprec)
if... | [
"def",
"find_primitive",
"(",
"cell",
",",
"symprec",
"=",
"1e-5",
")",
":",
"lattice",
",",
"positions",
",",
"numbers",
"=",
"spg",
".",
"find_primitive",
"(",
"cell",
".",
"totuple",
"(",
")",
",",
"symprec",
")",
"if",
"lattice",
"is",
"None",
":",... | A primitive cell is searched in the input cell. When a primitive
cell is found, an object of Atoms class of the primitive cell is
returned. When not, None is returned. | [
"A",
"primitive",
"cell",
"is",
"searched",
"in",
"the",
"input",
"cell",
".",
"When",
"a",
"primitive",
"cell",
"is",
"found",
"an",
"object",
"of",
"Atoms",
"class",
"of",
"the",
"primitive",
"cell",
"is",
"returned",
".",
"When",
"not",
"None",
"is",
... | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/symmetry.py#L300-L313 | train |
atztogo/phonopy | phonopy/structure/symmetry.py | elaborate_borns_and_epsilon | def elaborate_borns_and_epsilon(ucell,
borns,
epsilon,
primitive_matrix=None,
supercell_matrix=None,
is_symmetry=True,
symmetriz... | python | def elaborate_borns_and_epsilon(ucell,
borns,
epsilon,
primitive_matrix=None,
supercell_matrix=None,
is_symmetry=True,
symmetriz... | [
"def",
"elaborate_borns_and_epsilon",
"(",
"ucell",
",",
"borns",
",",
"epsilon",
",",
"primitive_matrix",
"=",
"None",
",",
"supercell_matrix",
"=",
"None",
",",
"is_symmetry",
"=",
"True",
",",
"symmetrize_tensors",
"=",
"False",
",",
"symprec",
"=",
"1e-5",
... | Symmetrize Born effective charges and dielectric constants and
extract Born effective charges of symmetrically independent atoms
for primitive cell.
Args:
ucell (Atoms): Unit cell structure
borns (np.array): Born effective charges of ucell
epsilon (np.array): Dielectric constan... | [
"Symmetrize",
"Born",
"effective",
"charges",
"and",
"dielectric",
"constants",
"and",
"extract",
"Born",
"effective",
"charges",
"of",
"symmetrically",
"independent",
"atoms",
"for",
"primitive",
"cell",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/symmetry.py#L343-L399 | train |
atztogo/phonopy | phonopy/structure/symmetry.py | symmetrize_borns_and_epsilon | def symmetrize_borns_and_epsilon(borns,
epsilon,
ucell,
primitive_matrix=None,
supercell_matrix=None,
symprec=1e-5,
is_sym... | python | def symmetrize_borns_and_epsilon(borns,
epsilon,
ucell,
primitive_matrix=None,
supercell_matrix=None,
symprec=1e-5,
is_sym... | [
"def",
"symmetrize_borns_and_epsilon",
"(",
"borns",
",",
"epsilon",
",",
"ucell",
",",
"primitive_matrix",
"=",
"None",
",",
"supercell_matrix",
"=",
"None",
",",
"symprec",
"=",
"1e-5",
",",
"is_symmetry",
"=",
"True",
")",
":",
"lattice",
"=",
"ucell",
".... | Symmetrize Born effective charges and dielectric tensor
Parameters
----------
borns: array_like
Born effective charges.
shape=(unitcell_atoms, 3, 3)
dtype='double'
epsilon: array_like
Dielectric constant
shape=(3, 3)
dtype='double'
ucell: PhonopyAtoms... | [
"Symmetrize",
"Born",
"effective",
"charges",
"and",
"dielectric",
"tensor"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/symmetry.py#L402-L488 | train |
atztogo/phonopy | phonopy/interface/dftbp.py | read_dftbp | def read_dftbp(filename):
""" Reads DFTB+ structure files in gen format.
Args:
filename: name of the gen-file to be read
Returns:
atoms: an object of the phonopy.Atoms class, representing the structure
found in filename
"""
infile = open(filename, 'r')
lines = infile.... | python | def read_dftbp(filename):
""" Reads DFTB+ structure files in gen format.
Args:
filename: name of the gen-file to be read
Returns:
atoms: an object of the phonopy.Atoms class, representing the structure
found in filename
"""
infile = open(filename, 'r')
lines = infile.... | [
"def",
"read_dftbp",
"(",
"filename",
")",
":",
"infile",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"lines",
"=",
"infile",
".",
"readlines",
"(",
")",
"# remove any comments",
"for",
"ss",
"in",
"lines",
":",
"if",
"ss",
".",
"strip",
"(",
")",
... | Reads DFTB+ structure files in gen format.
Args:
filename: name of the gen-file to be read
Returns:
atoms: an object of the phonopy.Atoms class, representing the structure
found in filename | [
"Reads",
"DFTB",
"+",
"structure",
"files",
"in",
"gen",
"format",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/dftbp.py#L72-L135 | train |
atztogo/phonopy | phonopy/interface/dftbp.py | get_reduced_symbols | def get_reduced_symbols(symbols):
"""Reduces expanded list of symbols.
Args:
symbols: list containing any chemical symbols as often as
the atom appears in the structure
Returns:
reduced_symbols: any symbols appears only once
"""
reduced_symbols = []
for ss in symbols:... | python | def get_reduced_symbols(symbols):
"""Reduces expanded list of symbols.
Args:
symbols: list containing any chemical symbols as often as
the atom appears in the structure
Returns:
reduced_symbols: any symbols appears only once
"""
reduced_symbols = []
for ss in symbols:... | [
"def",
"get_reduced_symbols",
"(",
"symbols",
")",
":",
"reduced_symbols",
"=",
"[",
"]",
"for",
"ss",
"in",
"symbols",
":",
"if",
"not",
"(",
"ss",
"in",
"reduced_symbols",
")",
":",
"reduced_symbols",
".",
"append",
"(",
"ss",
")",
"return",
"reduced_sym... | Reduces expanded list of symbols.
Args:
symbols: list containing any chemical symbols as often as
the atom appears in the structure
Returns:
reduced_symbols: any symbols appears only once | [
"Reduces",
"expanded",
"list",
"of",
"symbols",
"."
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/dftbp.py#L140-L157 | train |
atztogo/phonopy | phonopy/interface/dftbp.py | write_dftbp | def write_dftbp(filename, atoms):
"""Writes DFTB+ readable, gen-formatted structure files
Args:
filename: name of the gen-file to be written
atoms: object containing information about structure
"""
scale_pos = dftbpToBohr
lines = ""
# 1. line, use absolute positions
natoms... | python | def write_dftbp(filename, atoms):
"""Writes DFTB+ readable, gen-formatted structure files
Args:
filename: name of the gen-file to be written
atoms: object containing information about structure
"""
scale_pos = dftbpToBohr
lines = ""
# 1. line, use absolute positions
natoms... | [
"def",
"write_dftbp",
"(",
"filename",
",",
"atoms",
")",
":",
"scale_pos",
"=",
"dftbpToBohr",
"lines",
"=",
"\"\"",
"# 1. line, use absolute positions",
"natoms",
"=",
"atoms",
".",
"get_number_of_atoms",
"(",
")",
"lines",
"+=",
"str",
"(",
"natoms",
")",
"... | Writes DFTB+ readable, gen-formatted structure files
Args:
filename: name of the gen-file to be written
atoms: object containing information about structure | [
"Writes",
"DFTB",
"+",
"readable",
"gen",
"-",
"formatted",
"structure",
"files"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/dftbp.py#L159-L203 | train |
atztogo/phonopy | phonopy/interface/dftbp.py | write_supercells_with_displacements | def write_supercells_with_displacements(supercell, cells_with_disps, filename="geo.gen"):
"""Writes perfect supercell and supercells with displacements
Args:
supercell: perfect supercell
cells_with_disps: supercells with displaced atoms
filename: root-filename
"""
# original ce... | python | def write_supercells_with_displacements(supercell, cells_with_disps, filename="geo.gen"):
"""Writes perfect supercell and supercells with displacements
Args:
supercell: perfect supercell
cells_with_disps: supercells with displaced atoms
filename: root-filename
"""
# original ce... | [
"def",
"write_supercells_with_displacements",
"(",
"supercell",
",",
"cells_with_disps",
",",
"filename",
"=",
"\"geo.gen\"",
")",
":",
"# original cell",
"write_dftbp",
"(",
"filename",
"+",
"\"S\"",
",",
"supercell",
")",
"# displaced cells",
"for",
"ii",
"in",
"r... | Writes perfect supercell and supercells with displacements
Args:
supercell: perfect supercell
cells_with_disps: supercells with displaced atoms
filename: root-filename | [
"Writes",
"perfect",
"supercell",
"and",
"supercells",
"with",
"displacements"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/dftbp.py#L205-L219 | train |
atztogo/phonopy | phonopy/interface/__init__.py | get_interface_mode | def get_interface_mode(args):
"""Return calculator name
The calculator name is obtained from command option arguments where
argparse is used. The argument attribute name has to be
"{calculator}_mode". Then this method returns {calculator}.
"""
calculator_list = ['wien2k', 'abinit', 'qe', 'elk... | python | def get_interface_mode(args):
"""Return calculator name
The calculator name is obtained from command option arguments where
argparse is used. The argument attribute name has to be
"{calculator}_mode". Then this method returns {calculator}.
"""
calculator_list = ['wien2k', 'abinit', 'qe', 'elk... | [
"def",
"get_interface_mode",
"(",
"args",
")",
":",
"calculator_list",
"=",
"[",
"'wien2k'",
",",
"'abinit'",
",",
"'qe'",
",",
"'elk'",
",",
"'siesta'",
",",
"'cp2k'",
",",
"'crystal'",
",",
"'vasp'",
",",
"'dftbp'",
",",
"'turbomole'",
"]",
"for",
"calcu... | Return calculator name
The calculator name is obtained from command option arguments where
argparse is used. The argument attribute name has to be
"{calculator}_mode". Then this method returns {calculator}. | [
"Return",
"calculator",
"name"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/__init__.py#L40-L55 | train |
atztogo/phonopy | phonopy/interface/__init__.py | get_default_physical_units | def get_default_physical_units(interface_mode=None):
"""Return physical units used for calculators
Physical units: energy, distance, atomic mass, force
vasp : eV, Angstrom, AMU, eV/Angstrom
wien2k : Ry, au(=borh), AMU, mRy/au
abinit : hartree, au,... | python | def get_default_physical_units(interface_mode=None):
"""Return physical units used for calculators
Physical units: energy, distance, atomic mass, force
vasp : eV, Angstrom, AMU, eV/Angstrom
wien2k : Ry, au(=borh), AMU, mRy/au
abinit : hartree, au,... | [
"def",
"get_default_physical_units",
"(",
"interface_mode",
"=",
"None",
")",
":",
"from",
"phonopy",
".",
"units",
"import",
"(",
"Wien2kToTHz",
",",
"AbinitToTHz",
",",
"PwscfToTHz",
",",
"ElkToTHz",
",",
"SiestaToTHz",
",",
"VaspToTHz",
",",
"CP2KToTHz",
",",... | Return physical units used for calculators
Physical units: energy, distance, atomic mass, force
vasp : eV, Angstrom, AMU, eV/Angstrom
wien2k : Ry, au(=borh), AMU, mRy/au
abinit : hartree, au, AMU, eV/Angstrom
elk : hartree... | [
"Return",
"physical",
"units",
"used",
"for",
"calculators"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/interface/__init__.py#L231-L318 | train |
atztogo/phonopy | phonopy/structure/tetrahedron_method.py | get_tetrahedra_integration_weight | def get_tetrahedra_integration_weight(omegas,
tetrahedra_omegas,
function='I'):
"""Returns integration weights
Parameters
----------
omegas : float or list of float values
Energy(s) at which the integration weight(s) ar... | python | def get_tetrahedra_integration_weight(omegas,
tetrahedra_omegas,
function='I'):
"""Returns integration weights
Parameters
----------
omegas : float or list of float values
Energy(s) at which the integration weight(s) ar... | [
"def",
"get_tetrahedra_integration_weight",
"(",
"omegas",
",",
"tetrahedra_omegas",
",",
"function",
"=",
"'I'",
")",
":",
"if",
"isinstance",
"(",
"omegas",
",",
"float",
")",
":",
"return",
"phonoc",
".",
"tetrahedra_integration_weight",
"(",
"omegas",
",",
"... | Returns integration weights
Parameters
----------
omegas : float or list of float values
Energy(s) at which the integration weight(s) are computed.
tetrahedra_omegas : ndarray of list of list
Energies at vertices of 24 tetrahedra
shape=(24, 4)
dytpe='double'
function... | [
"Returns",
"integration",
"weights"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L95-L125 | train |
atztogo/phonopy | phonopy/structure/tetrahedron_method.py | TetrahedronMethod._g_1 | def _g_1(self):
"""omega1 < omega < omega2"""
# return 3 * self._n_1() / (self._omega - self._vertices_omegas[0])
return (3 * self._f(1, 0) * self._f(2, 0) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | python | def _g_1(self):
"""omega1 < omega < omega2"""
# return 3 * self._n_1() / (self._omega - self._vertices_omegas[0])
return (3 * self._f(1, 0) * self._f(2, 0) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | [
"def",
"_g_1",
"(",
"self",
")",
":",
"# return 3 * self._n_1() / (self._omega - self._vertices_omegas[0])",
"return",
"(",
"3",
"*",
"self",
".",
"_f",
"(",
"1",
",",
"0",
")",
"*",
"self",
".",
"_f",
"(",
"2",
",",
"0",
")",
"/",
"(",
"self",
".",
"_... | omega1 < omega < omega2 | [
"omega1",
"<",
"omega",
"<",
"omega2"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L438-L442 | train |
atztogo/phonopy | phonopy/structure/tetrahedron_method.py | TetrahedronMethod._g_3 | def _g_3(self):
"""omega3 < omega < omega4"""
# return 3 * (1.0 - self._n_3()) / (self._vertices_omegas[3] - self._omega)
return (3 * self._f(1, 3) * self._f(2, 3) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | python | def _g_3(self):
"""omega3 < omega < omega4"""
# return 3 * (1.0 - self._n_3()) / (self._vertices_omegas[3] - self._omega)
return (3 * self._f(1, 3) * self._f(2, 3) /
(self._vertices_omegas[3] - self._vertices_omegas[0])) | [
"def",
"_g_3",
"(",
"self",
")",
":",
"# return 3 * (1.0 - self._n_3()) / (self._vertices_omegas[3] - self._omega)",
"return",
"(",
"3",
"*",
"self",
".",
"_f",
"(",
"1",
",",
"3",
")",
"*",
"self",
".",
"_f",
"(",
"2",
",",
"3",
")",
"/",
"(",
"self",
"... | omega3 < omega < omega4 | [
"omega3",
"<",
"omega",
"<",
"omega4"
] | 869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/tetrahedron_method.py#L450-L454 | train |
mattupstate/flask-security | flask_security/datastore.py | UserDatastore.deactivate_user | def deactivate_user(self, user):
"""Deactivates a specified user. Returns `True` if a change was made.
:param user: The user to deactivate
"""
if user.active:
user.active = False
return True
return False | python | def deactivate_user(self, user):
"""Deactivates a specified user. Returns `True` if a change was made.
:param user: The user to deactivate
"""
if user.active:
user.active = False
return True
return False | [
"def",
"deactivate_user",
"(",
"self",
",",
"user",
")",
":",
"if",
"user",
".",
"active",
":",
"user",
".",
"active",
"=",
"False",
"return",
"True",
"return",
"False"
] | Deactivates a specified user. Returns `True` if a change was made.
:param user: The user to deactivate | [
"Deactivates",
"a",
"specified",
"user",
".",
"Returns",
"True",
"if",
"a",
"change",
"was",
"made",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L180-L188 | train |
mattupstate/flask-security | flask_security/datastore.py | UserDatastore.activate_user | def activate_user(self, user):
"""Activates a specified user. Returns `True` if a change was made.
:param user: The user to activate
"""
if not user.active:
user.active = True
return True
return False | python | def activate_user(self, user):
"""Activates a specified user. Returns `True` if a change was made.
:param user: The user to activate
"""
if not user.active:
user.active = True
return True
return False | [
"def",
"activate_user",
"(",
"self",
",",
"user",
")",
":",
"if",
"not",
"user",
".",
"active",
":",
"user",
".",
"active",
"=",
"True",
"return",
"True",
"return",
"False"
] | Activates a specified user. Returns `True` if a change was made.
:param user: The user to activate | [
"Activates",
"a",
"specified",
"user",
".",
"Returns",
"True",
"if",
"a",
"change",
"was",
"made",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L190-L198 | train |
mattupstate/flask-security | flask_security/datastore.py | UserDatastore.create_role | def create_role(self, **kwargs):
"""Creates and returns a new role from the given parameters."""
role = self.role_model(**kwargs)
return self.put(role) | python | def create_role(self, **kwargs):
"""Creates and returns a new role from the given parameters."""
role = self.role_model(**kwargs)
return self.put(role) | [
"def",
"create_role",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"role",
"=",
"self",
".",
"role_model",
"(",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"put",
"(",
"role",
")"
] | Creates and returns a new role from the given parameters. | [
"Creates",
"and",
"returns",
"a",
"new",
"role",
"from",
"the",
"given",
"parameters",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L200-L204 | train |
mattupstate/flask-security | flask_security/datastore.py | UserDatastore.find_or_create_role | def find_or_create_role(self, name, **kwargs):
"""Returns a role matching the given name or creates it with any
additionally provided parameters.
"""
kwargs["name"] = name
return self.find_role(name) or self.create_role(**kwargs) | python | def find_or_create_role(self, name, **kwargs):
"""Returns a role matching the given name or creates it with any
additionally provided parameters.
"""
kwargs["name"] = name
return self.find_role(name) or self.create_role(**kwargs) | [
"def",
"find_or_create_role",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"name\"",
"]",
"=",
"name",
"return",
"self",
".",
"find_role",
"(",
"name",
")",
"or",
"self",
".",
"create_role",
"(",
"*",
"*",
"kwargs",
"... | Returns a role matching the given name or creates it with any
additionally provided parameters. | [
"Returns",
"a",
"role",
"matching",
"the",
"given",
"name",
"or",
"creates",
"it",
"with",
"any",
"additionally",
"provided",
"parameters",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/datastore.py#L206-L211 | train |
mattupstate/flask-security | flask_security/decorators.py | http_auth_required | def http_auth_required(realm):
"""Decorator that protects endpoints using Basic HTTP authentication.
:param realm: optional realm name"""
def decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
if _check_http_auth():
return fn(*args, **kwargs)
if... | python | def http_auth_required(realm):
"""Decorator that protects endpoints using Basic HTTP authentication.
:param realm: optional realm name"""
def decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
if _check_http_auth():
return fn(*args, **kwargs)
if... | [
"def",
"http_auth_required",
"(",
"realm",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"_check_http_auth",
"(",
")",
":",
"return",
"f... | Decorator that protects endpoints using Basic HTTP authentication.
:param realm: optional realm name | [
"Decorator",
"that",
"protects",
"endpoints",
"using",
"Basic",
"HTTP",
"authentication",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/decorators.py#L93-L114 | train |
mattupstate/flask-security | flask_security/decorators.py | auth_token_required | def auth_token_required(fn):
"""Decorator that protects endpoints using token authentication. The token
should be added to the request by the client by using a query string
variable with a name equal to the configuration value of
`SECURITY_TOKEN_AUTHENTICATION_KEY` or in a request header named that of
... | python | def auth_token_required(fn):
"""Decorator that protects endpoints using token authentication. The token
should be added to the request by the client by using a query string
variable with a name equal to the configuration value of
`SECURITY_TOKEN_AUTHENTICATION_KEY` or in a request header named that of
... | [
"def",
"auth_token_required",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"_check_token",
"(",
")",
":",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwarg... | Decorator that protects endpoints using token authentication. The token
should be added to the request by the client by using a query string
variable with a name equal to the configuration value of
`SECURITY_TOKEN_AUTHENTICATION_KEY` or in a request header named that of
the configuration value of `SECUR... | [
"Decorator",
"that",
"protects",
"endpoints",
"using",
"token",
"authentication",
".",
"The",
"token",
"should",
"be",
"added",
"to",
"the",
"request",
"by",
"the",
"client",
"by",
"using",
"a",
"query",
"string",
"variable",
"with",
"a",
"name",
"equal",
"t... | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/decorators.py#L117-L133 | train |
mattupstate/flask-security | flask_security/confirmable.py | confirm_user | def confirm_user(user):
"""Confirms the specified user
:param user: The user to confirm
"""
if user.confirmed_at is not None:
return False
user.confirmed_at = _security.datetime_factory()
_datastore.put(user)
user_confirmed.send(app._get_current_object(), user=user)
return True | python | def confirm_user(user):
"""Confirms the specified user
:param user: The user to confirm
"""
if user.confirmed_at is not None:
return False
user.confirmed_at = _security.datetime_factory()
_datastore.put(user)
user_confirmed.send(app._get_current_object(), user=user)
return True | [
"def",
"confirm_user",
"(",
"user",
")",
":",
"if",
"user",
".",
"confirmed_at",
"is",
"not",
"None",
":",
"return",
"False",
"user",
".",
"confirmed_at",
"=",
"_security",
".",
"datetime_factory",
"(",
")",
"_datastore",
".",
"put",
"(",
"user",
")",
"u... | Confirms the specified user
:param user: The user to confirm | [
"Confirms",
"the",
"specified",
"user"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/confirmable.py#L82-L92 | train |
mattupstate/flask-security | flask_security/recoverable.py | send_password_reset_notice | def send_password_reset_notice(user):
"""Sends the password reset notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_RESET_NOTICE_EMAIL'):
_security.send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'),
... | python | def send_password_reset_notice(user):
"""Sends the password reset notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_RESET_NOTICE_EMAIL'):
_security.send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'),
... | [
"def",
"send_password_reset_notice",
"(",
"user",
")",
":",
"if",
"config_value",
"(",
"'SEND_PASSWORD_RESET_NOTICE_EMAIL'",
")",
":",
"_security",
".",
"send_mail",
"(",
"config_value",
"(",
"'EMAIL_SUBJECT_PASSWORD_NOTICE'",
")",
",",
"user",
".",
"email",
",",
"'... | Sends the password reset notice email for the specified user.
:param user: The user to send the notice to | [
"Sends",
"the",
"password",
"reset",
"notice",
"email",
"for",
"the",
"specified",
"user",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/recoverable.py#L45-L52 | train |
mattupstate/flask-security | flask_security/recoverable.py | update_password | def update_password(user, password):
"""Update the specified user's password
:param user: The user to update_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_reset_notice(user)
password_reset.send(app._get... | python | def update_password(user, password):
"""Update the specified user's password
:param user: The user to update_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_reset_notice(user)
password_reset.send(app._get... | [
"def",
"update_password",
"(",
"user",
",",
"password",
")",
":",
"user",
".",
"password",
"=",
"hash_password",
"(",
"password",
")",
"_datastore",
".",
"put",
"(",
"user",
")",
"send_password_reset_notice",
"(",
"user",
")",
"password_reset",
".",
"send",
... | Update the specified user's password
:param user: The user to update_password
:param password: The unhashed new password | [
"Update",
"the",
"specified",
"user",
"s",
"password"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/recoverable.py#L84-L93 | train |
mattupstate/flask-security | flask_security/core.py | Security.init_app | def init_app(self, app, datastore=None, register_blueprint=None, **kwargs):
"""Initializes the Flask-Security extension for the specified
application and datastore implementation.
:param app: The application.
:param datastore: An instance of a user datastore.
:param register_blu... | python | def init_app(self, app, datastore=None, register_blueprint=None, **kwargs):
"""Initializes the Flask-Security extension for the specified
application and datastore implementation.
:param app: The application.
:param datastore: An instance of a user datastore.
:param register_blu... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"datastore",
"=",
"None",
",",
"register_blueprint",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"app",
"=",
"app",
"if",
"datastore",
"is",
"None",
":",
"datastore",
"=",
"self",
".",... | Initializes the Flask-Security extension for the specified
application and datastore implementation.
:param app: The application.
:param datastore: An instance of a user datastore.
:param register_blueprint: to register the Security blueprint or not. | [
"Initializes",
"the",
"Flask",
"-",
"Security",
"extension",
"for",
"the",
"specified",
"application",
"and",
"datastore",
"implementation",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/core.py#L511-L560 | train |
mattupstate/flask-security | flask_security/views.py | login | def login():
"""View function for login view"""
form_class = _security.login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class(request.form)
if form.validate_on_submit():
login_user(form.user, remember=form.remember.data)
... | python | def login():
"""View function for login view"""
form_class = _security.login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class(request.form)
if form.validate_on_submit():
login_user(form.user, remember=form.remember.data)
... | [
"def",
"login",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"login_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form",
"=",
"form_cl... | View function for login view | [
"View",
"function",
"for",
"login",
"view"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L67-L89 | train |
mattupstate/flask-security | flask_security/views.py | register | def register():
"""View function which handles a registration request."""
if _security.confirmable or request.is_json:
form_class = _security.confirm_register_form
else:
form_class = _security.register_form
if request.is_json:
form_data = MultiDict(request.get_json())
else:... | python | def register():
"""View function which handles a registration request."""
if _security.confirmable or request.is_json:
form_class = _security.confirm_register_form
else:
form_class = _security.register_form
if request.is_json:
form_data = MultiDict(request.get_json())
else:... | [
"def",
"register",
"(",
")",
":",
"if",
"_security",
".",
"confirmable",
"or",
"request",
".",
"is_json",
":",
"form_class",
"=",
"_security",
".",
"confirm_register_form",
"else",
":",
"form_class",
"=",
"_security",
".",
"register_form",
"if",
"request",
"."... | View function which handles a registration request. | [
"View",
"function",
"which",
"handles",
"a",
"registration",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L102-L139 | train |
mattupstate/flask-security | flask_security/views.py | send_login | def send_login():
"""View function that sends login instructions for passwordless login"""
form_class = _security.passwordless_login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_login... | python | def send_login():
"""View function that sends login instructions for passwordless login"""
form_class = _security.passwordless_login_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_login... | [
"def",
"send_login",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"passwordless_login_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form",... | View function that sends login instructions for passwordless login | [
"View",
"function",
"that",
"sends",
"login",
"instructions",
"for",
"passwordless",
"login"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L142-L162 | train |
mattupstate/flask-security | flask_security/views.py | token_login | def token_login(token):
"""View function that handles passwordless login via a token"""
expired, invalid, user = login_token_status(token)
if invalid:
do_flash(*get_message('INVALID_LOGIN_TOKEN'))
if expired:
send_login_instructions(user)
do_flash(*get_message('LOGIN_EXPIRED', ... | python | def token_login(token):
"""View function that handles passwordless login via a token"""
expired, invalid, user = login_token_status(token)
if invalid:
do_flash(*get_message('INVALID_LOGIN_TOKEN'))
if expired:
send_login_instructions(user)
do_flash(*get_message('LOGIN_EXPIRED', ... | [
"def",
"token_login",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"login_token_status",
"(",
"token",
")",
"if",
"invalid",
":",
"do_flash",
"(",
"*",
"get_message",
"(",
"'INVALID_LOGIN_TOKEN'",
")",
")",
"if",
"expired",
":",
"se... | View function that handles passwordless login via a token | [
"View",
"function",
"that",
"handles",
"passwordless",
"login",
"via",
"a",
"token"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L166-L184 | train |
mattupstate/flask-security | flask_security/views.py | send_confirmation | def send_confirmation():
"""View function which sends confirmation instructions."""
form_class = _security.send_confirmation_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_confirmation_... | python | def send_confirmation():
"""View function which sends confirmation instructions."""
form_class = _security.send_confirmation_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_confirmation_... | [
"def",
"send_confirmation",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"send_confirmation_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"... | View function which sends confirmation instructions. | [
"View",
"function",
"which",
"sends",
"confirmation",
"instructions",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L187-L210 | train |
mattupstate/flask-security | flask_security/views.py | confirm_email | def confirm_email(token):
"""View function which handles a email confirmation request."""
expired, invalid, user = confirm_email_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_CONFIRMATION_TOKEN'))
already_confirmed = user is not None and use... | python | def confirm_email(token):
"""View function which handles a email confirmation request."""
expired, invalid, user = confirm_email_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_CONFIRMATION_TOKEN'))
already_confirmed = user is not None and use... | [
"def",
"confirm_email",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"confirm_email_token_status",
"(",
"token",
")",
"if",
"not",
"user",
"or",
"invalid",
":",
"invalid",
"=",
"True",
"do_flash",
"(",
"*",
"get_message",
"(",
"'INV... | View function which handles a email confirmation request. | [
"View",
"function",
"which",
"handles",
"a",
"email",
"confirmation",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L213-L244 | train |
mattupstate/flask-security | flask_security/views.py | forgot_password | def forgot_password():
"""View function that handles a forgotten password request."""
form_class = _security.forgot_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_reset_passwor... | python | def forgot_password():
"""View function that handles a forgotten password request."""
form_class = _security.forgot_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
send_reset_passwor... | [
"def",
"forgot_password",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"forgot_password_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form... | View function that handles a forgotten password request. | [
"View",
"function",
"that",
"handles",
"a",
"forgotten",
"password",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L248-L269 | train |
mattupstate/flask-security | flask_security/views.py | reset_password | def reset_password(token):
"""View function that handles a reset password request."""
expired, invalid, user = reset_password_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_RESET_PASSWORD_TOKEN'))
if expired:
send_reset_password_instr... | python | def reset_password(token):
"""View function that handles a reset password request."""
expired, invalid, user = reset_password_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_RESET_PASSWORD_TOKEN'))
if expired:
send_reset_password_instr... | [
"def",
"reset_password",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"reset_password_token_status",
"(",
"token",
")",
"if",
"not",
"user",
"or",
"invalid",
":",
"invalid",
"=",
"True",
"do_flash",
"(",
"*",
"get_message",
"(",
"'I... | View function that handles a reset password request. | [
"View",
"function",
"that",
"handles",
"a",
"reset",
"password",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L273-L303 | train |
mattupstate/flask-security | flask_security/views.py | change_password | def change_password():
"""View function which handles a change password request."""
form_class = _security.change_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
after_this_request(_... | python | def change_password():
"""View function which handles a change password request."""
form_class = _security.change_password_form
if request.is_json:
form = form_class(MultiDict(request.get_json()))
else:
form = form_class()
if form.validate_on_submit():
after_this_request(_... | [
"def",
"change_password",
"(",
")",
":",
"form_class",
"=",
"_security",
".",
"change_password_form",
"if",
"request",
".",
"is_json",
":",
"form",
"=",
"form_class",
"(",
"MultiDict",
"(",
"request",
".",
"get_json",
"(",
")",
")",
")",
"else",
":",
"form... | View function which handles a change password request. | [
"View",
"function",
"which",
"handles",
"a",
"change",
"password",
"request",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L307-L334 | train |
mattupstate/flask-security | flask_security/views.py | create_blueprint | def create_blueprint(state, import_name):
"""Creates the security extension blueprint"""
bp = Blueprint(state.blueprint_name, import_name,
url_prefix=state.url_prefix,
subdomain=state.subdomain,
template_folder='templates')
bp.route(state.logout_url... | python | def create_blueprint(state, import_name):
"""Creates the security extension blueprint"""
bp = Blueprint(state.blueprint_name, import_name,
url_prefix=state.url_prefix,
subdomain=state.subdomain,
template_folder='templates')
bp.route(state.logout_url... | [
"def",
"create_blueprint",
"(",
"state",
",",
"import_name",
")",
":",
"bp",
"=",
"Blueprint",
"(",
"state",
".",
"blueprint_name",
",",
"import_name",
",",
"url_prefix",
"=",
"state",
".",
"url_prefix",
",",
"subdomain",
"=",
"state",
".",
"subdomain",
",",... | Creates the security extension blueprint | [
"Creates",
"the",
"security",
"extension",
"blueprint"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L337-L387 | train |
mattupstate/flask-security | flask_security/utils.py | login_user | def login_user(user, remember=None):
"""Perform the login routine.
If SECURITY_TRACKABLE is used, make sure you commit changes after this
request (i.e. ``app.security.datastore.commit()``).
:param user: The user to login
:param remember: Flag specifying if the remember cookie should be set.
... | python | def login_user(user, remember=None):
"""Perform the login routine.
If SECURITY_TRACKABLE is used, make sure you commit changes after this
request (i.e. ``app.security.datastore.commit()``).
:param user: The user to login
:param remember: Flag specifying if the remember cookie should be set.
... | [
"def",
"login_user",
"(",
"user",
",",
"remember",
"=",
"None",
")",
":",
"if",
"remember",
"is",
"None",
":",
"remember",
"=",
"config_value",
"(",
"'DEFAULT_REMEMBER_ME'",
")",
"if",
"not",
"_login_user",
"(",
"user",
",",
"remember",
")",
":",
"# pragma... | Perform the login routine.
If SECURITY_TRACKABLE is used, make sure you commit changes after this
request (i.e. ``app.security.datastore.commit()``).
:param user: The user to login
:param remember: Flag specifying if the remember cookie should be set.
Defaults to ``False`` | [
"Perform",
"the",
"login",
"routine",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L63-L98 | train |
mattupstate/flask-security | flask_security/utils.py | logout_user | def logout_user():
"""Logs out the current.
This will also clean up the remember me cookie if it exists.
"""
for key in ('identity.name', 'identity.auth_type'):
session.pop(key, None)
identity_changed.send(current_app._get_current_object(),
identity=AnonymousIdent... | python | def logout_user():
"""Logs out the current.
This will also clean up the remember me cookie if it exists.
"""
for key in ('identity.name', 'identity.auth_type'):
session.pop(key, None)
identity_changed.send(current_app._get_current_object(),
identity=AnonymousIdent... | [
"def",
"logout_user",
"(",
")",
":",
"for",
"key",
"in",
"(",
"'identity.name'",
",",
"'identity.auth_type'",
")",
":",
"session",
".",
"pop",
"(",
"key",
",",
"None",
")",
"identity_changed",
".",
"send",
"(",
"current_app",
".",
"_get_current_object",
"(",... | Logs out the current.
This will also clean up the remember me cookie if it exists. | [
"Logs",
"out",
"the",
"current",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L101-L111 | train |
mattupstate/flask-security | flask_security/utils.py | verify_password | def verify_password(password, password_hash):
"""Returns ``True`` if the password matches the supplied hash.
:param password: A plaintext password to verify
:param password_hash: The expected hash value of the password
(usually from your database)
"""
if use_double_hash(pa... | python | def verify_password(password, password_hash):
"""Returns ``True`` if the password matches the supplied hash.
:param password: A plaintext password to verify
:param password_hash: The expected hash value of the password
(usually from your database)
"""
if use_double_hash(pa... | [
"def",
"verify_password",
"(",
"password",
",",
"password_hash",
")",
":",
"if",
"use_double_hash",
"(",
"password_hash",
")",
":",
"password",
"=",
"get_hmac",
"(",
"password",
")",
"return",
"_pwd_context",
".",
"verify",
"(",
"password",
",",
"password_hash",... | Returns ``True`` if the password matches the supplied hash.
:param password: A plaintext password to verify
:param password_hash: The expected hash value of the password
(usually from your database) | [
"Returns",
"True",
"if",
"the",
"password",
"matches",
"the",
"supplied",
"hash",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L132-L142 | train |
mattupstate/flask-security | flask_security/utils.py | find_redirect | def find_redirect(key):
"""Returns the URL to redirect to after a user logs in successfully.
:param key: The session or application configuration key to search for
"""
rv = (get_url(session.pop(key.lower(), None)) or
get_url(current_app.config[key.upper()] or None) or '/')
return rv | python | def find_redirect(key):
"""Returns the URL to redirect to after a user logs in successfully.
:param key: The session or application configuration key to search for
"""
rv = (get_url(session.pop(key.lower(), None)) or
get_url(current_app.config[key.upper()] or None) or '/')
return rv | [
"def",
"find_redirect",
"(",
"key",
")",
":",
"rv",
"=",
"(",
"get_url",
"(",
"session",
".",
"pop",
"(",
"key",
".",
"lower",
"(",
")",
",",
"None",
")",
")",
"or",
"get_url",
"(",
"current_app",
".",
"config",
"[",
"key",
".",
"upper",
"(",
")"... | Returns the URL to redirect to after a user logs in successfully.
:param key: The session or application configuration key to search for | [
"Returns",
"the",
"URL",
"to",
"redirect",
"to",
"after",
"a",
"user",
"logs",
"in",
"successfully",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L306-L313 | train |
mattupstate/flask-security | flask_security/utils.py | send_mail | def send_mail(subject, recipient, template, **context):
"""Send an email via the Flask-Mail extension.
:param subject: Email subject
:param recipient: Email recipient
:param template: The name of the email template
:param context: The context to render the template with
"""
context.setdefa... | python | def send_mail(subject, recipient, template, **context):
"""Send an email via the Flask-Mail extension.
:param subject: Email subject
:param recipient: Email recipient
:param template: The name of the email template
:param context: The context to render the template with
"""
context.setdefa... | [
"def",
"send_mail",
"(",
"subject",
",",
"recipient",
",",
"template",
",",
"*",
"*",
"context",
")",
":",
"context",
".",
"setdefault",
"(",
"'security'",
",",
"_security",
")",
"context",
".",
"update",
"(",
"_security",
".",
"_run_ctx_processor",
"(",
"... | Send an email via the Flask-Mail extension.
:param subject: Email subject
:param recipient: Email recipient
:param template: The name of the email template
:param context: The context to render the template with | [
"Send",
"an",
"email",
"via",
"the",
"Flask",
"-",
"Mail",
"extension",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L373-L404 | train |
mattupstate/flask-security | flask_security/utils.py | capture_registrations | def capture_registrations():
"""Testing utility for capturing registrations.
:param confirmation_sent_at: An optional datetime object to set the
user's `confirmation_sent_at` to
"""
registrations = []
def _on(app, **data):
registrations.append(data)
us... | python | def capture_registrations():
"""Testing utility for capturing registrations.
:param confirmation_sent_at: An optional datetime object to set the
user's `confirmation_sent_at` to
"""
registrations = []
def _on(app, **data):
registrations.append(data)
us... | [
"def",
"capture_registrations",
"(",
")",
":",
"registrations",
"=",
"[",
"]",
"def",
"_on",
"(",
"app",
",",
"*",
"*",
"data",
")",
":",
"registrations",
".",
"append",
"(",
"data",
")",
"user_registered",
".",
"connect",
"(",
"_on",
")",
"try",
":",
... | Testing utility for capturing registrations.
:param confirmation_sent_at: An optional datetime object to set the
user's `confirmation_sent_at` to | [
"Testing",
"utility",
"for",
"capturing",
"registrations",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L481-L497 | train |
mattupstate/flask-security | flask_security/utils.py | capture_reset_password_requests | def capture_reset_password_requests(reset_password_sent_at=None):
"""Testing utility for capturing password reset requests.
:param reset_password_sent_at: An optional datetime object to set the
user's `reset_password_sent_at` to
"""
reset_requests = []
def _on(ap... | python | def capture_reset_password_requests(reset_password_sent_at=None):
"""Testing utility for capturing password reset requests.
:param reset_password_sent_at: An optional datetime object to set the
user's `reset_password_sent_at` to
"""
reset_requests = []
def _on(ap... | [
"def",
"capture_reset_password_requests",
"(",
"reset_password_sent_at",
"=",
"None",
")",
":",
"reset_requests",
"=",
"[",
"]",
"def",
"_on",
"(",
"app",
",",
"*",
"*",
"data",
")",
":",
"reset_requests",
".",
"append",
"(",
"data",
")",
"reset_password_instr... | Testing utility for capturing password reset requests.
:param reset_password_sent_at: An optional datetime object to set the
user's `reset_password_sent_at` to | [
"Testing",
"utility",
"for",
"capturing",
"password",
"reset",
"requests",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L501-L517 | train |
mattupstate/flask-security | flask_security/passwordless.py | send_login_instructions | def send_login_instructions(user):
"""Sends the login instructions email for the specified user.
:param user: The user to send the instructions to
:param token: The login token
"""
token = generate_login_token(user)
login_link = url_for_security('token_login', token=token, _external=True)
... | python | def send_login_instructions(user):
"""Sends the login instructions email for the specified user.
:param user: The user to send the instructions to
:param token: The login token
"""
token = generate_login_token(user)
login_link = url_for_security('token_login', token=token, _external=True)
... | [
"def",
"send_login_instructions",
"(",
"user",
")",
":",
"token",
"=",
"generate_login_token",
"(",
"user",
")",
"login_link",
"=",
"url_for_security",
"(",
"'token_login'",
",",
"token",
"=",
"token",
",",
"_external",
"=",
"True",
")",
"_security",
".",
"sen... | Sends the login instructions email for the specified user.
:param user: The user to send the instructions to
:param token: The login token | [
"Sends",
"the",
"login",
"instructions",
"email",
"for",
"the",
"specified",
"user",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/passwordless.py#L24-L37 | train |
mattupstate/flask-security | flask_security/cli.py | roles_add | def roles_add(user, role):
"""Add user to role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.add_role_to_user(user, role):
... | python | def roles_add(user, role):
"""Add user to role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.add_role_to_user(user, role):
... | [
"def",
"roles_add",
"(",
"user",
",",
"role",
")",
":",
"user",
",",
"role",
"=",
"_datastore",
".",
"_prepare_role_modify_args",
"(",
"user",
",",
"role",
")",
"if",
"user",
"is",
"None",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'Cannot find user.'... | Add user to role. | [
"Add",
"user",
"to",
"role",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/cli.py#L93-L104 | train |
mattupstate/flask-security | flask_security/cli.py | roles_remove | def roles_remove(user, role):
"""Remove user from role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.remove_role_from_user(user,... | python | def roles_remove(user, role):
"""Remove user from role."""
user, role = _datastore._prepare_role_modify_args(user, role)
if user is None:
raise click.UsageError('Cannot find user.')
if role is None:
raise click.UsageError('Cannot find role.')
if _datastore.remove_role_from_user(user,... | [
"def",
"roles_remove",
"(",
"user",
",",
"role",
")",
":",
"user",
",",
"role",
"=",
"_datastore",
".",
"_prepare_role_modify_args",
"(",
"user",
",",
"role",
")",
"if",
"user",
"is",
"None",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'Cannot find use... | Remove user from role. | [
"Remove",
"user",
"from",
"role",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/cli.py#L112-L123 | train |
mattupstate/flask-security | flask_security/changeable.py | send_password_changed_notice | def send_password_changed_notice(user):
"""Sends the password changed notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_CHANGE_EMAIL'):
subject = config_value('EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE')
_security.send_mail(su... | python | def send_password_changed_notice(user):
"""Sends the password changed notice email for the specified user.
:param user: The user to send the notice to
"""
if config_value('SEND_PASSWORD_CHANGE_EMAIL'):
subject = config_value('EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE')
_security.send_mail(su... | [
"def",
"send_password_changed_notice",
"(",
"user",
")",
":",
"if",
"config_value",
"(",
"'SEND_PASSWORD_CHANGE_EMAIL'",
")",
":",
"subject",
"=",
"config_value",
"(",
"'EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE'",
")",
"_security",
".",
"send_mail",
"(",
"subject",
",",
"... | Sends the password changed notice email for the specified user.
:param user: The user to send the notice to | [
"Sends",
"the",
"password",
"changed",
"notice",
"email",
"for",
"the",
"specified",
"user",
"."
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/changeable.py#L25-L32 | train |
mattupstate/flask-security | flask_security/changeable.py | change_user_password | def change_user_password(user, password):
"""Change the specified user's password
:param user: The user to change_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_changed_notice(user)
password_changed.send... | python | def change_user_password(user, password):
"""Change the specified user's password
:param user: The user to change_password
:param password: The unhashed new password
"""
user.password = hash_password(password)
_datastore.put(user)
send_password_changed_notice(user)
password_changed.send... | [
"def",
"change_user_password",
"(",
"user",
",",
"password",
")",
":",
"user",
".",
"password",
"=",
"hash_password",
"(",
"password",
")",
"_datastore",
".",
"put",
"(",
"user",
")",
"send_password_changed_notice",
"(",
"user",
")",
"password_changed",
".",
"... | Change the specified user's password
:param user: The user to change_password
:param password: The unhashed new password | [
"Change",
"the",
"specified",
"user",
"s",
"password"
] | a401fb47018fbbbe0b899ea55afadfd0e3cd847a | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/changeable.py#L35-L45 | train |
jd/tenacity | tenacity/after.py | after_log | def after_log(logger, log_level, sec_format="%0.3f"):
"""After call strategy that logs to some logger the finished attempt."""
log_tpl = ("Finished call to '%s' after " + str(sec_format) + "(s), "
"this was the %s time calling it.")
def log_it(retry_state):
logger.log(log_level, log_... | python | def after_log(logger, log_level, sec_format="%0.3f"):
"""After call strategy that logs to some logger the finished attempt."""
log_tpl = ("Finished call to '%s' after " + str(sec_format) + "(s), "
"this was the %s time calling it.")
def log_it(retry_state):
logger.log(log_level, log_... | [
"def",
"after_log",
"(",
"logger",
",",
"log_level",
",",
"sec_format",
"=",
"\"%0.3f\"",
")",
":",
"log_tpl",
"=",
"(",
"\"Finished call to '%s' after \"",
"+",
"str",
"(",
"sec_format",
")",
"+",
"\"(s), \"",
"\"this was the %s time calling it.\"",
")",
"def",
"... | After call strategy that logs to some logger the finished attempt. | [
"After",
"call",
"strategy",
"that",
"logs",
"to",
"some",
"logger",
"the",
"finished",
"attempt",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/after.py#L24-L35 | train |
jd/tenacity | tenacity/__init__.py | retry | def retry(*dargs, **dkw):
"""Wrap a function with a new `Retrying` object.
:param dargs: positional arguments passed to Retrying object
:param dkw: keyword arguments passed to the Retrying object
"""
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
... | python | def retry(*dargs, **dkw):
"""Wrap a function with a new `Retrying` object.
:param dargs: positional arguments passed to Retrying object
:param dkw: keyword arguments passed to the Retrying object
"""
# support both @retry and @retry() as valid syntax
if len(dargs) == 1 and callable(dargs[0]):
... | [
"def",
"retry",
"(",
"*",
"dargs",
",",
"*",
"*",
"dkw",
")",
":",
"# support both @retry and @retry() as valid syntax",
"if",
"len",
"(",
"dargs",
")",
"==",
"1",
"and",
"callable",
"(",
"dargs",
"[",
"0",
"]",
")",
":",
"return",
"retry",
"(",
")",
"... | Wrap a function with a new `Retrying` object.
:param dargs: positional arguments passed to Retrying object
:param dkw: keyword arguments passed to the Retrying object | [
"Wrap",
"a",
"function",
"with",
"a",
"new",
"Retrying",
"object",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L88-L109 | train |
jd/tenacity | tenacity/__init__.py | BaseRetrying.copy | def copy(self, sleep=_unset, stop=_unset, wait=_unset,
retry=_unset, before=_unset, after=_unset, before_sleep=_unset,
reraise=_unset):
"""Copy this object with some parameters changed if needed."""
if before_sleep is _unset:
before_sleep = self.before_sleep
... | python | def copy(self, sleep=_unset, stop=_unset, wait=_unset,
retry=_unset, before=_unset, after=_unset, before_sleep=_unset,
reraise=_unset):
"""Copy this object with some parameters changed if needed."""
if before_sleep is _unset:
before_sleep = self.before_sleep
... | [
"def",
"copy",
"(",
"self",
",",
"sleep",
"=",
"_unset",
",",
"stop",
"=",
"_unset",
",",
"wait",
"=",
"_unset",
",",
"retry",
"=",
"_unset",
",",
"before",
"=",
"_unset",
",",
"after",
"=",
"_unset",
",",
"before_sleep",
"=",
"_unset",
",",
"reraise... | Copy this object with some parameters changed if needed. | [
"Copy",
"this",
"object",
"with",
"some",
"parameters",
"changed",
"if",
"needed",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L231-L246 | train |
jd/tenacity | tenacity/__init__.py | BaseRetrying.statistics | def statistics(self):
"""Return a dictionary of runtime statistics.
This dictionary will be empty when the controller has never been
ran. When it is running or has ran previously it should have (but
may not) have useful and/or informational keys and values when
running is underw... | python | def statistics(self):
"""Return a dictionary of runtime statistics.
This dictionary will be empty when the controller has never been
ran. When it is running or has ran previously it should have (but
may not) have useful and/or informational keys and values when
running is underw... | [
"def",
"statistics",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_local",
".",
"statistics",
"except",
"AttributeError",
":",
"self",
".",
"_local",
".",
"statistics",
"=",
"{",
"}",
"return",
"self",
".",
"_local",
".",
"statistics"
] | Return a dictionary of runtime statistics.
This dictionary will be empty when the controller has never been
ran. When it is running or has ran previously it should have (but
may not) have useful and/or informational keys and values when
running is underway and/or completed.
.. ... | [
"Return",
"a",
"dictionary",
"of",
"runtime",
"statistics",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L258-L283 | train |
jd/tenacity | tenacity/__init__.py | BaseRetrying.wraps | def wraps(self, f):
"""Wrap a function for retrying.
:param f: A function to wraps for retrying.
"""
@_utils.wraps(f)
def wrapped_f(*args, **kw):
return self.call(f, *args, **kw)
def retry_with(*args, **kwargs):
return self.copy(*args, **kwargs).... | python | def wraps(self, f):
"""Wrap a function for retrying.
:param f: A function to wraps for retrying.
"""
@_utils.wraps(f)
def wrapped_f(*args, **kw):
return self.call(f, *args, **kw)
def retry_with(*args, **kwargs):
return self.copy(*args, **kwargs).... | [
"def",
"wraps",
"(",
"self",
",",
"f",
")",
":",
"@",
"_utils",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped_f",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"call",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kw"... | Wrap a function for retrying.
:param f: A function to wraps for retrying. | [
"Wrap",
"a",
"function",
"for",
"retrying",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L285-L300 | train |
jd/tenacity | tenacity/__init__.py | Future.construct | def construct(cls, attempt_number, value, has_exception):
"""Construct a new Future object."""
fut = cls(attempt_number)
if has_exception:
fut.set_exception(value)
else:
fut.set_result(value)
return fut | python | def construct(cls, attempt_number, value, has_exception):
"""Construct a new Future object."""
fut = cls(attempt_number)
if has_exception:
fut.set_exception(value)
else:
fut.set_result(value)
return fut | [
"def",
"construct",
"(",
"cls",
",",
"attempt_number",
",",
"value",
",",
"has_exception",
")",
":",
"fut",
"=",
"cls",
"(",
"attempt_number",
")",
"if",
"has_exception",
":",
"fut",
".",
"set_exception",
"(",
"value",
")",
"else",
":",
"fut",
".",
"set_... | Construct a new Future object. | [
"Construct",
"a",
"new",
"Future",
"object",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/__init__.py#L388-L395 | train |
jd/tenacity | tenacity/_utils.py | get_callback_name | def get_callback_name(cb):
"""Get a callback fully-qualified name.
If no name can be produced ``repr(cb)`` is called and returned.
"""
segments = []
try:
segments.append(cb.__qualname__)
except AttributeError:
try:
segments.append(cb.__name__)
if inspect.... | python | def get_callback_name(cb):
"""Get a callback fully-qualified name.
If no name can be produced ``repr(cb)`` is called and returned.
"""
segments = []
try:
segments.append(cb.__qualname__)
except AttributeError:
try:
segments.append(cb.__name__)
if inspect.... | [
"def",
"get_callback_name",
"(",
"cb",
")",
":",
"segments",
"=",
"[",
"]",
"try",
":",
"segments",
".",
"append",
"(",
"cb",
".",
"__qualname__",
")",
"except",
"AttributeError",
":",
"try",
":",
"segments",
".",
"append",
"(",
"cb",
".",
"__name__",
... | Get a callback fully-qualified name.
If no name can be produced ``repr(cb)`` is called and returned. | [
"Get",
"a",
"callback",
"fully",
"-",
"qualified",
"name",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/_utils.py#L98-L128 | train |
jd/tenacity | tenacity/compat.py | make_retry_state | def make_retry_state(previous_attempt_number, delay_since_first_attempt,
last_result=None):
"""Construct RetryCallState for given attempt number & delay.
Only used in testing and thus is extra careful about timestamp arithmetics.
"""
required_parameter_unset = (previous_attempt_num... | python | def make_retry_state(previous_attempt_number, delay_since_first_attempt,
last_result=None):
"""Construct RetryCallState for given attempt number & delay.
Only used in testing and thus is extra careful about timestamp arithmetics.
"""
required_parameter_unset = (previous_attempt_num... | [
"def",
"make_retry_state",
"(",
"previous_attempt_number",
",",
"delay_since_first_attempt",
",",
"last_result",
"=",
"None",
")",
":",
"required_parameter_unset",
"=",
"(",
"previous_attempt_number",
"is",
"_unset",
"or",
"delay_since_first_attempt",
"is",
"_unset",
")",... | Construct RetryCallState for given attempt number & delay.
Only used in testing and thus is extra careful about timestamp arithmetics. | [
"Construct",
"RetryCallState",
"for",
"given",
"attempt",
"number",
"&",
"delay",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L57-L79 | train |
jd/tenacity | tenacity/compat.py | func_takes_last_result | def func_takes_last_result(waiter):
"""Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning.
"""
if not six.callable(waiter):
return False
if not inspect.isfunction(waiter) and not in... | python | def func_takes_last_result(waiter):
"""Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning.
"""
if not six.callable(waiter):
return False
if not inspect.isfunction(waiter) and not in... | [
"def",
"func_takes_last_result",
"(",
"waiter",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"waiter",
")",
":",
"return",
"False",
"if",
"not",
"inspect",
".",
"isfunction",
"(",
"waiter",
")",
"and",
"not",
"inspect",
".",
"ismethod",
"(",
"wait... | Check if function has a "last_result" parameter.
Needed to provide backward compatibility for wait functions that didn't
take "last_result" in the beginning. | [
"Check",
"if",
"function",
"has",
"a",
"last_result",
"parameter",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L82-L94 | train |
jd/tenacity | tenacity/compat.py | stop_func_accept_retry_state | def stop_func_accept_retry_state(stop_func):
"""Wrap "stop" function to accept "retry_state" parameter."""
if not six.callable(stop_func):
return stop_func
if func_takes_retry_state(stop_func):
return stop_func
@_utils.wraps(stop_func)
def wrapped_stop_func(retry_state):
wa... | python | def stop_func_accept_retry_state(stop_func):
"""Wrap "stop" function to accept "retry_state" parameter."""
if not six.callable(stop_func):
return stop_func
if func_takes_retry_state(stop_func):
return stop_func
@_utils.wraps(stop_func)
def wrapped_stop_func(retry_state):
wa... | [
"def",
"stop_func_accept_retry_state",
"(",
"stop_func",
")",
":",
"if",
"not",
"six",
".",
"callable",
"(",
"stop_func",
")",
":",
"return",
"stop_func",
"if",
"func_takes_retry_state",
"(",
"stop_func",
")",
":",
"return",
"stop_func",
"@",
"_utils",
".",
"w... | Wrap "stop" function to accept "retry_state" parameter. | [
"Wrap",
"stop",
"function",
"to",
"accept",
"retry_state",
"parameter",
"."
] | 354c40b7dc8e728c438668100dd020b65c84dfc6 | https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L120-L136 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.