partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | slurm_parse_timestr | A slurm time parser. Accepts a string in one the following forms:
# "days-hours",
# "days-hours:minutes",
# "days-hours:minutes:seconds".
# "minutes",
# "minutes:seconds",
# "hours:minutes:seconds",
Returns:
Time in seconds.
Raises:
`ValueError`... | pymatgen/io/abinit/qutils.py | def slurm_parse_timestr(s):
"""
A slurm time parser. Accepts a string in one the following forms:
# "days-hours",
# "days-hours:minutes",
# "days-hours:minutes:seconds".
# "minutes",
# "minutes:seconds",
# "hours:minutes:seconds",
Returns:
Time in se... | def slurm_parse_timestr(s):
"""
A slurm time parser. Accepts a string in one the following forms:
# "days-hours",
# "days-hours:minutes",
# "days-hours:minutes:seconds".
# "minutes",
# "minutes:seconds",
# "hours:minutes:seconds",
Returns:
Time in se... | [
"A",
"slurm",
"time",
"parser",
".",
"Accepts",
"a",
"string",
"in",
"one",
"the",
"following",
"forms",
":"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/qutils.py#L17-L68 | [
"def",
"slurm_parse_timestr",
"(",
"s",
")",
":",
"days",
",",
"hours",
",",
"minutes",
",",
"seconds",
"=",
"0",
",",
"0",
",",
"0",
",",
"0",
"if",
"type",
"(",
"s",
")",
"==",
"type",
"(",
"1",
")",
":",
"return",
"Time",
"(",
"s",
",",
"\... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | time2slurm | Convert a number representing a time value in the given unit (Default: seconds)
to a string following the slurm convention: "days-hours:minutes:seconds".
>>> assert time2slurm(61) == '0-0:1:1' and time2slurm(60*60+1) == '0-1:0:1'
>>> assert time2slurm(0.5, unit="h") == '0-0:30:0' | pymatgen/io/abinit/qutils.py | def time2slurm(timeval, unit="s"):
"""
Convert a number representing a time value in the given unit (Default: seconds)
to a string following the slurm convention: "days-hours:minutes:seconds".
>>> assert time2slurm(61) == '0-0:1:1' and time2slurm(60*60+1) == '0-1:0:1'
>>> assert time2slurm(0.5, uni... | def time2slurm(timeval, unit="s"):
"""
Convert a number representing a time value in the given unit (Default: seconds)
to a string following the slurm convention: "days-hours:minutes:seconds".
>>> assert time2slurm(61) == '0-0:1:1' and time2slurm(60*60+1) == '0-1:0:1'
>>> assert time2slurm(0.5, uni... | [
"Convert",
"a",
"number",
"representing",
"a",
"time",
"value",
"in",
"the",
"given",
"unit",
"(",
"Default",
":",
"seconds",
")",
"to",
"a",
"string",
"following",
"the",
"slurm",
"convention",
":",
"days",
"-",
"hours",
":",
"minutes",
":",
"seconds",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/qutils.py#L71-L86 | [
"def",
"time2slurm",
"(",
"timeval",
",",
"unit",
"=",
"\"s\"",
")",
":",
"d",
",",
"h",
",",
"m",
",",
"s",
"=",
"24",
"*",
"3600",
",",
"3600",
",",
"60",
",",
"1",
"timeval",
"=",
"Time",
"(",
"timeval",
",",
"unit",
")",
".",
"to",
"(",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | time2pbspro | Convert a number representing a time value in the given unit (Default: seconds)
to a string following the PbsPro convention: "hours:minutes:seconds".
>>> assert time2pbspro(2, unit="d") == '48:0:0' | pymatgen/io/abinit/qutils.py | def time2pbspro(timeval, unit="s"):
"""
Convert a number representing a time value in the given unit (Default: seconds)
to a string following the PbsPro convention: "hours:minutes:seconds".
>>> assert time2pbspro(2, unit="d") == '48:0:0'
"""
h, m, s = 3600, 60, 1
timeval = Time(timeval, un... | def time2pbspro(timeval, unit="s"):
"""
Convert a number representing a time value in the given unit (Default: seconds)
to a string following the PbsPro convention: "hours:minutes:seconds".
>>> assert time2pbspro(2, unit="d") == '48:0:0'
"""
h, m, s = 3600, 60, 1
timeval = Time(timeval, un... | [
"Convert",
"a",
"number",
"representing",
"a",
"time",
"value",
"in",
"the",
"given",
"unit",
"(",
"Default",
":",
"seconds",
")",
"to",
"a",
"string",
"following",
"the",
"PbsPro",
"convention",
":",
"hours",
":",
"minutes",
":",
"seconds",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/qutils.py#L89-L102 | [
"def",
"time2pbspro",
"(",
"timeval",
",",
"unit",
"=",
"\"s\"",
")",
":",
"h",
",",
"m",
",",
"s",
"=",
"3600",
",",
"60",
",",
"1",
"timeval",
"=",
"Time",
"(",
"timeval",
",",
"unit",
")",
".",
"to",
"(",
"\"s\"",
")",
"hours",
",",
"minutes... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | any2mb | Convert string or number to memory in megabytes. | pymatgen/io/abinit/qutils.py | def any2mb(s):
"""Convert string or number to memory in megabytes."""
if is_string(s):
return int(Memory.from_string(s).to("Mb"))
else:
return int(s) | def any2mb(s):
"""Convert string or number to memory in megabytes."""
if is_string(s):
return int(Memory.from_string(s).to("Mb"))
else:
return int(s) | [
"Convert",
"string",
"or",
"number",
"to",
"memory",
"in",
"megabytes",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/qutils.py#L129-L134 | [
"def",
"any2mb",
"(",
"s",
")",
":",
"if",
"is_string",
"(",
"s",
")",
":",
"return",
"int",
"(",
"Memory",
".",
"from_string",
"(",
"s",
")",
".",
"to",
"(",
"\"Mb\"",
")",
")",
"else",
":",
"return",
"int",
"(",
"s",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer.max_cation_removal | Maximum number of cation A that can be removed while maintaining charge-balance.
Returns:
integer amount of cation. Depends on cell size (this is an 'extrinsic' function!) | pymatgen/apps/battery/analyzer.py | def max_cation_removal(self):
"""
Maximum number of cation A that can be removed while maintaining charge-balance.
Returns:
integer amount of cation. Depends on cell size (this is an 'extrinsic' function!)
"""
# how much 'spare charge' is left in the redox metals fo... | def max_cation_removal(self):
"""
Maximum number of cation A that can be removed while maintaining charge-balance.
Returns:
integer amount of cation. Depends on cell size (this is an 'extrinsic' function!)
"""
# how much 'spare charge' is left in the redox metals fo... | [
"Maximum",
"number",
"of",
"cation",
"A",
"that",
"can",
"be",
"removed",
"while",
"maintaining",
"charge",
"-",
"balance",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L51-L69 | [
"def",
"max_cation_removal",
"(",
"self",
")",
":",
"# how much 'spare charge' is left in the redox metals for oxidation?",
"oxid_pot",
"=",
"sum",
"(",
"[",
"(",
"Element",
"(",
"spec",
".",
"symbol",
")",
".",
"max_oxidation_state",
"-",
"spec",
".",
"oxi_state",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer.max_cation_insertion | Maximum number of cation A that can be inserted while maintaining charge-balance.
No consideration is given to whether there (geometrically speaking) are Li sites to actually accommodate the extra Li.
Returns:
integer amount of cation. Depends on cell size (this is an 'extrinsic' function!) | pymatgen/apps/battery/analyzer.py | def max_cation_insertion(self):
"""
Maximum number of cation A that can be inserted while maintaining charge-balance.
No consideration is given to whether there (geometrically speaking) are Li sites to actually accommodate the extra Li.
Returns:
integer amount of cation. Dep... | def max_cation_insertion(self):
"""
Maximum number of cation A that can be inserted while maintaining charge-balance.
No consideration is given to whether there (geometrically speaking) are Li sites to actually accommodate the extra Li.
Returns:
integer amount of cation. Dep... | [
"Maximum",
"number",
"of",
"cation",
"A",
"that",
"can",
"be",
"inserted",
"while",
"maintaining",
"charge",
"-",
"balance",
".",
"No",
"consideration",
"is",
"given",
"to",
"whether",
"there",
"(",
"geometrically",
"speaking",
")",
"are",
"Li",
"sites",
"to... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L73-L89 | [
"def",
"max_cation_insertion",
"(",
"self",
")",
":",
"# how much 'spare charge' is left in the redox metals for reduction?",
"lowest_oxid",
"=",
"defaultdict",
"(",
"lambda",
":",
"2",
",",
"{",
"'Cu'",
":",
"1",
"}",
")",
"# only Cu can go down to 1+",
"oxid_pot",
"="... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer._get_max_cap_ah | Give max capacity in mAh for inserting and removing a charged cation
This method does not normalize the capacity and intended as a helper method | pymatgen/apps/battery/analyzer.py | def _get_max_cap_ah(self, remove, insert):
"""
Give max capacity in mAh for inserting and removing a charged cation
This method does not normalize the capacity and intended as a helper method
"""
num_cations = 0
if remove:
num_cations += self.max_cation_remova... | def _get_max_cap_ah(self, remove, insert):
"""
Give max capacity in mAh for inserting and removing a charged cation
This method does not normalize the capacity and intended as a helper method
"""
num_cations = 0
if remove:
num_cations += self.max_cation_remova... | [
"Give",
"max",
"capacity",
"in",
"mAh",
"for",
"inserting",
"and",
"removing",
"a",
"charged",
"cation",
"This",
"method",
"does",
"not",
"normalize",
"the",
"capacity",
"and",
"intended",
"as",
"a",
"helper",
"method"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L92-L103 | [
"def",
"_get_max_cap_ah",
"(",
"self",
",",
"remove",
",",
"insert",
")",
":",
"num_cations",
"=",
"0",
"if",
"remove",
":",
"num_cations",
"+=",
"self",
".",
"max_cation_removal",
"if",
"insert",
":",
"num_cations",
"+=",
"self",
".",
"max_cation_insertion",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer.get_max_capgrav | Give max capacity in mAh/g for inserting and removing a charged cation
Note that the weight is normalized to the most lithiated state,
thus removal of 1 Li from LiFePO4 gives the same capacity as insertion of 1 Li into FePO4.
Args:
remove: (bool) whether to allow cation removal
... | pymatgen/apps/battery/analyzer.py | def get_max_capgrav(self, remove=True, insert=True):
"""
Give max capacity in mAh/g for inserting and removing a charged cation
Note that the weight is normalized to the most lithiated state,
thus removal of 1 Li from LiFePO4 gives the same capacity as insertion of 1 Li into FePO4.
... | def get_max_capgrav(self, remove=True, insert=True):
"""
Give max capacity in mAh/g for inserting and removing a charged cation
Note that the weight is normalized to the most lithiated state,
thus removal of 1 Li from LiFePO4 gives the same capacity as insertion of 1 Li into FePO4.
... | [
"Give",
"max",
"capacity",
"in",
"mAh",
"/",
"g",
"for",
"inserting",
"and",
"removing",
"a",
"charged",
"cation",
"Note",
"that",
"the",
"weight",
"is",
"normalized",
"to",
"the",
"most",
"lithiated",
"state",
"thus",
"removal",
"of",
"1",
"Li",
"from",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L106-L122 | [
"def",
"get_max_capgrav",
"(",
"self",
",",
"remove",
"=",
"True",
",",
"insert",
"=",
"True",
")",
":",
"weight",
"=",
"self",
".",
"comp",
".",
"weight",
"if",
"insert",
":",
"weight",
"+=",
"self",
".",
"max_cation_insertion",
"*",
"self",
".",
"cat... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer.get_max_capvol | Give max capacity in mAh/cc for inserting and removing a charged cation into base structure.
Args:
remove: (bool) whether to allow cation removal
insert: (bool) whether to allow cation insertion
volume: (float) volume to use for normalization (default=volume of initial struc... | pymatgen/apps/battery/analyzer.py | def get_max_capvol(self, remove=True, insert=True, volume=None):
"""
Give max capacity in mAh/cc for inserting and removing a charged cation into base structure.
Args:
remove: (bool) whether to allow cation removal
insert: (bool) whether to allow cation insertion
... | def get_max_capvol(self, remove=True, insert=True, volume=None):
"""
Give max capacity in mAh/cc for inserting and removing a charged cation into base structure.
Args:
remove: (bool) whether to allow cation removal
insert: (bool) whether to allow cation insertion
... | [
"Give",
"max",
"capacity",
"in",
"mAh",
"/",
"cc",
"for",
"inserting",
"and",
"removing",
"a",
"charged",
"cation",
"into",
"base",
"structure",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L125-L139 | [
"def",
"get_max_capvol",
"(",
"self",
",",
"remove",
"=",
"True",
",",
"insert",
"=",
"True",
",",
"volume",
"=",
"None",
")",
":",
"vol",
"=",
"volume",
"if",
"volume",
"else",
"self",
".",
"struc_oxid",
".",
"volume",
"return",
"self",
".",
"_get_max... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer.get_removals_int_oxid | Returns a set of delithiation steps, e.g. set([1.0 2.0 4.0]) etc. in order to
produce integer oxidation states of the redox metals.
If multiple redox metals are present, all combinations of reduction/oxidation are tested.
Note that having more than 3 redox metals will likely slow down the algori... | pymatgen/apps/battery/analyzer.py | def get_removals_int_oxid(self):
"""
Returns a set of delithiation steps, e.g. set([1.0 2.0 4.0]) etc. in order to
produce integer oxidation states of the redox metals.
If multiple redox metals are present, all combinations of reduction/oxidation are tested.
Note that having more... | def get_removals_int_oxid(self):
"""
Returns a set of delithiation steps, e.g. set([1.0 2.0 4.0]) etc. in order to
produce integer oxidation states of the redox metals.
If multiple redox metals are present, all combinations of reduction/oxidation are tested.
Note that having more... | [
"Returns",
"a",
"set",
"of",
"delithiation",
"steps",
"e",
".",
"g",
".",
"set",
"(",
"[",
"1",
".",
"0",
"2",
".",
"0",
"4",
".",
"0",
"]",
")",
"etc",
".",
"in",
"order",
"to",
"produce",
"integer",
"oxidation",
"states",
"of",
"the",
"redox",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L141-L167 | [
"def",
"get_removals_int_oxid",
"(",
"self",
")",
":",
"# the elements that can possibly be oxidized",
"oxid_els",
"=",
"[",
"Element",
"(",
"spec",
".",
"symbol",
")",
"for",
"spec",
"in",
"self",
".",
"comp",
"if",
"is_redox_active_intercalation",
"(",
"spec",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatteryAnalyzer._get_int_removals_helper | This is a helper method for get_removals_int_oxid!
Args:
spec_amts_oxi - a dict of species to their amounts in the structure
oxid_el - the element to oxidize
oxid_els - the full list of elements that might be oxidized
numa - a running set of numbers of A cation a... | pymatgen/apps/battery/analyzer.py | def _get_int_removals_helper(self, spec_amts_oxi, oxid_el, oxid_els, numa):
"""
This is a helper method for get_removals_int_oxid!
Args:
spec_amts_oxi - a dict of species to their amounts in the structure
oxid_el - the element to oxidize
oxid_els - the full l... | def _get_int_removals_helper(self, spec_amts_oxi, oxid_el, oxid_els, numa):
"""
This is a helper method for get_removals_int_oxid!
Args:
spec_amts_oxi - a dict of species to their amounts in the structure
oxid_el - the element to oxidize
oxid_els - the full l... | [
"This",
"is",
"a",
"helper",
"method",
"for",
"get_removals_int_oxid!"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/analyzer.py#L169-L211 | [
"def",
"_get_int_removals_helper",
"(",
"self",
",",
"spec_amts_oxi",
",",
"oxid_el",
",",
"oxid_els",
",",
"numa",
")",
":",
"# If Mn is the oxid_el, we have a mixture of Mn2+, Mn3+, determine the minimum oxidation state for Mn",
"#this is the state we want to oxidize!",
"oxid_old",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | reduce_formula | Helper method to reduce a sym_amt dict to a reduced formula and factor.
Args:
sym_amt (dict): {symbol: amount}.
iupac_ordering (bool, optional): Whether to order the
formula by the iupac "electronegativity" series, defined in
Table VI of "Nomenclature of Inorganic Chemistry ... | pymatgen/core/composition.py | def reduce_formula(sym_amt, iupac_ordering=False):
"""
Helper method to reduce a sym_amt dict to a reduced formula and factor.
Args:
sym_amt (dict): {symbol: amount}.
iupac_ordering (bool, optional): Whether to order the
formula by the iupac "electronegativity" series, defined i... | def reduce_formula(sym_amt, iupac_ordering=False):
"""
Helper method to reduce a sym_amt dict to a reduced formula and factor.
Args:
sym_amt (dict): {symbol: amount}.
iupac_ordering (bool, optional): Whether to order the
formula by the iupac "electronegativity" series, defined i... | [
"Helper",
"method",
"to",
"reduce",
"a",
"sym_amt",
"dict",
"to",
"a",
"reduced",
"formula",
"and",
"factor",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/composition.py#L1055-L1107 | [
"def",
"reduce_formula",
"(",
"sym_amt",
",",
"iupac_ordering",
"=",
"False",
")",
":",
"syms",
"=",
"sorted",
"(",
"sym_amt",
".",
"keys",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"[",
"get_el_sp",
"(",
"x",
")",
".",
"X",
",",
"x",
"]",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ChemicalPotential.get_energy | Calculates the energy of a composition.
Args:
composition (Composition): input composition
strict (bool): Whether all potentials must be specified | pymatgen/core/composition.py | def get_energy(self, composition, strict=True):
"""
Calculates the energy of a composition.
Args:
composition (Composition): input composition
strict (bool): Whether all potentials must be specified
"""
if strict and set(composition.keys()) > set(... | def get_energy(self, composition, strict=True):
"""
Calculates the energy of a composition.
Args:
composition (Composition): input composition
strict (bool): Whether all potentials must be specified
"""
if strict and set(composition.keys()) > set(... | [
"Calculates",
"the",
"energy",
"of",
"a",
"composition",
".",
"Args",
":",
"composition",
"(",
"Composition",
")",
":",
"input",
"composition",
"strict",
"(",
"bool",
")",
":",
"Whether",
"all",
"potentials",
"must",
"be",
"specified"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/composition.py#L1166-L1177 | [
"def",
"get_energy",
"(",
"self",
",",
"composition",
",",
"strict",
"=",
"True",
")",
":",
"if",
"strict",
"and",
"set",
"(",
"composition",
".",
"keys",
"(",
")",
")",
">",
"set",
"(",
"self",
".",
"keys",
"(",
")",
")",
":",
"s",
"=",
"set",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.with_edges | Constructor for MoleculeGraph, using pre-existing or pre-defined edges
with optional edge parameters.
:param molecule: Molecule object
:param edges: dict representing the bonds of the functional
group (format: {(from_index, to_index, from_image, to_image): props},
... | pymatgen/analysis/graphs.py | def with_edges(structure, edges):
"""
Constructor for MoleculeGraph, using pre-existing or pre-defined edges
with optional edge parameters.
:param molecule: Molecule object
:param edges: dict representing the bonds of the functional
group (format: {(from_index, t... | def with_edges(structure, edges):
"""
Constructor for MoleculeGraph, using pre-existing or pre-defined edges
with optional edge parameters.
:param molecule: Molecule object
:param edges: dict representing the bonds of the functional
group (format: {(from_index, t... | [
"Constructor",
"for",
"MoleculeGraph",
"using",
"pre",
"-",
"existing",
"or",
"pre",
"-",
"defined",
"edges",
"with",
"optional",
"edge",
"parameters",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L140-L192 | [
"def",
"with_edges",
"(",
"structure",
",",
"edges",
")",
":",
"sg",
"=",
"StructureGraph",
".",
"with_empty_graph",
"(",
"structure",
",",
"name",
"=",
"\"bonds\"",
",",
"edge_weight_name",
"=",
"\"weight\"",
",",
"edge_weight_units",
"=",
"\"\"",
")",
"for",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.with_local_env_strategy | Constructor for StructureGraph, using a strategy
from :Class: `pymatgen.analysis.local_env`.
:param structure: Structure object
:param strategy: an instance of a
:Class: `pymatgen.analysis.local_env.NearNeighbors` object
:return: | pymatgen/analysis/graphs.py | def with_local_env_strategy(structure, strategy):
"""
Constructor for StructureGraph, using a strategy
from :Class: `pymatgen.analysis.local_env`.
:param structure: Structure object
:param strategy: an instance of a
:Class: `pymatgen.analysis.local_env.NearNeighbors`... | def with_local_env_strategy(structure, strategy):
"""
Constructor for StructureGraph, using a strategy
from :Class: `pymatgen.analysis.local_env`.
:param structure: Structure object
:param strategy: an instance of a
:Class: `pymatgen.analysis.local_env.NearNeighbors`... | [
"Constructor",
"for",
"StructureGraph",
"using",
"a",
"strategy",
"from",
":",
"Class",
":",
"pymatgen",
".",
"analysis",
".",
"local_env",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L195-L224 | [
"def",
"with_local_env_strategy",
"(",
"structure",
",",
"strategy",
")",
":",
"sg",
"=",
"StructureGraph",
".",
"with_empty_graph",
"(",
"structure",
",",
"name",
"=",
"\"bonds\"",
",",
"edge_weight_name",
"=",
"\"weight\"",
",",
"edge_weight_units",
"=",
"\"\"",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.add_edge | Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have a direction, from_index,
from_jimage can be swapped with to_index, to_jimage.
However, images will always always be shifted so that
from_index < to_index and from_jimage becomes (0, 0,... | pymatgen/analysis/graphs.py | def add_edge(self, from_index, to_index,
from_jimage=(0, 0, 0), to_jimage=None,
weight=None, warn_duplicates=True,
edge_properties=None):
"""
Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have ... | def add_edge(self, from_index, to_index,
from_jimage=(0, 0, 0), to_jimage=None,
weight=None, warn_duplicates=True,
edge_properties=None):
"""
Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have ... | [
"Add",
"edge",
"to",
"graph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L247-L351 | [
"def",
"add_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"from_jimage",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"to_jimage",
"=",
"None",
",",
"weight",
"=",
"None",
",",
"warn_duplicates",
"=",
"True",
",",
"edge_properties",
"=",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.alter_edge | Alters either the weight or the edge_properties of
an edge in the StructureGraph.
:param from_index: int
:param to_index: int
:param to_jimage: tuple
:param new_weight: alter_edge does not require
that weight be altered. As such, by default, this
is None. If weig... | pymatgen/analysis/graphs.py | def alter_edge(self, from_index, to_index, to_jimage=None,
new_weight=None, new_edge_properties=None):
"""
Alters either the weight or the edge_properties of
an edge in the StructureGraph.
:param from_index: int
:param to_index: int
:param to_jimage: t... | def alter_edge(self, from_index, to_index, to_jimage=None,
new_weight=None, new_edge_properties=None):
"""
Alters either the weight or the edge_properties of
an edge in the StructureGraph.
:param from_index: int
:param to_index: int
:param to_jimage: t... | [
"Alters",
"either",
"the",
"weight",
"or",
"the",
"edge_properties",
"of",
"an",
"edge",
"in",
"the",
"StructureGraph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L424-L465 | [
"def",
"alter_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"to_jimage",
"=",
"None",
",",
"new_weight",
"=",
"None",
",",
"new_edge_properties",
"=",
"None",
")",
":",
"existing_edges",
"=",
"self",
".",
"graph",
".",
"get_edge_data",
"(",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.break_edge | Remove an edge from the StructureGraph. If no image is given, this method will fail.
:param from_index: int
:param to_index: int
:param to_jimage: tuple
:param allow_reverse: If allow_reverse is True, then break_edge will
attempt to break both (from_index, to_index) and, failing... | pymatgen/analysis/graphs.py | def break_edge(self, from_index, to_index, to_jimage=None, allow_reverse=False):
"""
Remove an edge from the StructureGraph. If no image is given, this method will fail.
:param from_index: int
:param to_index: int
:param to_jimage: tuple
:param allow_reverse: If allow_re... | def break_edge(self, from_index, to_index, to_jimage=None, allow_reverse=False):
"""
Remove an edge from the StructureGraph. If no image is given, this method will fail.
:param from_index: int
:param to_index: int
:param to_jimage: tuple
:param allow_reverse: If allow_re... | [
"Remove",
"an",
"edge",
"from",
"the",
"StructureGraph",
".",
"If",
"no",
"image",
"is",
"given",
"this",
"method",
"will",
"fail",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L467-L508 | [
"def",
"break_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"to_jimage",
"=",
"None",
",",
"allow_reverse",
"=",
"False",
")",
":",
"# ensure that edge exists before attempting to remove it",
"existing_edges",
"=",
"self",
".",
"graph",
".",
"get_edge... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.substitute_group | Builds off of Structure.substitute to replace an atom in self.structure
with a functional group. This method also amends self.graph to
incorporate the new functional group.
NOTE: Care must be taken to ensure that the functional group that is
substituted will not place atoms to close to ... | pymatgen/analysis/graphs.py | def substitute_group(self, index, func_grp, strategy, bond_order=1,
graph_dict=None, strategy_params=None):
"""
Builds off of Structure.substitute to replace an atom in self.structure
with a functional group. This method also amends self.graph to
incorporate the ... | def substitute_group(self, index, func_grp, strategy, bond_order=1,
graph_dict=None, strategy_params=None):
"""
Builds off of Structure.substitute to replace an atom in self.structure
with a functional group. This method also amends self.graph to
incorporate the ... | [
"Builds",
"off",
"of",
"Structure",
".",
"substitute",
"to",
"replace",
"an",
"atom",
"in",
"self",
".",
"structure",
"with",
"a",
"functional",
"group",
".",
"This",
"method",
"also",
"amends",
"self",
".",
"graph",
"to",
"incorporate",
"the",
"new",
"fun... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L529-L627 | [
"def",
"substitute_group",
"(",
"self",
",",
"index",
",",
"func_grp",
",",
"strategy",
",",
"bond_order",
"=",
"1",
",",
"graph_dict",
"=",
"None",
",",
"strategy_params",
"=",
"None",
")",
":",
"def",
"map_indices",
"(",
"grp",
")",
":",
"grp_map",
"="... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.get_connected_sites | Returns a named tuple of neighbors of site n:
periodic_site, jimage, index, weight.
Index is the index of the corresponding site
in the original structure, weight can be
None if not defined.
:param n: index of Site in Structure
:param jimage: lattice vector of site
... | pymatgen/analysis/graphs.py | def get_connected_sites(self, n, jimage=(0, 0, 0)):
"""
Returns a named tuple of neighbors of site n:
periodic_site, jimage, index, weight.
Index is the index of the corresponding site
in the original structure, weight can be
None if not defined.
:param n: index o... | def get_connected_sites(self, n, jimage=(0, 0, 0)):
"""
Returns a named tuple of neighbors of site n:
periodic_site, jimage, index, weight.
Index is the index of the corresponding site
in the original structure, weight can be
None if not defined.
:param n: index o... | [
"Returns",
"a",
"named",
"tuple",
"of",
"neighbors",
"of",
"site",
"n",
":",
"periodic_site",
"jimage",
"index",
"weight",
".",
"Index",
"is",
"the",
"index",
"of",
"the",
"corresponding",
"site",
"in",
"the",
"original",
"structure",
"weight",
"can",
"be",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L629-L682 | [
"def",
"get_connected_sites",
"(",
"self",
",",
"n",
",",
"jimage",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"connected_sites",
"=",
"set",
"(",
")",
"connected_site_images",
"=",
"set",
"(",
")",
"out_edges",
"=",
"[",
"(",
"u",
",",
"v",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.get_coordination_of_site | Returns the number of neighbors of site n.
In graph terms, simply returns degree
of node corresponding to site n.
:param n: index of site
:return (int): | pymatgen/analysis/graphs.py | def get_coordination_of_site(self, n):
"""
Returns the number of neighbors of site n.
In graph terms, simply returns degree
of node corresponding to site n.
:param n: index of site
:return (int):
"""
number_of_self_loops = sum([1 for n, v in self.graph.edg... | def get_coordination_of_site(self, n):
"""
Returns the number of neighbors of site n.
In graph terms, simply returns degree
of node corresponding to site n.
:param n: index of site
:return (int):
"""
number_of_self_loops = sum([1 for n, v in self.graph.edg... | [
"Returns",
"the",
"number",
"of",
"neighbors",
"of",
"site",
"n",
".",
"In",
"graph",
"terms",
"simply",
"returns",
"degree",
"of",
"node",
"corresponding",
"to",
"site",
"n",
".",
":",
"param",
"n",
":",
"index",
"of",
"site",
":",
"return",
"(",
"int... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L684-L693 | [
"def",
"get_coordination_of_site",
"(",
"self",
",",
"n",
")",
":",
"number_of_self_loops",
"=",
"sum",
"(",
"[",
"1",
"for",
"n",
",",
"v",
"in",
"self",
".",
"graph",
".",
"edges",
"(",
"n",
")",
"if",
"n",
"==",
"v",
"]",
")",
"return",
"self",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.draw_graph_to_file | Draws graph using GraphViz.
The networkx graph object itself can also be drawn
with networkx's in-built graph drawing methods, but
note that this might give misleading results for
multigraphs (edges are super-imposed on each other).
If visualization is difficult to interpret,
... | pymatgen/analysis/graphs.py | def draw_graph_to_file(self, filename="graph",
diff=None,
hide_unconnected_nodes=False,
hide_image_edges=True,
edge_colors=False,
node_labels=False,
weight_la... | def draw_graph_to_file(self, filename="graph",
diff=None,
hide_unconnected_nodes=False,
hide_image_edges=True,
edge_colors=False,
node_labels=False,
weight_la... | [
"Draws",
"graph",
"using",
"GraphViz",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L695-L862 | [
"def",
"draw_graph_to_file",
"(",
"self",
",",
"filename",
"=",
"\"graph\"",
",",
"diff",
"=",
"None",
",",
"hide_unconnected_nodes",
"=",
"False",
",",
"hide_image_edges",
"=",
"True",
",",
"edge_colors",
"=",
"False",
",",
"node_labels",
"=",
"False",
",",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.types_and_weights_of_connections | Extract a dictionary summarizing the types and weights
of edges in the graph.
:return: A dictionary with keys specifying the
species involved in a connection in alphabetical order
(e.g. string 'Fe-O') and values which are a list of
weights for those connections (e.g. bond length... | pymatgen/analysis/graphs.py | def types_and_weights_of_connections(self):
"""
Extract a dictionary summarizing the types and weights
of edges in the graph.
:return: A dictionary with keys specifying the
species involved in a connection in alphabetical order
(e.g. string 'Fe-O') and values which are a... | def types_and_weights_of_connections(self):
"""
Extract a dictionary summarizing the types and weights
of edges in the graph.
:return: A dictionary with keys specifying the
species involved in a connection in alphabetical order
(e.g. string 'Fe-O') and values which are a... | [
"Extract",
"a",
"dictionary",
"summarizing",
"the",
"types",
"and",
"weights",
"of",
"edges",
"in",
"the",
"graph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L865-L885 | [
"def",
"types_and_weights_of_connections",
"(",
"self",
")",
":",
"def",
"get_label",
"(",
"u",
",",
"v",
")",
":",
"u_label",
"=",
"self",
".",
"structure",
"[",
"u",
"]",
".",
"species_string",
"v_label",
"=",
"self",
".",
"structure",
"[",
"v",
"]",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.weight_statistics | Extract a statistical summary of edge weights present in
the graph.
:return: A dict with an 'all_weights' list, 'minimum',
'maximum', 'median', 'mean', 'std_dev' | pymatgen/analysis/graphs.py | def weight_statistics(self):
"""
Extract a statistical summary of edge weights present in
the graph.
:return: A dict with an 'all_weights' list, 'minimum',
'maximum', 'median', 'mean', 'std_dev'
"""
all_weights = [d.get('weight', None) for u, v, d
... | def weight_statistics(self):
"""
Extract a statistical summary of edge weights present in
the graph.
:return: A dict with an 'all_weights' list, 'minimum',
'maximum', 'median', 'mean', 'std_dev'
"""
all_weights = [d.get('weight', None) for u, v, d
... | [
"Extract",
"a",
"statistical",
"summary",
"of",
"edge",
"weights",
"present",
"in",
"the",
"graph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L888-L907 | [
"def",
"weight_statistics",
"(",
"self",
")",
":",
"all_weights",
"=",
"[",
"d",
".",
"get",
"(",
"'weight'",
",",
"None",
")",
"for",
"u",
",",
"v",
",",
"d",
"in",
"self",
".",
"graph",
".",
"edges",
"(",
"data",
"=",
"True",
")",
"]",
"stats",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.types_of_coordination_environments | Extract information on the different co-ordination environments
present in the graph.
:param anonymous: if anonymous, will replace specie names
with A, B, C, etc.
:return: a list of co-ordination environments,
e.g. ['Mo-S(6)', 'S-Mo(3)'] | pymatgen/analysis/graphs.py | def types_of_coordination_environments(self, anonymous=False):
"""
Extract information on the different co-ordination environments
present in the graph.
:param anonymous: if anonymous, will replace specie names
with A, B, C, etc.
:return: a list of co-ordination environm... | def types_of_coordination_environments(self, anonymous=False):
"""
Extract information on the different co-ordination environments
present in the graph.
:param anonymous: if anonymous, will replace specie names
with A, B, C, etc.
:return: a list of co-ordination environm... | [
"Extract",
"information",
"on",
"the",
"different",
"co",
"-",
"ordination",
"environments",
"present",
"in",
"the",
"graph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L909-L950 | [
"def",
"types_of_coordination_environments",
"(",
"self",
",",
"anonymous",
"=",
"False",
")",
":",
"motifs",
"=",
"set",
"(",
")",
"for",
"idx",
",",
"site",
"in",
"enumerate",
"(",
"self",
".",
"structure",
")",
":",
"centre_sp",
"=",
"site",
".",
"spe... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.from_dict | As in :Class: `pymatgen.core.Structure` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information. | pymatgen/analysis/graphs.py | def from_dict(cls, d):
"""
As in :Class: `pymatgen.core.Structure` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information.
"""
s = Structure.from_dict(d['structure'])
return cls(s, d['graphs']) | def from_dict(cls, d):
"""
As in :Class: `pymatgen.core.Structure` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information.
"""
s = Structure.from_dict(d['structure'])
return cls(s, d['graphs']) | [
"As",
"in",
":",
"Class",
":",
"pymatgen",
".",
"core",
".",
"Structure",
"except",
"restoring",
"graphs",
"using",
"from_dict_of_dicts",
"from",
"NetworkX",
"to",
"restore",
"graph",
"information",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L967-L974 | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"s",
"=",
"Structure",
".",
"from_dict",
"(",
"d",
"[",
"'structure'",
"]",
")",
"return",
"cls",
"(",
"s",
",",
"d",
"[",
"'graphs'",
"]",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.sort | Same as Structure.sort(), also remaps nodes in graph.
:param key:
:param reverse:
:return: | pymatgen/analysis/graphs.py | def sort(self, key=None, reverse=False):
"""
Same as Structure.sort(), also remaps nodes in graph.
:param key:
:param reverse:
:return:
"""
old_structure = self.structure.copy()
# sort Structure
self.structure._sites = sorted(self.structure._site... | def sort(self, key=None, reverse=False):
"""
Same as Structure.sort(), also remaps nodes in graph.
:param key:
:param reverse:
:return:
"""
old_structure = self.structure.copy()
# sort Structure
self.structure._sites = sorted(self.structure._site... | [
"Same",
"as",
"Structure",
".",
"sort",
"()",
"also",
"remaps",
"nodes",
"in",
"graph",
".",
":",
"param",
"key",
":",
":",
"param",
"reverse",
":",
":",
"return",
":"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1240-L1271 | [
"def",
"sort",
"(",
"self",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"old_structure",
"=",
"self",
".",
"structure",
".",
"copy",
"(",
")",
"# sort Structure",
"self",
".",
"structure",
".",
"_sites",
"=",
"sorted",
"(",
"self",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.diff | Compares two StructureGraphs. Returns dict with
keys 'self', 'other', 'both' with edges that are
present in only one StructureGraph ('self' and
'other'), and edges that are present in both.
The Jaccard distance is a simple measure of the
dissimilarity between two StructureGraphs... | pymatgen/analysis/graphs.py | def diff(self, other, strict=True):
"""
Compares two StructureGraphs. Returns dict with
keys 'self', 'other', 'both' with edges that are
present in only one StructureGraph ('self' and
'other'), and edges that are present in both.
The Jaccard distance is a simple measure ... | def diff(self, other, strict=True):
"""
Compares two StructureGraphs. Returns dict with
keys 'self', 'other', 'both' with edges that are
present in only one StructureGraph ('self' and
'other'), and edges that are present in both.
The Jaccard distance is a simple measure ... | [
"Compares",
"two",
"StructureGraphs",
".",
"Returns",
"dict",
"with",
"keys",
"self",
"other",
"both",
"with",
"edges",
"that",
"are",
"present",
"in",
"only",
"one",
"StructureGraph",
"(",
"self",
"and",
"other",
")",
"and",
"edges",
"that",
"are",
"present... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1302-L1369 | [
"def",
"diff",
"(",
"self",
",",
"other",
",",
"strict",
"=",
"True",
")",
":",
"if",
"self",
".",
"structure",
"!=",
"other",
".",
"structure",
"and",
"strict",
":",
"return",
"ValueError",
"(",
"\"Meaningless to compare StructureGraphs if \"",
"\"corresponding... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureGraph.get_subgraphs_as_molecules | Retrieve subgraphs as molecules, useful for extracting
molecules from periodic crystals.
Will only return unique molecules, not any duplicates
present in the crystal (a duplicate defined as an
isomorphic subgraph).
:param use_weights (bool): If True, only treat subgraphs
... | pymatgen/analysis/graphs.py | def get_subgraphs_as_molecules(self, use_weights=False):
"""
Retrieve subgraphs as molecules, useful for extracting
molecules from periodic crystals.
Will only return unique molecules, not any duplicates
present in the crystal (a duplicate defined as an
isomorphic subgra... | def get_subgraphs_as_molecules(self, use_weights=False):
"""
Retrieve subgraphs as molecules, useful for extracting
molecules from periodic crystals.
Will only return unique molecules, not any duplicates
present in the crystal (a duplicate defined as an
isomorphic subgra... | [
"Retrieve",
"subgraphs",
"as",
"molecules",
"useful",
"for",
"extracting",
"molecules",
"from",
"periodic",
"crystals",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1371-L1453 | [
"def",
"get_subgraphs_as_molecules",
"(",
"self",
",",
"use_weights",
"=",
"False",
")",
":",
"# creating a supercell is an easy way to extract",
"# molecules (and not, e.g., layers of a 2D crystal)",
"# without adding extra logic",
"if",
"getattr",
"(",
"self",
",",
"'_supercell... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.with_empty_graph | Constructor for MoleculeGraph, returns a MoleculeGraph
object with an empty graph (no edges, only nodes defined
that correspond to Sites in Molecule).
:param molecule (Molecule):
:param name (str): name of graph, e.g. "bonds"
:param edge_weight_name (str): name of edge weights,
... | pymatgen/analysis/graphs.py | def with_empty_graph(cls, molecule, name="bonds",
edge_weight_name=None,
edge_weight_units=None):
"""
Constructor for MoleculeGraph, returns a MoleculeGraph
object with an empty graph (no edges, only nodes defined
that correspond to Sites... | def with_empty_graph(cls, molecule, name="bonds",
edge_weight_name=None,
edge_weight_units=None):
"""
Constructor for MoleculeGraph, returns a MoleculeGraph
object with an empty graph (no edges, only nodes defined
that correspond to Sites... | [
"Constructor",
"for",
"MoleculeGraph",
"returns",
"a",
"MoleculeGraph",
"object",
"with",
"an",
"empty",
"graph",
"(",
"no",
"edges",
"only",
"nodes",
"defined",
"that",
"correspond",
"to",
"Sites",
"in",
"Molecule",
")",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1519-L1552 | [
"def",
"with_empty_graph",
"(",
"cls",
",",
"molecule",
",",
"name",
"=",
"\"bonds\"",
",",
"edge_weight_name",
"=",
"None",
",",
"edge_weight_units",
"=",
"None",
")",
":",
"if",
"edge_weight_name",
"and",
"(",
"edge_weight_units",
"is",
"None",
")",
":",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.with_edges | Constructor for MoleculeGraph, using pre-existing or pre-defined edges
with optional edge parameters.
:param molecule: Molecule object
:param edges: dict representing the bonds of the functional
group (format: {(u, v): props}, where props is a dictionary of
prope... | pymatgen/analysis/graphs.py | def with_edges(molecule, edges):
"""
Constructor for MoleculeGraph, using pre-existing or pre-defined edges
with optional edge parameters.
:param molecule: Molecule object
:param edges: dict representing the bonds of the functional
group (format: {(u, v): props},... | def with_edges(molecule, edges):
"""
Constructor for MoleculeGraph, using pre-existing or pre-defined edges
with optional edge parameters.
:param molecule: Molecule object
:param edges: dict representing the bonds of the functional
group (format: {(u, v): props},... | [
"Constructor",
"for",
"MoleculeGraph",
"using",
"pre",
"-",
"existing",
"or",
"pre",
"-",
"defined",
"edges",
"with",
"optional",
"edge",
"parameters",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1555-L1603 | [
"def",
"with_edges",
"(",
"molecule",
",",
"edges",
")",
":",
"mg",
"=",
"MoleculeGraph",
".",
"with_empty_graph",
"(",
"molecule",
",",
"name",
"=",
"\"bonds\"",
",",
"edge_weight_name",
"=",
"\"weight\"",
",",
"edge_weight_units",
"=",
"\"\"",
")",
"for",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.with_local_env_strategy | Constructor for MoleculeGraph, using a strategy
from :Class: `pymatgen.analysis.local_env`.
:param molecule: Molecule object
:param strategy: an instance of a
:Class: `pymatgen.analysis.local_env.NearNeighbors` object
:param reorder: bool, representing if graph nodes need to... | pymatgen/analysis/graphs.py | def with_local_env_strategy(molecule, strategy, reorder=True,
extend_structure=True):
"""
Constructor for MoleculeGraph, using a strategy
from :Class: `pymatgen.analysis.local_env`.
:param molecule: Molecule object
:param strategy: an instance of ... | def with_local_env_strategy(molecule, strategy, reorder=True,
extend_structure=True):
"""
Constructor for MoleculeGraph, using a strategy
from :Class: `pymatgen.analysis.local_env`.
:param molecule: Molecule object
:param strategy: an instance of ... | [
"Constructor",
"for",
"MoleculeGraph",
"using",
"a",
"strategy",
"from",
":",
"Class",
":",
"pymatgen",
".",
"analysis",
".",
"local_env",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1606-L1673 | [
"def",
"with_local_env_strategy",
"(",
"molecule",
",",
"strategy",
",",
"reorder",
"=",
"True",
",",
"extend_structure",
"=",
"True",
")",
":",
"mg",
"=",
"MoleculeGraph",
".",
"with_empty_graph",
"(",
"molecule",
",",
"name",
"=",
"\"bonds\"",
",",
"edge_wei... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.add_edge | Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have a direction, from_index,
from_jimage can be swapped with to_index, to_jimage.
However, images will always always be shifted so that
from_index < to_index and from_jimage becomes (0, 0,... | pymatgen/analysis/graphs.py | def add_edge(self, from_index, to_index,
weight=None, warn_duplicates=True,
edge_properties=None):
"""
Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have a direction, from_index,
from_jimage can be swap... | def add_edge(self, from_index, to_index,
weight=None, warn_duplicates=True,
edge_properties=None):
"""
Add edge to graph.
Since physically a 'bond' (or other connection
between sites) doesn't have a direction, from_index,
from_jimage can be swap... | [
"Add",
"edge",
"to",
"graph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1696-L1748 | [
"def",
"add_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"weight",
"=",
"None",
",",
"warn_duplicates",
"=",
"True",
",",
"edge_properties",
"=",
"None",
")",
":",
"# this is not necessary for the class to work, but",
"# just makes it neater",
"if",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.insert_node | A wrapper around Molecule.insert(), which also incorporates the new
site into the MoleculeGraph.
:param i: Index at which to insert the new site
:param species: Species for the new site
:param coords: 3x1 array representing coordinates of the new site
:param validate_proximity: ... | pymatgen/analysis/graphs.py | def insert_node(self, i, species, coords, validate_proximity=False,
site_properties=None, edges=None):
"""
A wrapper around Molecule.insert(), which also incorporates the new
site into the MoleculeGraph.
:param i: Index at which to insert the new site
:param ... | def insert_node(self, i, species, coords, validate_proximity=False,
site_properties=None, edges=None):
"""
A wrapper around Molecule.insert(), which also incorporates the new
site into the MoleculeGraph.
:param i: Index at which to insert the new site
:param ... | [
"A",
"wrapper",
"around",
"Molecule",
".",
"insert",
"()",
"which",
"also",
"incorporates",
"the",
"new",
"site",
"into",
"the",
"MoleculeGraph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1750-L1794 | [
"def",
"insert_node",
"(",
"self",
",",
"i",
",",
"species",
",",
"coords",
",",
"validate_proximity",
"=",
"False",
",",
"site_properties",
"=",
"None",
",",
"edges",
"=",
"None",
")",
":",
"self",
".",
"molecule",
".",
"insert",
"(",
"i",
",",
"speci... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.set_node_attributes | Replicates molecule site properties (specie, coords, etc.) in the
MoleculeGraph.
:return: | pymatgen/analysis/graphs.py | def set_node_attributes(self):
"""
Replicates molecule site properties (specie, coords, etc.) in the
MoleculeGraph.
:return:
"""
species = {}
coords = {}
properties = {}
for node in self.graph.nodes():
species[node] = self.molecule[no... | def set_node_attributes(self):
"""
Replicates molecule site properties (specie, coords, etc.) in the
MoleculeGraph.
:return:
"""
species = {}
coords = {}
properties = {}
for node in self.graph.nodes():
species[node] = self.molecule[no... | [
"Replicates",
"molecule",
"site",
"properties",
"(",
"specie",
"coords",
"etc",
".",
")",
"in",
"the",
"MoleculeGraph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1796-L1814 | [
"def",
"set_node_attributes",
"(",
"self",
")",
":",
"species",
"=",
"{",
"}",
"coords",
"=",
"{",
"}",
"properties",
"=",
"{",
"}",
"for",
"node",
"in",
"self",
".",
"graph",
".",
"nodes",
"(",
")",
":",
"species",
"[",
"node",
"]",
"=",
"self",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.alter_edge | Alters either the weight or the edge_properties of
an edge in the MoleculeGraph.
:param from_index: int
:param to_index: int
:param new_weight: alter_edge does not require
that weight be altered. As such, by default, this
is None. If weight is to be changed, it should be... | pymatgen/analysis/graphs.py | def alter_edge(self, from_index, to_index,
new_weight=None, new_edge_properties=None):
"""
Alters either the weight or the edge_properties of
an edge in the MoleculeGraph.
:param from_index: int
:param to_index: int
:param new_weight: alter_edge does n... | def alter_edge(self, from_index, to_index,
new_weight=None, new_edge_properties=None):
"""
Alters either the weight or the edge_properties of
an edge in the MoleculeGraph.
:param from_index: int
:param to_index: int
:param new_weight: alter_edge does n... | [
"Alters",
"either",
"the",
"weight",
"or",
"the",
"edge_properties",
"of",
"an",
"edge",
"in",
"the",
"MoleculeGraph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1816-L1850 | [
"def",
"alter_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"new_weight",
"=",
"None",
",",
"new_edge_properties",
"=",
"None",
")",
":",
"existing_edge",
"=",
"self",
".",
"graph",
".",
"get_edge_data",
"(",
"from_index",
",",
"to_index",
")"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.break_edge | Remove an edge from the MoleculeGraph
:param from_index: int
:param to_index: int
:param allow_reverse: If allow_reverse is True, then break_edge will
attempt to break both (from_index, to_index) and, failing that,
will attempt to break (to_index, from_index).
:return: | pymatgen/analysis/graphs.py | def break_edge(self, from_index, to_index, allow_reverse=False):
"""
Remove an edge from the MoleculeGraph
:param from_index: int
:param to_index: int
:param allow_reverse: If allow_reverse is True, then break_edge will
attempt to break both (from_index, to_index) and, f... | def break_edge(self, from_index, to_index, allow_reverse=False):
"""
Remove an edge from the MoleculeGraph
:param from_index: int
:param to_index: int
:param allow_reverse: If allow_reverse is True, then break_edge will
attempt to break both (from_index, to_index) and, f... | [
"Remove",
"an",
"edge",
"from",
"the",
"MoleculeGraph"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1852-L1882 | [
"def",
"break_edge",
"(",
"self",
",",
"from_index",
",",
"to_index",
",",
"allow_reverse",
"=",
"False",
")",
":",
"# ensure that edge exists before attempting to remove it",
"existing_edge",
"=",
"self",
".",
"graph",
".",
"get_edge_data",
"(",
"from_index",
",",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.remove_nodes | A wrapper for Molecule.remove_sites().
:param indices: list of indices in the current Molecule (and graph) to
be removed.
:return: | pymatgen/analysis/graphs.py | def remove_nodes(self, indices):
"""
A wrapper for Molecule.remove_sites().
:param indices: list of indices in the current Molecule (and graph) to
be removed.
:return:
"""
self.molecule.remove_sites(indices)
self.graph.remove_nodes_from(indices)
... | def remove_nodes(self, indices):
"""
A wrapper for Molecule.remove_sites().
:param indices: list of indices in the current Molecule (and graph) to
be removed.
:return:
"""
self.molecule.remove_sites(indices)
self.graph.remove_nodes_from(indices)
... | [
"A",
"wrapper",
"for",
"Molecule",
".",
"remove_sites",
"()",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1884-L1901 | [
"def",
"remove_nodes",
"(",
"self",
",",
"indices",
")",
":",
"self",
".",
"molecule",
".",
"remove_sites",
"(",
"indices",
")",
"self",
".",
"graph",
".",
"remove_nodes_from",
"(",
"indices",
")",
"mapping",
"=",
"{",
"}",
"for",
"correct",
",",
"curren... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.split_molecule_subgraphs | Split MoleculeGraph into two or more MoleculeGraphs by
breaking a set of bonds. This function uses
MoleculeGraph.break_edge repeatedly to create
disjoint graphs (two or more separate molecules).
This function does not only alter the graph
information, but also changes the underly... | pymatgen/analysis/graphs.py | def split_molecule_subgraphs(self, bonds, allow_reverse=False,
alterations=None):
"""
Split MoleculeGraph into two or more MoleculeGraphs by
breaking a set of bonds. This function uses
MoleculeGraph.break_edge repeatedly to create
disjoint graphs ... | def split_molecule_subgraphs(self, bonds, allow_reverse=False,
alterations=None):
"""
Split MoleculeGraph into two or more MoleculeGraphs by
breaking a set of bonds. This function uses
MoleculeGraph.break_edge repeatedly to create
disjoint graphs ... | [
"Split",
"MoleculeGraph",
"into",
"two",
"or",
"more",
"MoleculeGraphs",
"by",
"breaking",
"a",
"set",
"of",
"bonds",
".",
"This",
"function",
"uses",
"MoleculeGraph",
".",
"break_edge",
"repeatedly",
"to",
"create",
"disjoint",
"graphs",
"(",
"two",
"or",
"mo... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L1903-L2013 | [
"def",
"split_molecule_subgraphs",
"(",
"self",
",",
"bonds",
",",
"allow_reverse",
"=",
"False",
",",
"alterations",
"=",
"None",
")",
":",
"self",
".",
"set_node_attributes",
"(",
")",
"original",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"for",
"b... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.build_unique_fragments | Find all possible fragment combinations of the MoleculeGraphs (in other
words, all connected induced subgraphs)
:return: | pymatgen/analysis/graphs.py | def build_unique_fragments(self):
"""
Find all possible fragment combinations of the MoleculeGraphs (in other
words, all connected induced subgraphs)
:return:
"""
self.set_node_attributes()
graph = self.graph.to_undirected()
nm = iso.categorical_node_ma... | def build_unique_fragments(self):
"""
Find all possible fragment combinations of the MoleculeGraphs (in other
words, all connected induced subgraphs)
:return:
"""
self.set_node_attributes()
graph = self.graph.to_undirected()
nm = iso.categorical_node_ma... | [
"Find",
"all",
"possible",
"fragment",
"combinations",
"of",
"the",
"MoleculeGraphs",
"(",
"in",
"other",
"words",
"all",
"connected",
"induced",
"subgraphs",
")"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2015-L2063 | [
"def",
"build_unique_fragments",
"(",
"self",
")",
":",
"self",
".",
"set_node_attributes",
"(",
")",
"graph",
"=",
"self",
".",
"graph",
".",
"to_undirected",
"(",
")",
"nm",
"=",
"iso",
".",
"categorical_node_match",
"(",
"\"specie\"",
",",
"\"ERROR\"",
")... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.substitute_group | Builds off of Molecule.substitute to replace an atom in self.molecule
with a functional group. This method also amends self.graph to
incorporate the new functional group.
NOTE: using a MoleculeGraph will generally produce a different graph
compared with using a Molecule or str (when not... | pymatgen/analysis/graphs.py | def substitute_group(self, index, func_grp, strategy, bond_order=1,
graph_dict=None, strategy_params=None, reorder=True,
extend_structure=True):
"""
Builds off of Molecule.substitute to replace an atom in self.molecule
with a functional group. Th... | def substitute_group(self, index, func_grp, strategy, bond_order=1,
graph_dict=None, strategy_params=None, reorder=True,
extend_structure=True):
"""
Builds off of Molecule.substitute to replace an atom in self.molecule
with a functional group. Th... | [
"Builds",
"off",
"of",
"Molecule",
".",
"substitute",
"to",
"replace",
"an",
"atom",
"in",
"self",
".",
"molecule",
"with",
"a",
"functional",
"group",
".",
"This",
"method",
"also",
"amends",
"self",
".",
"graph",
"to",
"incorporate",
"the",
"new",
"funct... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2065-L2187 | [
"def",
"substitute_group",
"(",
"self",
",",
"index",
",",
"func_grp",
",",
"strategy",
",",
"bond_order",
"=",
"1",
",",
"graph_dict",
"=",
"None",
",",
"strategy_params",
"=",
"None",
",",
"reorder",
"=",
"True",
",",
"extend_structure",
"=",
"True",
")"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.replace_group | Builds off of Molecule.substitute and MoleculeGraph.substitute_group
to replace a functional group in self.molecule with a functional group.
This method also amends self.graph to incorporate the new functional
group.
TODO: Figure out how to replace into a ring structure.
:param... | pymatgen/analysis/graphs.py | def replace_group(self, index, func_grp, strategy, bond_order=1,
graph_dict=None, strategy_params=None, reorder=True,
extend_structure=True):
"""
Builds off of Molecule.substitute and MoleculeGraph.substitute_group
to replace a functional group in self... | def replace_group(self, index, func_grp, strategy, bond_order=1,
graph_dict=None, strategy_params=None, reorder=True,
extend_structure=True):
"""
Builds off of Molecule.substitute and MoleculeGraph.substitute_group
to replace a functional group in self... | [
"Builds",
"off",
"of",
"Molecule",
".",
"substitute",
"and",
"MoleculeGraph",
".",
"substitute_group",
"to",
"replace",
"a",
"functional",
"group",
"in",
"self",
".",
"molecule",
"with",
"a",
"functional",
"group",
".",
"This",
"method",
"also",
"amends",
"sel... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2189-L2270 | [
"def",
"replace_group",
"(",
"self",
",",
"index",
",",
"func_grp",
",",
"strategy",
",",
"bond_order",
"=",
"1",
",",
"graph_dict",
"=",
"None",
",",
"strategy_params",
"=",
"None",
",",
"reorder",
"=",
"True",
",",
"extend_structure",
"=",
"True",
")",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.find_rings | Find ring structures in the MoleculeGraph.
:param including: list of site indices. If
including is not None, then find_rings will
only return those rings including the specified
sites. By default, this parameter is None, and
all rings will be returned.
:return: dict {ind... | pymatgen/analysis/graphs.py | def find_rings(self, including=None):
"""
Find ring structures in the MoleculeGraph.
:param including: list of site indices. If
including is not None, then find_rings will
only return those rings including the specified
sites. By default, this parameter is None, and
... | def find_rings(self, including=None):
"""
Find ring structures in the MoleculeGraph.
:param including: list of site indices. If
including is not None, then find_rings will
only return those rings including the specified
sites. By default, this parameter is None, and
... | [
"Find",
"ring",
"structures",
"in",
"the",
"MoleculeGraph",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2272-L2320 | [
"def",
"find_rings",
"(",
"self",
",",
"including",
"=",
"None",
")",
":",
"# Copies self.graph such that all edges (u, v) matched by edges (v, u)",
"undirected",
"=",
"self",
".",
"graph",
".",
"to_undirected",
"(",
")",
"directed",
"=",
"undirected",
".",
"to_direct... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.get_connected_sites | Returns a named tuple of neighbors of site n:
periodic_site, jimage, index, weight.
Index is the index of the corresponding site
in the original structure, weight can be
None if not defined.
:param n: index of Site in Molecule
:param jimage: lattice vector of site
... | pymatgen/analysis/graphs.py | def get_connected_sites(self, n):
"""
Returns a named tuple of neighbors of site n:
periodic_site, jimage, index, weight.
Index is the index of the corresponding site
in the original structure, weight can be
None if not defined.
:param n: index of Site in Molecule... | def get_connected_sites(self, n):
"""
Returns a named tuple of neighbors of site n:
periodic_site, jimage, index, weight.
Index is the index of the corresponding site
in the original structure, weight can be
None if not defined.
:param n: index of Site in Molecule... | [
"Returns",
"a",
"named",
"tuple",
"of",
"neighbors",
"of",
"site",
"n",
":",
"periodic_site",
"jimage",
"index",
"weight",
".",
"Index",
"is",
"the",
"index",
"of",
"the",
"corresponding",
"site",
"in",
"the",
"original",
"structure",
"weight",
"can",
"be",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2322-L2369 | [
"def",
"get_connected_sites",
"(",
"self",
",",
"n",
")",
":",
"connected_sites",
"=",
"set",
"(",
")",
"out_edges",
"=",
"[",
"(",
"u",
",",
"v",
",",
"d",
")",
"for",
"u",
",",
"v",
",",
"d",
"in",
"self",
".",
"graph",
".",
"out_edges",
"(",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.as_dict | As in :Class: `pymatgen.core.Molecule` except
with using `to_dict_of_dicts` from NetworkX
to store graph information. | pymatgen/analysis/graphs.py | def as_dict(self):
"""
As in :Class: `pymatgen.core.Molecule` except
with using `to_dict_of_dicts` from NetworkX
to store graph information.
"""
d = {"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"molecule": self.molec... | def as_dict(self):
"""
As in :Class: `pymatgen.core.Molecule` except
with using `to_dict_of_dicts` from NetworkX
to store graph information.
"""
d = {"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"molecule": self.molec... | [
"As",
"in",
":",
"Class",
":",
"pymatgen",
".",
"core",
".",
"Molecule",
"except",
"with",
"using",
"to_dict_of_dicts",
"from",
"NetworkX",
"to",
"store",
"graph",
"information",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2554-L2566 | [
"def",
"as_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"\"@module\"",
":",
"self",
".",
"__class__",
".",
"__module__",
",",
"\"@class\"",
":",
"self",
".",
"__class__",
".",
"__name__",
",",
"\"molecule\"",
":",
"self",
".",
"molecule",
".",
"as_dict",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.from_dict | As in :Class: `pymatgen.core.Molecule` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information. | pymatgen/analysis/graphs.py | def from_dict(cls, d):
"""
As in :Class: `pymatgen.core.Molecule` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information.
"""
m = Molecule.from_dict(d['molecule'])
return cls(m, d['graphs']) | def from_dict(cls, d):
"""
As in :Class: `pymatgen.core.Molecule` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information.
"""
m = Molecule.from_dict(d['molecule'])
return cls(m, d['graphs']) | [
"As",
"in",
":",
"Class",
":",
"pymatgen",
".",
"core",
".",
"Molecule",
"except",
"restoring",
"graphs",
"using",
"from_dict_of_dicts",
"from",
"NetworkX",
"to",
"restore",
"graph",
"information",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2569-L2576 | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"m",
"=",
"Molecule",
".",
"from_dict",
"(",
"d",
"[",
"'molecule'",
"]",
")",
"return",
"cls",
"(",
"m",
",",
"d",
"[",
"'graphs'",
"]",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.sort | Same as Molecule.sort(), also remaps nodes in graph.
:param key:
:param reverse:
:return: | pymatgen/analysis/graphs.py | def sort(self, key=None, reverse=False):
"""
Same as Molecule.sort(), also remaps nodes in graph.
:param key:
:param reverse:
:return:
"""
old_molecule = self.molecule.copy()
# sort Molecule
self.molecule._sites = sorted(self.molecule._sites, key... | def sort(self, key=None, reverse=False):
"""
Same as Molecule.sort(), also remaps nodes in graph.
:param key:
:param reverse:
:return:
"""
old_molecule = self.molecule.copy()
# sort Molecule
self.molecule._sites = sorted(self.molecule._sites, key... | [
"Same",
"as",
"Molecule",
".",
"sort",
"()",
"also",
"remaps",
"nodes",
"in",
"graph",
".",
":",
"param",
"key",
":",
":",
"param",
"reverse",
":",
":",
"return",
":"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2632-L2663 | [
"def",
"sort",
"(",
"self",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"old_molecule",
"=",
"self",
".",
"molecule",
".",
"copy",
"(",
")",
"# sort Molecule",
"self",
".",
"molecule",
".",
"_sites",
"=",
"sorted",
"(",
"self",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | MoleculeGraph.isomorphic_to | Checks if the graphs of two MoleculeGraphs are isomorphic to one
another. In order to prevent problems with misdirected edges, both
graphs are converted into undirected nx.Graph objects.
:param other: MoleculeGraph object to be compared.
:return: bool | pymatgen/analysis/graphs.py | def isomorphic_to(self, other):
"""
Checks if the graphs of two MoleculeGraphs are isomorphic to one
another. In order to prevent problems with misdirected edges, both
graphs are converted into undirected nx.Graph objects.
:param other: MoleculeGraph object to be compared.
... | def isomorphic_to(self, other):
"""
Checks if the graphs of two MoleculeGraphs are isomorphic to one
another. In order to prevent problems with misdirected edges, both
graphs are converted into undirected nx.Graph objects.
:param other: MoleculeGraph object to be compared.
... | [
"Checks",
"if",
"the",
"graphs",
"of",
"two",
"MoleculeGraphs",
"are",
"isomorphic",
"to",
"one",
"another",
".",
"In",
"order",
"to",
"prevent",
"problems",
"with",
"misdirected",
"edges",
"both",
"graphs",
"are",
"converted",
"into",
"undirected",
"nx",
".",... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/graphs.py#L2696-L2712 | [
"def",
"isomorphic_to",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"molecule",
".",
"composition",
"!=",
"other",
".",
"molecule",
".",
"composition",
":",
"return",
"False",
"else",
":",
"self_undir",
"=",
"self",
".",
"graph",
".",
"to_und... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | _load_bond_length_data | Loads bond length data from json file | pymatgen/core/bonds.py | def _load_bond_length_data():
"""Loads bond length data from json file"""
with open(os.path.join(os.path.dirname(__file__),
"bond_lengths.json")) as f:
data = collections.defaultdict(dict)
for row in json.load(f):
els = sorted(row['elements'])
d... | def _load_bond_length_data():
"""Loads bond length data from json file"""
with open(os.path.join(os.path.dirname(__file__),
"bond_lengths.json")) as f:
data = collections.defaultdict(dict)
for row in json.load(f):
els = sorted(row['elements'])
d... | [
"Loads",
"bond",
"length",
"data",
"from",
"json",
"file"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L26-L34 | [
"def",
"_load_bond_length_data",
"(",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"bond_lengths.json\"",
")",
")",
"as",
"f",
":",
"data",
"=",
"collections",
".",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | obtain_all_bond_lengths | Obtain bond lengths for all bond orders from bond length database
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
default_bl: If a particular type of bond does not exist, use this
bond length as a default value (bond order = 1).
If None, a ValueError w... | pymatgen/core/bonds.py | def obtain_all_bond_lengths(sp1, sp2, default_bl=None):
"""
Obtain bond lengths for all bond orders from bond length database
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
default_bl: If a particular type of bond does not exist, use this
bond length as a... | def obtain_all_bond_lengths(sp1, sp2, default_bl=None):
"""
Obtain bond lengths for all bond orders from bond length database
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
default_bl: If a particular type of bond does not exist, use this
bond length as a... | [
"Obtain",
"bond",
"lengths",
"for",
"all",
"bond",
"orders",
"from",
"bond",
"length",
"database"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L127-L151 | [
"def",
"obtain_all_bond_lengths",
"(",
"sp1",
",",
"sp2",
",",
"default_bl",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"sp1",
",",
"Element",
")",
":",
"sp1",
"=",
"sp1",
".",
"symbol",
"if",
"isinstance",
"(",
"sp2",
",",
"Element",
")",
":",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | get_bond_order | Calculate the bond order given the distance of 2 species
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
dist: Their distance in angstrom
tol (float): Relative tolerance to test. Basically, the code
checks if the distance between the sites is larger than
... | pymatgen/core/bonds.py | def get_bond_order(sp1, sp2, dist, tol=0.2, default_bl=None):
"""
Calculate the bond order given the distance of 2 species
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
dist: Their distance in angstrom
tol (float): Relative tolerance to test. Basically, the ... | def get_bond_order(sp1, sp2, dist, tol=0.2, default_bl=None):
"""
Calculate the bond order given the distance of 2 species
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
dist: Their distance in angstrom
tol (float): Relative tolerance to test. Basically, the ... | [
"Calculate",
"the",
"bond",
"order",
"given",
"the",
"distance",
"of",
"2",
"species"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L154-L196 | [
"def",
"get_bond_order",
"(",
"sp1",
",",
"sp2",
",",
"dist",
",",
"tol",
"=",
"0.2",
",",
"default_bl",
"=",
"None",
")",
":",
"all_lengths",
"=",
"obtain_all_bond_lengths",
"(",
"sp1",
",",
"sp2",
",",
"default_bl",
")",
"# Transform bond lengths dict to lis... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | get_bond_length | Get the bond length between two species.
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
bond_order: For species with different possible bond orders,
this allows one to obtain the bond length for a particular bond
order. For example, to get the C=C bon... | pymatgen/core/bonds.py | def get_bond_length(sp1, sp2, bond_order=1):
"""
Get the bond length between two species.
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
bond_order: For species with different possible bond orders,
this allows one to obtain the bond length for a particula... | def get_bond_length(sp1, sp2, bond_order=1):
"""
Get the bond length between two species.
Args:
sp1 (Specie): First specie.
sp2 (Specie): Second specie.
bond_order: For species with different possible bond orders,
this allows one to obtain the bond length for a particula... | [
"Get",
"the",
"bond",
"length",
"between",
"two",
"species",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L199-L229 | [
"def",
"get_bond_length",
"(",
"sp1",
",",
"sp2",
",",
"bond_order",
"=",
"1",
")",
":",
"sp1",
"=",
"Element",
"(",
"sp1",
")",
"if",
"isinstance",
"(",
"sp1",
",",
"str",
")",
"else",
"sp1",
"sp2",
"=",
"Element",
"(",
"sp2",
")",
"if",
"isinstan... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | CovalentBond.get_bond_order | The bond order according the distance between the two sites
Args:
tol (float): Relative tolerance to test.
(1 + tol) * the longest bond distance is considered
to be the threshold length for a bond to exist.
(1 - tol) * the shortest bond distance is con... | pymatgen/core/bonds.py | def get_bond_order(self, tol=0.2, default_bl=None):
"""
The bond order according the distance between the two sites
Args:
tol (float): Relative tolerance to test.
(1 + tol) * the longest bond distance is considered
to be the threshold length for a bond... | def get_bond_order(self, tol=0.2, default_bl=None):
"""
The bond order according the distance between the two sites
Args:
tol (float): Relative tolerance to test.
(1 + tol) * the longest bond distance is considered
to be the threshold length for a bond... | [
"The",
"bond",
"order",
"according",
"the",
"distance",
"between",
"the",
"two",
"sites",
"Args",
":",
"tol",
"(",
"float",
")",
":",
"Relative",
"tolerance",
"to",
"test",
".",
"(",
"1",
"+",
"tol",
")",
"*",
"the",
"longest",
"bond",
"distance",
"is"... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L63-L83 | [
"def",
"get_bond_order",
"(",
"self",
",",
"tol",
"=",
"0.2",
",",
"default_bl",
"=",
"None",
")",
":",
"sp1",
"=",
"list",
"(",
"self",
".",
"site1",
".",
"species",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"sp2",
"=",
"list",
"(",
"self",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | CovalentBond.is_bonded | Test if two sites are bonded, up to a certain limit.
Args:
site1 (Site): First site
site2 (Site): Second site
tol (float): Relative tolerance to test. Basically, the code
checks if the distance between the sites is less than (1 +
tol) * typical... | pymatgen/core/bonds.py | def is_bonded(site1, site2, tol=0.2, bond_order=None, default_bl=None):
"""
Test if two sites are bonded, up to a certain limit.
Args:
site1 (Site): First site
site2 (Site): Second site
tol (float): Relative tolerance to test. Basically, the code
... | def is_bonded(site1, site2, tol=0.2, bond_order=None, default_bl=None):
"""
Test if two sites are bonded, up to a certain limit.
Args:
site1 (Site): First site
site2 (Site): Second site
tol (float): Relative tolerance to test. Basically, the code
... | [
"Test",
"if",
"two",
"sites",
"are",
"bonded",
"up",
"to",
"a",
"certain",
"limit",
".",
"Args",
":",
"site1",
"(",
"Site",
")",
":",
"First",
"site",
"site2",
"(",
"Site",
")",
":",
"Second",
"site",
"tol",
"(",
"float",
")",
":",
"Relative",
"tol... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/bonds.py#L86-L117 | [
"def",
"is_bonded",
"(",
"site1",
",",
"site2",
",",
"tol",
"=",
"0.2",
",",
"bond_order",
"=",
"None",
",",
"default_bl",
"=",
"None",
")",
":",
"sp1",
"=",
"list",
"(",
"site1",
".",
"species",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"sp2",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | sendmail | Sends an e-mail with unix sendmail.
Args:
subject: String with the subject of the mail.
text: String with the body of the mail.
mailto: String or list of string with the recipients.
sender: string with the sender address.
If sender is None, username@hostname is used.
... | pymatgen/io/abinit/launcher.py | def sendmail(subject, text, mailto, sender=None):
"""
Sends an e-mail with unix sendmail.
Args:
subject: String with the subject of the mail.
text: String with the body of the mail.
mailto: String or list of string with the recipients.
sender: string with the sender address.... | def sendmail(subject, text, mailto, sender=None):
"""
Sends an e-mail with unix sendmail.
Args:
subject: String with the subject of the mail.
text: String with the body of the mail.
mailto: String or list of string with the recipients.
sender: string with the sender address.... | [
"Sends",
"an",
"e",
"-",
"mail",
"with",
"unix",
"sendmail",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L890-L938 | [
"def",
"sendmail",
"(",
"subject",
",",
"text",
",",
"mailto",
",",
"sender",
"=",
"None",
")",
":",
"def",
"user_at_host",
"(",
")",
":",
"from",
"socket",
"import",
"gethostname",
"return",
"os",
".",
"getlogin",
"(",
")",
"+",
"\"@\"",
"+",
"gethost... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ScriptEditor.declare_var | Declare a env variable. If val is None the variable is unset. | pymatgen/io/abinit/launcher.py | def declare_var(self, key, val):
"""Declare a env variable. If val is None the variable is unset."""
if val is not None:
line = "export " + key + '=' + str(val)
else:
line = "unset " + key
self._add(line) | def declare_var(self, key, val):
"""Declare a env variable. If val is None the variable is unset."""
if val is not None:
line = "export " + key + '=' + str(val)
else:
line = "unset " + key
self._add(line) | [
"Declare",
"a",
"env",
"variable",
".",
"If",
"val",
"is",
"None",
"the",
"variable",
"is",
"unset",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L74-L81 | [
"def",
"declare_var",
"(",
"self",
",",
"key",
",",
"val",
")",
":",
"if",
"val",
"is",
"not",
"None",
":",
"line",
"=",
"\"export \"",
"+",
"key",
"+",
"'='",
"+",
"str",
"(",
"val",
")",
"else",
":",
"line",
"=",
"\"unset \"",
"+",
"key",
"self... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ScriptEditor.declare_vars | Declare the variables defined in the dictionary d. | pymatgen/io/abinit/launcher.py | def declare_vars(self, d):
"""Declare the variables defined in the dictionary d."""
for k, v in d.items():
self.declare_var(k, v) | def declare_vars(self, d):
"""Declare the variables defined in the dictionary d."""
for k, v in d.items():
self.declare_var(k, v) | [
"Declare",
"the",
"variables",
"defined",
"in",
"the",
"dictionary",
"d",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L83-L86 | [
"def",
"declare_vars",
"(",
"self",
",",
"d",
")",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"self",
".",
"declare_var",
"(",
"k",
",",
"v",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ScriptEditor.export_envar | Export an environment variable. | pymatgen/io/abinit/launcher.py | def export_envar(self, key, val):
"""Export an environment variable."""
line = "export " + key + "=" + str(val)
self._add(line) | def export_envar(self, key, val):
"""Export an environment variable."""
line = "export " + key + "=" + str(val)
self._add(line) | [
"Export",
"an",
"environment",
"variable",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L88-L91 | [
"def",
"export_envar",
"(",
"self",
",",
"key",
",",
"val",
")",
":",
"line",
"=",
"\"export \"",
"+",
"key",
"+",
"\"=\"",
"+",
"str",
"(",
"val",
")",
"self",
".",
"_add",
"(",
"line",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ScriptEditor.export_envars | Export the environment variables contained in the dict env. | pymatgen/io/abinit/launcher.py | def export_envars(self, env):
"""Export the environment variables contained in the dict env."""
for k, v in env.items():
self.export_envar(k, v) | def export_envars(self, env):
"""Export the environment variables contained in the dict env."""
for k, v in env.items():
self.export_envar(k, v) | [
"Export",
"the",
"environment",
"variables",
"contained",
"in",
"the",
"dict",
"env",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L93-L96 | [
"def",
"export_envars",
"(",
"self",
",",
"env",
")",
":",
"for",
"k",
",",
"v",
"in",
"env",
".",
"items",
"(",
")",
":",
"self",
".",
"export_envar",
"(",
"k",
",",
"v",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ScriptEditor.get_script_str | Returns a string with the script and reset the editor if reset is True | pymatgen/io/abinit/launcher.py | def get_script_str(self, reset=True):
"""Returns a string with the script and reset the editor if reset is True"""
s = "\n".join(l for l in self._lines)
if reset:
self.reset()
return s | def get_script_str(self, reset=True):
"""Returns a string with the script and reset the editor if reset is True"""
s = "\n".join(l for l in self._lines)
if reset:
self.reset()
return s | [
"Returns",
"a",
"string",
"with",
"the",
"script",
"and",
"reset",
"the",
"editor",
"if",
"reset",
"is",
"True"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L120-L125 | [
"def",
"get_script_str",
"(",
"self",
",",
"reset",
"=",
"True",
")",
":",
"s",
"=",
"\"\\n\"",
".",
"join",
"(",
"l",
"for",
"l",
"in",
"self",
".",
"_lines",
")",
"if",
"reset",
":",
"self",
".",
"reset",
"(",
")",
"return",
"s"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyLauncher.single_shot | Run the first :class:`Task` than is ready for execution.
Returns:
Number of jobs launched. | pymatgen/io/abinit/launcher.py | def single_shot(self):
"""
Run the first :class:`Task` than is ready for execution.
Returns:
Number of jobs launched.
"""
num_launched = 0
# Get the tasks that can be executed in each workflow.
tasks = []
for work in self.flow:
tr... | def single_shot(self):
"""
Run the first :class:`Task` than is ready for execution.
Returns:
Number of jobs launched.
"""
num_launched = 0
# Get the tasks that can be executed in each workflow.
tasks = []
for work in self.flow:
tr... | [
"Run",
"the",
"first",
":",
"class",
":",
"Task",
"than",
"is",
"ready",
"for",
"execution",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L150-L182 | [
"def",
"single_shot",
"(",
"self",
")",
":",
"num_launched",
"=",
"0",
"# Get the tasks that can be executed in each workflow.",
"tasks",
"=",
"[",
"]",
"for",
"work",
"in",
"self",
".",
"flow",
":",
"try",
":",
"task",
"=",
"work",
".",
"fetch_task_to_run",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyLauncher.rapidfire | Keeps submitting `Tasks` until we are out of jobs or no job is ready to run.
Args:
max_nlaunch: Maximum number of launches. default: no limit.
max_loops: Maximum number of loops
sleep_time: seconds to sleep between rapidfire loop iterations
Returns:
The ... | pymatgen/io/abinit/launcher.py | def rapidfire(self, max_nlaunch=-1, max_loops=1, sleep_time=5):
"""
Keeps submitting `Tasks` until we are out of jobs or no job is ready to run.
Args:
max_nlaunch: Maximum number of launches. default: no limit.
max_loops: Maximum number of loops
sleep_time: s... | def rapidfire(self, max_nlaunch=-1, max_loops=1, sleep_time=5):
"""
Keeps submitting `Tasks` until we are out of jobs or no job is ready to run.
Args:
max_nlaunch: Maximum number of launches. default: no limit.
max_loops: Maximum number of loops
sleep_time: s... | [
"Keeps",
"submitting",
"Tasks",
"until",
"we",
"are",
"out",
"of",
"jobs",
"or",
"no",
"job",
"is",
"ready",
"to",
"run",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L184-L230 | [
"def",
"rapidfire",
"(",
"self",
",",
"max_nlaunch",
"=",
"-",
"1",
",",
"max_loops",
"=",
"1",
",",
"sleep_time",
"=",
"5",
")",
":",
"num_launched",
",",
"do_exit",
",",
"launched",
"=",
"0",
",",
"False",
",",
"[",
"]",
"for",
"count",
"in",
"ra... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyLauncher.fetch_tasks_to_run | Return the list of tasks that can be submitted.
Empty list if no task has been found. | pymatgen/io/abinit/launcher.py | def fetch_tasks_to_run(self):
"""
Return the list of tasks that can be submitted.
Empty list if no task has been found.
"""
tasks_to_run = []
for work in self.flow:
tasks_to_run.extend(work.fetch_alltasks_to_run())
return tasks_to_run | def fetch_tasks_to_run(self):
"""
Return the list of tasks that can be submitted.
Empty list if no task has been found.
"""
tasks_to_run = []
for work in self.flow:
tasks_to_run.extend(work.fetch_alltasks_to_run())
return tasks_to_run | [
"Return",
"the",
"list",
"of",
"tasks",
"that",
"can",
"be",
"submitted",
".",
"Empty",
"list",
"if",
"no",
"task",
"has",
"been",
"found",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L232-L242 | [
"def",
"fetch_tasks_to_run",
"(",
"self",
")",
":",
"tasks_to_run",
"=",
"[",
"]",
"for",
"work",
"in",
"self",
".",
"flow",
":",
"tasks_to_run",
".",
"extend",
"(",
"work",
".",
"fetch_alltasks_to_run",
"(",
")",
")",
"return",
"tasks_to_run"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.from_file | Read the configuration parameters from a Yaml file. | pymatgen/io/abinit/launcher.py | def from_file(cls, filepath):
"""Read the configuration parameters from a Yaml file."""
with open(filepath, "rt") as fh:
return cls(**yaml.safe_load(fh)) | def from_file(cls, filepath):
"""Read the configuration parameters from a Yaml file."""
with open(filepath, "rt") as fh:
return cls(**yaml.safe_load(fh)) | [
"Read",
"the",
"configuration",
"parameters",
"from",
"a",
"Yaml",
"file",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L375-L378 | [
"def",
"from_file",
"(",
"cls",
",",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"\"rt\"",
")",
"as",
"fh",
":",
"return",
"cls",
"(",
"*",
"*",
"yaml",
".",
"safe_load",
"(",
"fh",
")",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.from_string | Create an istance from string s containing a YAML dictionary. | pymatgen/io/abinit/launcher.py | def from_string(cls, s):
"""Create an istance from string s containing a YAML dictionary."""
stream = cStringIO(s)
stream.seek(0)
return cls(**yaml.safe_load(stream)) | def from_string(cls, s):
"""Create an istance from string s containing a YAML dictionary."""
stream = cStringIO(s)
stream.seek(0)
return cls(**yaml.safe_load(stream)) | [
"Create",
"an",
"istance",
"from",
"string",
"s",
"containing",
"a",
"YAML",
"dictionary",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L381-L385 | [
"def",
"from_string",
"(",
"cls",
",",
"s",
")",
":",
"stream",
"=",
"cStringIO",
"(",
"s",
")",
"stream",
".",
"seek",
"(",
"0",
")",
"return",
"cls",
"(",
"*",
"*",
"yaml",
".",
"safe_load",
"(",
"stream",
")",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.from_user_config | Initialize the :class:`PyFlowScheduler` from the YAML file 'scheduler.yml'.
Search first in the working directory and then in the configuration directory of abipy.
Raises:
`RuntimeError` if file is not found. | pymatgen/io/abinit/launcher.py | def from_user_config(cls):
"""
Initialize the :class:`PyFlowScheduler` from the YAML file 'scheduler.yml'.
Search first in the working directory and then in the configuration directory of abipy.
Raises:
`RuntimeError` if file is not found.
"""
# Try in the cu... | def from_user_config(cls):
"""
Initialize the :class:`PyFlowScheduler` from the YAML file 'scheduler.yml'.
Search first in the working directory and then in the configuration directory of abipy.
Raises:
`RuntimeError` if file is not found.
"""
# Try in the cu... | [
"Initialize",
"the",
":",
"class",
":",
"PyFlowScheduler",
"from",
"the",
"YAML",
"file",
"scheduler",
".",
"yml",
".",
"Search",
"first",
"in",
"the",
"working",
"directory",
"and",
"then",
"in",
"the",
"configuration",
"directory",
"of",
"abipy",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L388-L408 | [
"def",
"from_user_config",
"(",
"cls",
")",
":",
"# Try in the current directory.",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"cls",
".",
"YAML_FILE",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.pid | The pid of the process associated to the scheduler. | pymatgen/io/abinit/launcher.py | def pid(self):
"""The pid of the process associated to the scheduler."""
try:
return self._pid
except AttributeError:
self._pid = os.getpid()
return self._pid | def pid(self):
"""The pid of the process associated to the scheduler."""
try:
return self._pid
except AttributeError:
self._pid = os.getpid()
return self._pid | [
"The",
"pid",
"of",
"the",
"process",
"associated",
"to",
"the",
"scheduler",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L423-L429 | [
"def",
"pid",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_pid",
"except",
"AttributeError",
":",
"self",
".",
"_pid",
"=",
"os",
".",
"getpid",
"(",
")",
"return",
"self",
".",
"_pid"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.add_flow | Add an :class:`Flow` flow to the scheduler. | pymatgen/io/abinit/launcher.py | def add_flow(self, flow):
"""
Add an :class:`Flow` flow to the scheduler.
"""
if hasattr(self, "_flow"):
raise self.Error("Only one flow can be added to the scheduler.")
# Check if we are already using a scheduler to run this flow
flow.check_pid_file()
... | def add_flow(self, flow):
"""
Add an :class:`Flow` flow to the scheduler.
"""
if hasattr(self, "_flow"):
raise self.Error("Only one flow can be added to the scheduler.")
# Check if we are already using a scheduler to run this flow
flow.check_pid_file()
... | [
"Add",
"an",
":",
"class",
":",
"Flow",
"flow",
"to",
"the",
"scheduler",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L456-L474 | [
"def",
"add_flow",
"(",
"self",
",",
"flow",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_flow\"",
")",
":",
"raise",
"self",
".",
"Error",
"(",
"\"Only one flow can be added to the scheduler.\"",
")",
"# Check if we are already using a scheduler to run this flow",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler._validate_customer_service | Validate input parameters if customer service is on then
create directory for tarball files with correct premissions for user and group. | pymatgen/io/abinit/launcher.py | def _validate_customer_service(self):
"""
Validate input parameters if customer service is on then
create directory for tarball files with correct premissions for user and group.
"""
direc = self.customer_service_dir
if not direc.exists:
mode = 0o750
... | def _validate_customer_service(self):
"""
Validate input parameters if customer service is on then
create directory for tarball files with correct premissions for user and group.
"""
direc = self.customer_service_dir
if not direc.exists:
mode = 0o750
... | [
"Validate",
"input",
"parameters",
"if",
"customer",
"service",
"is",
"on",
"then",
"create",
"directory",
"for",
"tarball",
"files",
"with",
"correct",
"premissions",
"for",
"user",
"and",
"group",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L476-L489 | [
"def",
"_validate_customer_service",
"(",
"self",
")",
":",
"direc",
"=",
"self",
".",
"customer_service_dir",
"if",
"not",
"direc",
".",
"exists",
":",
"mode",
"=",
"0o750",
"print",
"(",
"\"Creating customer_service_dir %s with mode %s\"",
"%",
"(",
"direc",
","... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler._do_customer_service | This method is called before the shutdown of the scheduler.
If customer_service is on and the flow didn't completed successfully,
a lightweight tarball file with inputs and the most important output files
is created in customer_servide_dir. | pymatgen/io/abinit/launcher.py | def _do_customer_service(self):
"""
This method is called before the shutdown of the scheduler.
If customer_service is on and the flow didn't completed successfully,
a lightweight tarball file with inputs and the most important output files
is created in customer_servide_dir.
... | def _do_customer_service(self):
"""
This method is called before the shutdown of the scheduler.
If customer_service is on and the flow didn't completed successfully,
a lightweight tarball file with inputs and the most important output files
is created in customer_servide_dir.
... | [
"This",
"method",
"is",
"called",
"before",
"the",
"shutdown",
"of",
"the",
"scheduler",
".",
"If",
"customer_service",
"is",
"on",
"and",
"the",
"flow",
"didn",
"t",
"completed",
"successfully",
"a",
"lightweight",
"tarball",
"file",
"with",
"inputs",
"and",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L491-L519 | [
"def",
"_do_customer_service",
"(",
"self",
")",
":",
"if",
"self",
".",
"customer_service_dir",
"is",
"None",
":",
"return",
"doit",
"=",
"self",
".",
"exceptions",
"or",
"not",
"self",
".",
"flow",
".",
"all_ok",
"doit",
"=",
"True",
"if",
"not",
"doit... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.start | Starts the scheduler in a new thread. Returns 0 if success.
In standalone mode, this method will block until there are no more scheduled jobs. | pymatgen/io/abinit/launcher.py | def start(self):
"""
Starts the scheduler in a new thread. Returns 0 if success.
In standalone mode, this method will block until there are no more scheduled jobs.
"""
self.history.append("Started on %s" % time.asctime())
self.start_time = time.time()
if not has_... | def start(self):
"""
Starts the scheduler in a new thread. Returns 0 if success.
In standalone mode, this method will block until there are no more scheduled jobs.
"""
self.history.append("Started on %s" % time.asctime())
self.start_time = time.time()
if not has_... | [
"Starts",
"the",
"scheduler",
"in",
"a",
"new",
"thread",
".",
"Returns",
"0",
"if",
"success",
".",
"In",
"standalone",
"mode",
"this",
"method",
"will",
"block",
"until",
"there",
"are",
"no",
"more",
"scheduled",
"jobs",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L522-L561 | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"history",
".",
"append",
"(",
"\"Started on %s\"",
"%",
"time",
".",
"asctime",
"(",
")",
")",
"self",
".",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"not",
"has_apscheduler",
":",
"r... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler._runem_all | This function checks the status of all tasks,
tries to fix tasks that went unconverged, abicritical, or queuecritical
and tries to run all the tasks that can be submitted.+ | pymatgen/io/abinit/launcher.py | def _runem_all(self):
"""
This function checks the status of all tasks,
tries to fix tasks that went unconverged, abicritical, or queuecritical
and tries to run all the tasks that can be submitted.+
"""
excs = []
flow = self.flow
# Allow to change the man... | def _runem_all(self):
"""
This function checks the status of all tasks,
tries to fix tasks that went unconverged, abicritical, or queuecritical
and tries to run all the tasks that can be submitted.+
"""
excs = []
flow = self.flow
# Allow to change the man... | [
"This",
"function",
"checks",
"the",
"status",
"of",
"all",
"tasks",
"tries",
"to",
"fix",
"tasks",
"that",
"went",
"unconverged",
"abicritical",
"or",
"queuecritical",
"and",
"tries",
"to",
"run",
"all",
"the",
"tasks",
"that",
"can",
"be",
"submitted",
"."... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L563-L661 | [
"def",
"_runem_all",
"(",
"self",
")",
":",
"excs",
"=",
"[",
"]",
"flow",
"=",
"self",
".",
"flow",
"# Allow to change the manager at run-time",
"if",
"self",
".",
"use_dynamic_manager",
":",
"from",
"pymatgen",
".",
"io",
".",
"abinit",
".",
"tasks",
"impo... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.callback | The function that will be executed by the scheduler. | pymatgen/io/abinit/launcher.py | def callback(self):
"""The function that will be executed by the scheduler."""
try:
return self._callback()
except:
# All exceptions raised here will trigger the shutdown!
s = straceback()
self.exceptions.append(s)
# This is useful whe... | def callback(self):
"""The function that will be executed by the scheduler."""
try:
return self._callback()
except:
# All exceptions raised here will trigger the shutdown!
s = straceback()
self.exceptions.append(s)
# This is useful whe... | [
"The",
"function",
"that",
"will",
"be",
"executed",
"by",
"the",
"scheduler",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L663-L680 | [
"def",
"callback",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_callback",
"(",
")",
"except",
":",
"# All exceptions raised here will trigger the shutdown!",
"s",
"=",
"straceback",
"(",
")",
"self",
".",
"exceptions",
".",
"append",
"(",
"s",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler._callback | The actual callback. | pymatgen/io/abinit/launcher.py | def _callback(self):
"""The actual callback."""
if self.debug:
# Show the number of open file descriptors
print(">>>>> _callback: Number of open file descriptors: %s" % get_open_fds())
self._runem_all()
# Mission accomplished. Shutdown the scheduler.
all... | def _callback(self):
"""The actual callback."""
if self.debug:
# Show the number of open file descriptors
print(">>>>> _callback: Number of open file descriptors: %s" % get_open_fds())
self._runem_all()
# Mission accomplished. Shutdown the scheduler.
all... | [
"The",
"actual",
"callback",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L682-L771 | [
"def",
"_callback",
"(",
"self",
")",
":",
"if",
"self",
".",
"debug",
":",
"# Show the number of open file descriptors",
"print",
"(",
"\">>>>> _callback: Number of open file descriptors: %s\"",
"%",
"get_open_fds",
"(",
")",
")",
"self",
".",
"_runem_all",
"(",
")",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.cleanup | Cleanup routine: remove the pid file and save the pickle database | pymatgen/io/abinit/launcher.py | def cleanup(self):
"""Cleanup routine: remove the pid file and save the pickle database"""
try:
os.remove(self.pid_file)
except OSError as exc:
logger.critical("Could not remove pid_file: %s", exc)
# Save the final status of the flow.
self.flow.pickle_dum... | def cleanup(self):
"""Cleanup routine: remove the pid file and save the pickle database"""
try:
os.remove(self.pid_file)
except OSError as exc:
logger.critical("Could not remove pid_file: %s", exc)
# Save the final status of the flow.
self.flow.pickle_dum... | [
"Cleanup",
"routine",
":",
"remove",
"the",
"pid",
"file",
"and",
"save",
"the",
"pickle",
"database"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L773-L781 | [
"def",
"cleanup",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"pid_file",
")",
"except",
"OSError",
"as",
"exc",
":",
"logger",
".",
"critical",
"(",
"\"Could not remove pid_file: %s\"",
",",
"exc",
")",
"# Save the final status... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.shutdown | Shutdown the scheduler. | pymatgen/io/abinit/launcher.py | def shutdown(self, msg):
"""Shutdown the scheduler."""
try:
self.cleanup()
self.history.append("Completed on: %s" % time.asctime())
self.history.append("Elapsed time: %s" % self.get_delta_etime())
if self.debug:
print(">>>>> shutdown: Num... | def shutdown(self, msg):
"""Shutdown the scheduler."""
try:
self.cleanup()
self.history.append("Completed on: %s" % time.asctime())
self.history.append("Elapsed time: %s" % self.get_delta_etime())
if self.debug:
print(">>>>> shutdown: Num... | [
"Shutdown",
"the",
"scheduler",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L783-L846 | [
"def",
"shutdown",
"(",
"self",
",",
"msg",
")",
":",
"try",
":",
"self",
".",
"cleanup",
"(",
")",
"self",
".",
"history",
".",
"append",
"(",
"\"Completed on: %s\"",
"%",
"time",
".",
"asctime",
"(",
")",
")",
"self",
".",
"history",
".",
"append",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PyFlowScheduler.send_email | Send an e-mail before completing the shutdown.
Returns 0 if success. | pymatgen/io/abinit/launcher.py | def send_email(self, msg, tag=None):
"""
Send an e-mail before completing the shutdown.
Returns 0 if success.
"""
try:
return self._send_email(msg, tag)
except:
self.exceptions.append(straceback())
return -2 | def send_email(self, msg, tag=None):
"""
Send an e-mail before completing the shutdown.
Returns 0 if success.
"""
try:
return self._send_email(msg, tag)
except:
self.exceptions.append(straceback())
return -2 | [
"Send",
"an",
"e",
"-",
"mail",
"before",
"completing",
"the",
"shutdown",
".",
"Returns",
"0",
"if",
"success",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L850-L859 | [
"def",
"send_email",
"(",
"self",
",",
"msg",
",",
"tag",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"_send_email",
"(",
"msg",
",",
"tag",
")",
"except",
":",
"self",
".",
"exceptions",
".",
"append",
"(",
"straceback",
"(",
")",
")... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatchLauncher.from_dir | Find all flows located withing the directory `top` and build the `BatchLauncher`.
Args:
top: Top level directory or list of directories.
workdir: Batch workdir.
name:
manager: :class:`TaskManager` object. If None, the manager is read from `manager.yml`
... | pymatgen/io/abinit/launcher.py | def from_dir(cls, top, workdir=None, name=None, manager=None, max_depth=2):
"""
Find all flows located withing the directory `top` and build the `BatchLauncher`.
Args:
top: Top level directory or list of directories.
workdir: Batch workdir.
name:
... | def from_dir(cls, top, workdir=None, name=None, manager=None, max_depth=2):
"""
Find all flows located withing the directory `top` and build the `BatchLauncher`.
Args:
top: Top level directory or list of directories.
workdir: Batch workdir.
name:
... | [
"Find",
"all",
"flows",
"located",
"withing",
"the",
"directory",
"top",
"and",
"build",
"the",
"BatchLauncher",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L966-L1003 | [
"def",
"from_dir",
"(",
"cls",
",",
"top",
",",
"workdir",
"=",
"None",
",",
"name",
"=",
"None",
",",
"manager",
"=",
"None",
",",
"max_depth",
"=",
"2",
")",
":",
"from",
".",
"flows",
"import",
"Flow",
"def",
"find_pickles",
"(",
"dirtop",
")",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatchLauncher.pickle_load | Loads the object from a pickle file.
Args:
filepath: Filename or directory name. It filepath is a directory, we
scan the directory tree starting from filepath and we
read the first pickle database. Raise RuntimeError if multiple
databases are found. | pymatgen/io/abinit/launcher.py | def pickle_load(cls, filepath):
"""
Loads the object from a pickle file.
Args:
filepath: Filename or directory name. It filepath is a directory, we
scan the directory tree starting from filepath and we
read the first pickle database. Raise RuntimeErro... | def pickle_load(cls, filepath):
"""
Loads the object from a pickle file.
Args:
filepath: Filename or directory name. It filepath is a directory, we
scan the directory tree starting from filepath and we
read the first pickle database. Raise RuntimeErro... | [
"Loads",
"the",
"object",
"from",
"a",
"pickle",
"file",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L1006-L1042 | [
"def",
"pickle_load",
"(",
"cls",
",",
"filepath",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"filepath",
")",
":",
"# Walk through each directory inside path and find the pickle database.",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatchLauncher.pickle_dump | Save the status of the object in pickle format. | pymatgen/io/abinit/launcher.py | def pickle_dump(self):
"""Save the status of the object in pickle format."""
with open(os.path.join(self.workdir, self.PICKLE_FNAME), mode="wb") as fh:
pickle.dump(self, fh) | def pickle_dump(self):
"""Save the status of the object in pickle format."""
with open(os.path.join(self.workdir, self.PICKLE_FNAME), mode="wb") as fh:
pickle.dump(self, fh) | [
"Save",
"the",
"status",
"of",
"the",
"object",
"in",
"pickle",
"format",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L1044-L1047 | [
"def",
"pickle_dump",
"(",
"self",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"workdir",
",",
"self",
".",
"PICKLE_FNAME",
")",
",",
"mode",
"=",
"\"wb\"",
")",
"as",
"fh",
":",
"pickle",
".",
"dump",
"(",
"s... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatchLauncher.add_flow | Add a flow. Accept filepath or :class:`Flow` object. Return 1 if flow was added else 0. | pymatgen/io/abinit/launcher.py | def add_flow(self, flow):
"""
Add a flow. Accept filepath or :class:`Flow` object. Return 1 if flow was added else 0.
"""
from .flows import Flow
flow = Flow.as_flow(flow)
if flow in self.flows:
raise self.Error("Cannot add same flow twice!")
if not ... | def add_flow(self, flow):
"""
Add a flow. Accept filepath or :class:`Flow` object. Return 1 if flow was added else 0.
"""
from .flows import Flow
flow = Flow.as_flow(flow)
if flow in self.flows:
raise self.Error("Cannot add same flow twice!")
if not ... | [
"Add",
"a",
"flow",
".",
"Accept",
"filepath",
"or",
":",
"class",
":",
"Flow",
"object",
".",
"Return",
"1",
"if",
"flow",
"was",
"added",
"else",
"0",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L1135-L1165 | [
"def",
"add_flow",
"(",
"self",
",",
"flow",
")",
":",
"from",
".",
"flows",
"import",
"Flow",
"flow",
"=",
"Flow",
".",
"as_flow",
"(",
"flow",
")",
"if",
"flow",
"in",
"self",
".",
"flows",
":",
"raise",
"self",
".",
"Error",
"(",
"\"Cannot add sam... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatchLauncher.submit | Submit a job script that will run the schedulers with `abirun.py`.
Args:
verbose: Verbosity level
dry_run: Don't submit the script if dry_run. Default: False
Returns:
namedtuple with attributes:
retcode: Return code as returned by the submission scri... | pymatgen/io/abinit/launcher.py | def submit(self, **kwargs):
"""
Submit a job script that will run the schedulers with `abirun.py`.
Args:
verbose: Verbosity level
dry_run: Don't submit the script if dry_run. Default: False
Returns:
namedtuple with attributes:
retcode... | def submit(self, **kwargs):
"""
Submit a job script that will run the schedulers with `abirun.py`.
Args:
verbose: Verbosity level
dry_run: Don't submit the script if dry_run. Default: False
Returns:
namedtuple with attributes:
retcode... | [
"Submit",
"a",
"job",
"script",
"that",
"will",
"run",
"the",
"schedulers",
"with",
"abirun",
".",
"py",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L1167-L1252 | [
"def",
"submit",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"verbose",
",",
"dry_run",
"=",
"kwargs",
".",
"pop",
"(",
"\"verbose\"",
",",
"0",
")",
",",
"kwargs",
".",
"pop",
"(",
"\"dry_run\"",
",",
"False",
")",
"if",
"not",
"self",
".",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | BatchLauncher._get_script_nflows | Write the submission script. Return (script, num_flows_in_batch) | pymatgen/io/abinit/launcher.py | def _get_script_nflows(self):
"""
Write the submission script. Return (script, num_flows_in_batch)
"""
flows_torun = [f for f in self.flows if not f.all_ok]
if not flows_torun:
return "", 0
executable = [
'export _LOG=%s' % self.log_file.path,
... | def _get_script_nflows(self):
"""
Write the submission script. Return (script, num_flows_in_batch)
"""
flows_torun = [f for f in self.flows if not f.all_ok]
if not flows_torun:
return "", 0
executable = [
'export _LOG=%s' % self.log_file.path,
... | [
"Write",
"the",
"submission",
"script",
".",
"Return",
"(",
"script",
"num_flows_in_batch",
")"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/launcher.py#L1254-L1301 | [
"def",
"_get_script_nflows",
"(",
"self",
")",
":",
"flows_torun",
"=",
"[",
"f",
"for",
"f",
"in",
"self",
".",
"flows",
"if",
"not",
"f",
".",
"all_ok",
"]",
"if",
"not",
"flows_torun",
":",
"return",
"\"\"",
",",
"0",
"executable",
"=",
"[",
"'exp... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | LMTOCtrl.get_string | Generates the string representation of the CTRL file. This is
the mininmal CTRL file necessary to execute lmhart.run. | pymatgen/io/lmto.py | def get_string(self, sigfigs=8):
"""
Generates the string representation of the CTRL file. This is
the mininmal CTRL file necessary to execute lmhart.run.
"""
ctrl_dict = self.as_dict()
lines = [] if "HEADER" not in ctrl_dict else \
["HEADER".ljust(10) + self.... | def get_string(self, sigfigs=8):
"""
Generates the string representation of the CTRL file. This is
the mininmal CTRL file necessary to execute lmhart.run.
"""
ctrl_dict = self.as_dict()
lines = [] if "HEADER" not in ctrl_dict else \
["HEADER".ljust(10) + self.... | [
"Generates",
"the",
"string",
"representation",
"of",
"the",
"CTRL",
"file",
".",
"This",
"is",
"the",
"mininmal",
"CTRL",
"file",
"necessary",
"to",
"execute",
"lmhart",
".",
"run",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lmto.py#L64-L101 | [
"def",
"get_string",
"(",
"self",
",",
"sigfigs",
"=",
"8",
")",
":",
"ctrl_dict",
"=",
"self",
".",
"as_dict",
"(",
")",
"lines",
"=",
"[",
"]",
"if",
"\"HEADER\"",
"not",
"in",
"ctrl_dict",
"else",
"[",
"\"HEADER\"",
".",
"ljust",
"(",
"10",
")",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | LMTOCtrl.as_dict | Returns the CTRL as a dictionary. "SITE" and "CLASS" are of
the form {'CATEGORY': {'TOKEN': value}}, the rest is of the
form 'TOKEN'/'CATEGORY': value. It gets the conventional standard
structure because primitive cells use the conventional
a-lattice parameter as the scaling factor and n... | pymatgen/io/lmto.py | def as_dict(self):
"""
Returns the CTRL as a dictionary. "SITE" and "CLASS" are of
the form {'CATEGORY': {'TOKEN': value}}, the rest is of the
form 'TOKEN'/'CATEGORY': value. It gets the conventional standard
structure because primitive cells use the conventional
a-lattic... | def as_dict(self):
"""
Returns the CTRL as a dictionary. "SITE" and "CLASS" are of
the form {'CATEGORY': {'TOKEN': value}}, the rest is of the
form 'TOKEN'/'CATEGORY': value. It gets the conventional standard
structure because primitive cells use the conventional
a-lattic... | [
"Returns",
"the",
"CTRL",
"as",
"a",
"dictionary",
".",
"SITE",
"and",
"CLASS",
"are",
"of",
"the",
"form",
"{",
"CATEGORY",
":",
"{",
"TOKEN",
":",
"value",
"}}",
"the",
"rest",
"is",
"of",
"the",
"form",
"TOKEN",
"/",
"CATEGORY",
":",
"value",
".",... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lmto.py#L103-L152 | [
"def",
"as_dict",
"(",
"self",
")",
":",
"ctrl_dict",
"=",
"{",
"\"@module\"",
":",
"self",
".",
"__class__",
".",
"__module__",
",",
"\"@class\"",
":",
"self",
".",
"__class__",
".",
"__name__",
"}",
"if",
"self",
".",
"header",
"is",
"not",
"None",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | LMTOCtrl.from_file | Creates a CTRL file object from an existing file.
Args:
filename: The name of the CTRL file. Defaults to 'CTRL'.
Returns:
An LMTOCtrl object. | pymatgen/io/lmto.py | def from_file(cls, filename="CTRL", **kwargs):
"""
Creates a CTRL file object from an existing file.
Args:
filename: The name of the CTRL file. Defaults to 'CTRL'.
Returns:
An LMTOCtrl object.
"""
with zopen(filename, "rt") as f:
cont... | def from_file(cls, filename="CTRL", **kwargs):
"""
Creates a CTRL file object from an existing file.
Args:
filename: The name of the CTRL file. Defaults to 'CTRL'.
Returns:
An LMTOCtrl object.
"""
with zopen(filename, "rt") as f:
cont... | [
"Creates",
"a",
"CTRL",
"file",
"object",
"from",
"an",
"existing",
"file",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lmto.py#L163-L175 | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
"=",
"\"CTRL\"",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"zopen",
"(",
"filename",
",",
"\"rt\"",
")",
"as",
"f",
":",
"contents",
"=",
"f",
".",
"read",
"(",
")",
"return",
"LMTOCtrl",
".",
"from... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | LMTOCtrl.from_string | Creates a CTRL file object from a string. This will mostly be
used to read an LMTOCtrl object from a CTRL file. Empty spheres
are ignored.
Args:
data: String representation of the CTRL file.
Returns:
An LMTOCtrl object. | pymatgen/io/lmto.py | def from_string(cls, data, sigfigs=8):
"""
Creates a CTRL file object from a string. This will mostly be
used to read an LMTOCtrl object from a CTRL file. Empty spheres
are ignored.
Args:
data: String representation of the CTRL file.
Returns:
An ... | def from_string(cls, data, sigfigs=8):
"""
Creates a CTRL file object from a string. This will mostly be
used to read an LMTOCtrl object from a CTRL file. Empty spheres
are ignored.
Args:
data: String representation of the CTRL file.
Returns:
An ... | [
"Creates",
"a",
"CTRL",
"file",
"object",
"from",
"a",
"string",
".",
"This",
"will",
"mostly",
"be",
"used",
"to",
"read",
"an",
"LMTOCtrl",
"object",
"from",
"a",
"CTRL",
"file",
".",
"Empty",
"spheres",
"are",
"ignored",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lmto.py#L178-L253 | [
"def",
"from_string",
"(",
"cls",
",",
"data",
",",
"sigfigs",
"=",
"8",
")",
":",
"lines",
"=",
"data",
".",
"split",
"(",
"\"\\n\"",
")",
"[",
":",
"-",
"1",
"]",
"struc_lines",
"=",
"{",
"\"HEADER\"",
":",
"[",
"]",
",",
"\"VERS\"",
":",
"[",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | LMTOCtrl.from_dict | Creates a CTRL file object from a dictionary. The dictionary
must contain the items "ALAT", PLAT" and "SITE".
Valid dictionary items are:
ALAT: the a-lattice parameter
PLAT: (3x3) array for the lattice vectors
SITE: list of dictionaries: {'ATOM': class label,
... | pymatgen/io/lmto.py | def from_dict(cls, d):
"""
Creates a CTRL file object from a dictionary. The dictionary
must contain the items "ALAT", PLAT" and "SITE".
Valid dictionary items are:
ALAT: the a-lattice parameter
PLAT: (3x3) array for the lattice vectors
SITE: list of ... | def from_dict(cls, d):
"""
Creates a CTRL file object from a dictionary. The dictionary
must contain the items "ALAT", PLAT" and "SITE".
Valid dictionary items are:
ALAT: the a-lattice parameter
PLAT: (3x3) array for the lattice vectors
SITE: list of ... | [
"Creates",
"a",
"CTRL",
"file",
"object",
"from",
"a",
"dictionary",
".",
"The",
"dictionary",
"must",
"contain",
"the",
"items",
"ALAT",
"PLAT",
"and",
"SITE",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lmto.py#L256-L307 | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"for",
"cat",
"in",
"[",
"\"HEADER\"",
",",
"\"VERS\"",
"]",
":",
"if",
"cat",
"not",
"in",
"d",
":",
"d",
"[",
"cat",
"]",
"=",
"None",
"alat",
"=",
"d",
"[",
"\"ALAT\"",
"]",
"*",
"bohr_to_a... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | LMTOCopl._get_bond_data | Subroutine to extract bond label, site indices, and length from
a COPL header line. The site indices are zero-based, so they
can be easily used with a Structure object.
Example header line: Fe-1/Fe-1-tr(-1,-1,-1) : 2.482 Ang.
Args:
line: line in the COHPCAR header describi... | pymatgen/io/lmto.py | def _get_bond_data(line):
"""
Subroutine to extract bond label, site indices, and length from
a COPL header line. The site indices are zero-based, so they
can be easily used with a Structure object.
Example header line: Fe-1/Fe-1-tr(-1,-1,-1) : 2.482 Ang.
Args:
... | def _get_bond_data(line):
"""
Subroutine to extract bond label, site indices, and length from
a COPL header line. The site indices are zero-based, so they
can be easily used with a Structure object.
Example header line: Fe-1/Fe-1-tr(-1,-1,-1) : 2.482 Ang.
Args:
... | [
"Subroutine",
"to",
"extract",
"bond",
"label",
"site",
"indices",
"and",
"length",
"from",
"a",
"COPL",
"header",
"line",
".",
"The",
"site",
"indices",
"are",
"zero",
"-",
"based",
"so",
"they",
"can",
"be",
"easily",
"used",
"with",
"a",
"Structure",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lmto.py#L398-L422 | [
"def",
"_get_bond_data",
"(",
"line",
")",
":",
"line",
"=",
"line",
".",
"split",
"(",
")",
"length",
"=",
"float",
"(",
"line",
"[",
"2",
"]",
")",
"# Replacing \"/\" with \"-\" makes splitting easier",
"sites",
"=",
"line",
"[",
"0",
"]",
".",
"replace"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | NEBPathfinder.interpolate | Finds a set of n_images from self.s1 to self.s2, where all sites except
for the ones given in relax_sites, the interpolation is linear (as in
pymatgen.core.structure.interpolate), and for the site indices given
in relax_sites, the path is relaxed by the elastic band method within
the sta... | pymatgen/analysis/path_finder.py | def interpolate(self):
"""
Finds a set of n_images from self.s1 to self.s2, where all sites except
for the ones given in relax_sites, the interpolation is linear (as in
pymatgen.core.structure.interpolate), and for the site indices given
in relax_sites, the path is relaxed by the... | def interpolate(self):
"""
Finds a set of n_images from self.s1 to self.s2, where all sites except
for the ones given in relax_sites, the interpolation is linear (as in
pymatgen.core.structure.interpolate), and for the site indices given
in relax_sites, the path is relaxed by the... | [
"Finds",
"a",
"set",
"of",
"n_images",
"from",
"self",
".",
"s1",
"to",
"self",
".",
"s2",
"where",
"all",
"sites",
"except",
"for",
"the",
"ones",
"given",
"in",
"relax_sites",
"the",
"interpolation",
"is",
"linear",
"(",
"as",
"in",
"pymatgen",
".",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L56-L83 | [
"def",
"interpolate",
"(",
"self",
")",
":",
"images",
"=",
"self",
".",
"__s1",
".",
"interpolate",
"(",
"self",
".",
"__s2",
",",
"nimages",
"=",
"self",
".",
"__n_images",
",",
"interpolate_lattices",
"=",
"False",
")",
"for",
"site_i",
"in",
"self",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | NEBPathfinder.plot_images | Generates a POSCAR with the calculated diffusion path with respect to the first endpoint.
:param outfile: Output file for the POSCAR | pymatgen/analysis/path_finder.py | def plot_images(self, outfile):
"""
Generates a POSCAR with the calculated diffusion path with respect to the first endpoint.
:param outfile: Output file for the POSCAR
"""
sum_struct = self.__images[0].sites
for image in self.__images:
for site_i in self.__re... | def plot_images(self, outfile):
"""
Generates a POSCAR with the calculated diffusion path with respect to the first endpoint.
:param outfile: Output file for the POSCAR
"""
sum_struct = self.__images[0].sites
for image in self.__images:
for site_i in self.__re... | [
"Generates",
"a",
"POSCAR",
"with",
"the",
"calculated",
"diffusion",
"path",
"with",
"respect",
"to",
"the",
"first",
"endpoint",
".",
":",
"param",
"outfile",
":",
"Output",
"file",
"for",
"the",
"POSCAR"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L93-L108 | [
"def",
"plot_images",
"(",
"self",
",",
"outfile",
")",
":",
"sum_struct",
"=",
"self",
".",
"__images",
"[",
"0",
"]",
".",
"sites",
"for",
"image",
"in",
"self",
".",
"__images",
":",
"for",
"site_i",
"in",
"self",
".",
"__relax_sites",
":",
"sum_str... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | NEBPathfinder.string_relax | Implements path relaxation via the elastic band method. In general, the
method is to define a path by a set of points (images) connected with
bands with some elasticity constant k. The images then relax along the
forces found in the potential field V, counterbalanced by the elastic
respo... | pymatgen/analysis/path_finder.py | def string_relax(start, end, V, n_images=25, dr=None, h=3.0, k=0.17,
min_iter=100, max_iter=10000, max_tol=5e-6):
"""
Implements path relaxation via the elastic band method. In general, the
method is to define a path by a set of points (images) connected with
bands w... | def string_relax(start, end, V, n_images=25, dr=None, h=3.0, k=0.17,
min_iter=100, max_iter=10000, max_tol=5e-6):
"""
Implements path relaxation via the elastic band method. In general, the
method is to define a path by a set of points (images) connected with
bands w... | [
"Implements",
"path",
"relaxation",
"via",
"the",
"elastic",
"band",
"method",
".",
"In",
"general",
"the",
"method",
"is",
"to",
"define",
"a",
"path",
"by",
"a",
"set",
"of",
"points",
"(",
"images",
")",
"connected",
"with",
"bands",
"with",
"some",
"... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L111-L237 | [
"def",
"string_relax",
"(",
"start",
",",
"end",
",",
"V",
",",
"n_images",
"=",
"25",
",",
"dr",
"=",
"None",
",",
"h",
"=",
"3.0",
",",
"k",
"=",
"0.17",
",",
"min_iter",
"=",
"100",
",",
"max_iter",
"=",
"10000",
",",
"max_tol",
"=",
"5e-6",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | NEBPathfinder.__f2d | Converts fractional coordinates to discrete coordinates with respect to
the grid size of v | pymatgen/analysis/path_finder.py | def __f2d(frac_coords, v):
"""
Converts fractional coordinates to discrete coordinates with respect to
the grid size of v
"""
# frac_coords = frac_coords % 1
return np.array([int(frac_coords[0] * v.shape[0]),
int(frac_coords[1] * v.shape[1]),
... | def __f2d(frac_coords, v):
"""
Converts fractional coordinates to discrete coordinates with respect to
the grid size of v
"""
# frac_coords = frac_coords % 1
return np.array([int(frac_coords[0] * v.shape[0]),
int(frac_coords[1] * v.shape[1]),
... | [
"Converts",
"fractional",
"coordinates",
"to",
"discrete",
"coordinates",
"with",
"respect",
"to",
"the",
"grid",
"size",
"of",
"v"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L240-L248 | [
"def",
"__f2d",
"(",
"frac_coords",
",",
"v",
")",
":",
"# frac_coords = frac_coords % 1",
"return",
"np",
".",
"array",
"(",
"[",
"int",
"(",
"frac_coords",
"[",
"0",
"]",
"*",
"v",
".",
"shape",
"[",
"0",
"]",
")",
",",
"int",
"(",
"frac_coords",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | NEBPathfinder.__d2f | Converts a point given in discrete coordinates withe respect to the
grid in v to fractional coordinates. | pymatgen/analysis/path_finder.py | def __d2f(disc_coords, v):
"""
Converts a point given in discrete coordinates withe respect to the
grid in v to fractional coordinates.
"""
return np.array([disc_coords[0] / v.shape[0],
disc_coords[1] / v.shape[1],
disc_coords[2] ... | def __d2f(disc_coords, v):
"""
Converts a point given in discrete coordinates withe respect to the
grid in v to fractional coordinates.
"""
return np.array([disc_coords[0] / v.shape[0],
disc_coords[1] / v.shape[1],
disc_coords[2] ... | [
"Converts",
"a",
"point",
"given",
"in",
"discrete",
"coordinates",
"withe",
"respect",
"to",
"the",
"grid",
"in",
"v",
"to",
"fractional",
"coordinates",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L251-L258 | [
"def",
"__d2f",
"(",
"disc_coords",
",",
"v",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"disc_coords",
"[",
"0",
"]",
"/",
"v",
".",
"shape",
"[",
"0",
"]",
",",
"disc_coords",
"[",
"1",
"]",
"/",
"v",
".",
"shape",
"[",
"1",
"]",
","... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StaticPotential.normalize | Sets the potential range 0 to 1. | pymatgen/analysis/path_finder.py | def normalize(self):
"""
Sets the potential range 0 to 1.
"""
self.__v = self.__v - np.amin(self.__v)
self.__v = self.__v / np.amax(self.__v) | def normalize(self):
"""
Sets the potential range 0 to 1.
"""
self.__v = self.__v - np.amin(self.__v)
self.__v = self.__v / np.amax(self.__v) | [
"Sets",
"the",
"potential",
"range",
"0",
"to",
"1",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L278-L283 | [
"def",
"normalize",
"(",
"self",
")",
":",
"self",
".",
"__v",
"=",
"self",
".",
"__v",
"-",
"np",
".",
"amin",
"(",
"self",
".",
"__v",
")",
"self",
".",
"__v",
"=",
"self",
".",
"__v",
"/",
"np",
".",
"amax",
"(",
"self",
".",
"__v",
")"
] | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StaticPotential.rescale_field | Changes the discretization of the potential field by linear
interpolation. This is necessary if the potential field
obtained from DFT is strangely skewed, or is too fine or coarse. Obeys
periodic boundary conditions at the edges of
the cell. Alternatively useful for mixing potentials tha... | pymatgen/analysis/path_finder.py | def rescale_field(self, new_dim):
"""
Changes the discretization of the potential field by linear
interpolation. This is necessary if the potential field
obtained from DFT is strangely skewed, or is too fine or coarse. Obeys
periodic boundary conditions at the edges of
th... | def rescale_field(self, new_dim):
"""
Changes the discretization of the potential field by linear
interpolation. This is necessary if the potential field
obtained from DFT is strangely skewed, or is too fine or coarse. Obeys
periodic boundary conditions at the edges of
th... | [
"Changes",
"the",
"discretization",
"of",
"the",
"potential",
"field",
"by",
"linear",
"interpolation",
".",
"This",
"is",
"necessary",
"if",
"the",
"potential",
"field",
"obtained",
"from",
"DFT",
"is",
"strangely",
"skewed",
"or",
"is",
"too",
"fine",
"or",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L285-L310 | [
"def",
"rescale_field",
"(",
"self",
",",
"new_dim",
")",
":",
"v_dim",
"=",
"self",
".",
"__v",
".",
"shape",
"padded_v",
"=",
"np",
".",
"lib",
".",
"pad",
"(",
"self",
".",
"__v",
",",
"(",
"(",
"0",
",",
"1",
")",
",",
"(",
"0",
",",
"1",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StaticPotential.gaussian_smear | Applies an isotropic Gaussian smear of width (standard deviation) r to
the potential field. This is necessary to avoid finding paths through
narrow minima or nodes that may exist in the field (although any
potential or charge distribution generated from GGA should be
relatively smooth an... | pymatgen/analysis/path_finder.py | def gaussian_smear(self, r):
"""
Applies an isotropic Gaussian smear of width (standard deviation) r to
the potential field. This is necessary to avoid finding paths through
narrow minima or nodes that may exist in the field (although any
potential or charge distribution generate... | def gaussian_smear(self, r):
"""
Applies an isotropic Gaussian smear of width (standard deviation) r to
the potential field. This is necessary to avoid finding paths through
narrow minima or nodes that may exist in the field (although any
potential or charge distribution generate... | [
"Applies",
"an",
"isotropic",
"Gaussian",
"smear",
"of",
"width",
"(",
"standard",
"deviation",
")",
"r",
"to",
"the",
"potential",
"field",
".",
"This",
"is",
"necessary",
"to",
"avoid",
"finding",
"paths",
"through",
"narrow",
"minima",
"or",
"nodes",
"tha... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/path_finder.py#L312-L356 | [
"def",
"gaussian_smear",
"(",
"self",
",",
"r",
")",
":",
"# Since scaling factor in fractional coords is not isotropic, have to",
"# have different radii in 3 directions",
"a_lat",
"=",
"self",
".",
"__s",
".",
"lattice",
".",
"a",
"b_lat",
"=",
"self",
".",
"__s",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | RLSVolumePredictor.predict | Given a structure, returns the predicted volume.
Args:
structure (Structure): structure w/unknown volume
ref_structure (Structure): A reference structure with a similar
structure but different species.
Returns:
a float value of the predicted volume | pymatgen/analysis/structure_prediction/volume_predictor.py | def predict(self, structure, ref_structure):
"""
Given a structure, returns the predicted volume.
Args:
structure (Structure): structure w/unknown volume
ref_structure (Structure): A reference structure with a similar
structure but different species.
... | def predict(self, structure, ref_structure):
"""
Given a structure, returns the predicted volume.
Args:
structure (Structure): structure w/unknown volume
ref_structure (Structure): A reference structure with a similar
structure but different species.
... | [
"Given",
"a",
"structure",
"returns",
"the",
"predicted",
"volume",
".",
"Args",
":",
"structure",
"(",
"Structure",
")",
":",
"structure",
"w",
"/",
"unknown",
"volume",
"ref_structure",
"(",
"Structure",
")",
":",
"A",
"reference",
"structure",
"with",
"a"... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_prediction/volume_predictor.py#L53-L123 | [
"def",
"predict",
"(",
"self",
",",
"structure",
",",
"ref_structure",
")",
":",
"if",
"self",
".",
"check_isostructural",
":",
"m",
"=",
"StructureMatcher",
"(",
")",
"mapping",
"=",
"m",
".",
"get_best_electronegativity_anonymous_mapping",
"(",
"structure",
",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | RLSVolumePredictor.get_predicted_structure | Given a structure, returns back the structure scaled to predicted
volume.
Args:
structure (Structure): structure w/unknown volume
ref_structure (Structure): A reference structure with a similar
structure but different species.
Returns:
a Struct... | pymatgen/analysis/structure_prediction/volume_predictor.py | def get_predicted_structure(self, structure, ref_structure):
"""
Given a structure, returns back the structure scaled to predicted
volume.
Args:
structure (Structure): structure w/unknown volume
ref_structure (Structure): A reference structure with a similar
... | def get_predicted_structure(self, structure, ref_structure):
"""
Given a structure, returns back the structure scaled to predicted
volume.
Args:
structure (Structure): structure w/unknown volume
ref_structure (Structure): A reference structure with a similar
... | [
"Given",
"a",
"structure",
"returns",
"back",
"the",
"structure",
"scaled",
"to",
"predicted",
"volume",
".",
"Args",
":",
"structure",
"(",
"Structure",
")",
":",
"structure",
"w",
"/",
"unknown",
"volume",
"ref_structure",
"(",
"Structure",
")",
":",
"A",
... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_prediction/volume_predictor.py#L125-L139 | [
"def",
"get_predicted_structure",
"(",
"self",
",",
"structure",
",",
"ref_structure",
")",
":",
"new_structure",
"=",
"structure",
".",
"copy",
"(",
")",
"new_structure",
".",
"scale_lattice",
"(",
"self",
".",
"predict",
"(",
"structure",
",",
"ref_structure",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | DLSVolumePredictor.predict | Given a structure, returns the predicted volume.
Args:
structure (Structure) : a crystal structure with an unknown volume.
icsd_vol (bool) : True if the input structure's volume comes from
ICSD.
Returns:
a float value of the predicted volume. | pymatgen/analysis/structure_prediction/volume_predictor.py | def predict(self, structure, icsd_vol=False):
"""
Given a structure, returns the predicted volume.
Args:
structure (Structure) : a crystal structure with an unknown volume.
icsd_vol (bool) : True if the input structure's volume comes from
ICSD.
R... | def predict(self, structure, icsd_vol=False):
"""
Given a structure, returns the predicted volume.
Args:
structure (Structure) : a crystal structure with an unknown volume.
icsd_vol (bool) : True if the input structure's volume comes from
ICSD.
R... | [
"Given",
"a",
"structure",
"returns",
"the",
"predicted",
"volume",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_prediction/volume_predictor.py#L171-L242 | [
"def",
"predict",
"(",
"self",
",",
"structure",
",",
"icsd_vol",
"=",
"False",
")",
":",
"# Get standard deviation of electronnegativity in the structure.",
"std_x",
"=",
"np",
".",
"std",
"(",
"[",
"site",
".",
"specie",
".",
"X",
"for",
"site",
"in",
"struc... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.