function
stringlengths 11
56k
| repo_name
stringlengths 5
60
| features
sequence |
---|---|---|
def handle_message(self, client, message):
payload = self.parse_message(message)
if payload:
event = payload.pop('event')
self.fire_callback(client, event, **payload) | CptLemming/django-socket-server | [
7,
8,
7,
2,
1416363509
] |
def __init__(self, volumes, energies, eos="vinet"):
"""Init method.
volumes : array_like
Unit cell volumes where energies are obtained.
shape=(volumes, ), dtype='double'.
energies : array_like
Energies obtained at volumes.
shape=(volumes, ), dtype='double'.
eos : str
Identifier of equation of states function.
"""
self._volumes = volumes
if np.array(energies).ndim == 1:
self._energies = energies
else:
self._energies = energies[0]
self._eos = get_eos(eos)
self._energy = None
self._bulk_modulus = None
self._b_prime = None
try:
(
self._energy,
self._bulk_modulus,
self._b_prime,
self._volume,
) = fit_to_eos(volumes, self._energies, self._eos)
except TypeError:
msg = ['Failed to fit to "%s" equation of states.' % eos]
if len(volumes) < 4:
msg += ["At least 4 volume points are needed for the fitting."]
msg += ["Careful choice of volume points is recommended."]
raise RuntimeError("\n".join(msg)) | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def bulk_modulus(self):
"""Return bulk modulus."""
return self._bulk_modulus | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def equilibrium_volume(self):
"""Return volume at equilibrium."""
return self._volume | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def b_prime(self):
"""Return fitted parameter B'."""
return self._b_prime | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def energy(self):
"""Return fitted parameter of energy."""
return self._energy | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def get_parameters(self):
"""Return fitted parameters."""
return (self._energy, self._bulk_modulus, self._b_prime, self._volume) | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot(self):
"""Plot fitted EOS curve."""
import matplotlib.pyplot as plt
ep = self.get_parameters()
vols = self._volumes
volume_points = np.linspace(min(vols), max(vols), 201)
fig, ax = plt.subplots()
ax.plot(volume_points, self._eos(volume_points, *ep), "r-")
ax.plot(vols, self._energies, "bo", markersize=4)
return plt | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def __init__(
self,
volumes, # angstrom^3
electronic_energies, # eV
temperatures, # K
cv, # J/K/mol
entropy, # J/K/mol
fe_phonon, # kJ/mol
eos="vinet",
t_max=None,
energy_plot_factor=None, | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def thermal_expansion(self):
"""Return volumetric thermal expansion coefficients at temperatures."""
return self._thermal_expansions[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def helmholtz_volume(self):
"""Return Helmholtz free energies at temperatures and volumes."""
return self._free_energies[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def volume_temperature(self):
"""Return equilibrium volumes at temperatures."""
return self._equiv_volumes[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def gibbs_temperature(self):
"""Return Gibbs free energies at temperatures."""
return self._equiv_energies[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def bulk_modulus_temperature(self):
"""Return bulk modulus vs temperature data."""
return self._equiv_bulk_modulus[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def heat_capacity_P_numerical(self):
"""Return heat capacities at constant pressure at temperatures.
Values are computed by numerical derivative of Gibbs free energy.
"""
return self._cp_numerical[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def heat_capacity_P_polyfit(self):
"""Return heat capacities at constant pressure at temperatures.
Volumes are computed in another way to heat_capacity_P_numerical
for the better numerical behaviour. But this does not work
when temperature dependent electronic_energies is supplied.
"""
if self._electronic_energies.ndim == 1:
return self._cp_polyfit[: self._len]
else:
return None | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def gruneisen_temperature(self):
"""Return Gruneisen parameters at temperatures."""
return self._gruneisen_parameters[: self._len] | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot(self, thin_number=10, volume_temp_exp=None):
"""Plot three figures.
- Helmholtz free energy at volumes and temperatures.
- Equilibrium volumes at temperatures.
- Thermal expansion coefficients at temperatures.
"""
import matplotlib.pyplot as plt
plt.rcParams["pdf.fonttype"] = 42
plt.rcParams["font.family"] = "serif"
fig, axs = plt.subplots(1, 3, figsize=(7, 3.5))
axs[0].xaxis.set_ticks_position("both")
axs[0].yaxis.set_ticks_position("both")
axs[0].xaxis.set_tick_params(which="both", direction="in")
axs[0].yaxis.set_tick_params(which="both", direction="in")
self._plot_helmholtz_volume(axs[0], thin_number=thin_number)
axs[1].xaxis.set_ticks_position("both")
axs[1].yaxis.set_ticks_position("both")
axs[1].xaxis.set_tick_params(which="both", direction="in")
axs[1].yaxis.set_tick_params(which="both", direction="in")
self._plot_volume_temperature(axs[1], exp_data=volume_temp_exp)
axs[2].xaxis.set_ticks_position("both")
axs[2].yaxis.set_ticks_position("both")
axs[2].xaxis.set_tick_params(which="both", direction="in")
axs[2].yaxis.set_tick_params(which="both", direction="in")
self._plot_thermal_expansion(axs[2])
plt.tight_layout()
return plt | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_helmholtz_volume(
self, thin_number=10, xlabel=r"Volume $(\AA^3)$", ylabel="Free energy" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_pdf_helmholtz_volume(
self, thin_number=10, filename="helmholtz-volume.pdf" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def write_helmholtz_volume(self, filename="helmholtz-volume.dat"):
"""Write Helmholtz free energy vs volume in file."""
w = open(filename, "w")
for i, (t, ep, fe) in enumerate(
zip(self._temperatures, self._equiv_parameters, self._free_energies)
):
if i == self._len:
break
w.write("# Temperature: %f\n" % t)
w.write("# Parameters: %f %f %f %f\n" % tuple(ep))
for j, v in enumerate(self._volumes):
w.write("%20.15f %25.15f\n" % (v, fe[j]))
w.write("\n\n")
w.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def get_volume_temperature(self):
"""Return equilibrium volumes at temperatures."""
warnings.warn(
"QHA.get_volume_temperature() is deprecated."
"Use volume_temperature attribute.",
DeprecationWarning,
)
return self.volume_temperature | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_pdf_volume_temperature(
self, exp_data=None, filename="volume-temperature.pdf" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def write_volume_temperature(self, filename="volume-temperature.dat"):
"""Write volume vs temperature in file."""
w = open(filename, "w")
for i in range(self._len):
w.write(
"%25.15f %25.15f\n" % (self._temperatures[i], self._equiv_volumes[i])
)
w.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_thermal_expansion(self):
"""Return pyplot of thermal expansion vs temperature."""
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
self._plot_thermal_expansion(ax)
return plt | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def write_thermal_expansion(self, filename="thermal_expansion.dat"):
"""Write thermal expansion vs temperature in file."""
w = open(filename, "w")
for i in range(self._len):
w.write(
"%25.15f %25.15f\n"
% (self._temperatures[i], self._thermal_expansions[i])
)
w.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_gibbs_temperature(
self, xlabel="Temperature (K)", ylabel="Gibbs free energy" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_pdf_gibbs_temperature(self, filename="gibbs-temperature.pdf"):
"""Plot Gibbs free energy vs temperature in pdf."""
import matplotlib.pyplot as plt
self._set_rcParams(plt)
fig, ax = plt.subplots()
ax.xaxis.set_ticks_position("both")
ax.yaxis.set_ticks_position("both")
ax.xaxis.set_tick_params(which="both", direction="in")
ax.yaxis.set_tick_params(which="both", direction="in")
self._plot_gibbs_temperature(ax)
plt.savefig(filename)
plt.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def get_bulk_modulus_temperature(self):
"""Return bulk moduli at temperatures."""
return self.bulk_modulus_temperature | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_pdf_bulk_modulus_temperature(
self, filename="bulk_modulus-temperature.pdf" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def write_bulk_modulus_temperature(self, filename="bulk_modulus-temperature.dat"):
"""Write bulk modulus vs temperature in file."""
w = open(filename, "w")
for i in range(self._len):
w.write(
"%20.15f %25.15f\n"
% (self._temperatures[i], self._equiv_bulk_modulus[i])
)
w.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_heat_capacity_P_numerical(self, Z=1, exp_data=None):
"""Return pyplot of C_P by numerical difference vs temperature."""
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
self._plot_heat_capacity_P_numerical(ax, Z=Z, exp_data=exp_data)
return plt | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def write_heat_capacity_P_numerical(self, filename="Cp-temperature.dat"):
"""Write C_P by numerical difference vs temperature in file."""
w = open(filename, "w")
for i in range(self._len):
w.write(
"%20.15f %20.15f\n" % (self._temperatures[i], self._cp_numerical[i])
)
w.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_heat_capacity_P_polyfit(self, Z=1, exp_data=None):
"""Return pyplot of C_P by fittings vs temperature."""
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
self._plot_heat_capacity_P_polyfit(ax, Z=Z, exp_data=exp_data)
return plt | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def write_heat_capacity_P_polyfit(
self,
filename="Cp-temperature_polyfit.dat",
filename_ev="entropy-volume.dat",
filename_cvv="Cv-volume.dat",
filename_dsdvt="dsdv-temperature.dat", | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def get_gruneisen_temperature(self):
"""Return Grueneisen parameters at temperatures."""
return self.gruneisen_temperature | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def plot_pdf_gruneisen_temperature(self, filename="gruneisen-temperature.pdf"):
"""Plot Grueneisen parameter vs temperature in pdf."""
import matplotlib.pyplot as plt
self._set_rcParams(plt)
fig, ax = plt.subplots()
ax.xaxis.set_ticks_position("both")
ax.yaxis.set_ticks_position("both")
ax.xaxis.set_tick_params(which="both", direction="in")
ax.yaxis.set_tick_params(which="both", direction="in")
self._plot_gruneisen_temperature(ax)
plt.savefig(filename)
plt.close() | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_helmholtz_volume(
self, ax, thin_number=10, xlabel=r"Volume $(\AA^3)$", ylabel="Free energy" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_volume_temperature(
self, ax, exp_data=None, xlabel="Temperature (K)", ylabel=r"Volume $(\AA^3)$" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_thermal_expansion(
self,
ax,
xlabel="Temperature (K)",
ylabel=r"Thermal expansion $(\mathrm{K}^{-1})$", | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def __init__(self):
super().__init__(useMathText=True) | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_gibbs_temperature(
self, ax, xlabel="Temperature (K)", ylabel="Gibbs free energy (eV)" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_bulk_modulus_temperature(
self, ax, xlabel="Temperature (K)", ylabel="Bulk modulus (GPa)" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_heat_capacity_P_numerical(
self,
ax,
Z=1,
exp_data=None,
xlabel="Temperature (K)",
ylabel=r"$C\mathrm{_P}$ $\mathrm{(J/mol\cdot K)}$", | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_heat_capacity_P_polyfit(
self,
ax,
Z=1,
exp_data=None,
xlabel="Temperature (K)",
ylabel=r"$C\mathrm{_P}$ $\mathrm{(J/mol\cdot K)}$", | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _plot_gruneisen_temperature(
self, ax, xlabel="Temperature (K)", ylabel="Gruneisen parameter" | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _set_thermal_expansion(self):
beta = [0.0]
for i in range(1, self._num_elems - 1):
dt = self._temperatures[i + 1] - self._temperatures[i - 1]
dv = self._equiv_volumes[i + 1] - self._equiv_volumes[i - 1]
beta.append(dv / dt / self._equiv_volumes[i])
self._thermal_expansions = beta | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _set_heat_capacity_P_polyfit(self):
cp = [0.0]
dsdv = [0.0]
self._volume_entropy_parameters = []
self._volume_cv_parameters = []
self._volume_entropy = []
self._volume_cv = []
for j in range(1, self._num_elems - 1):
t = self._temperatures[j]
x = self._equiv_volumes[j]
try:
parameters = np.polyfit(self._volumes, self._cv[j], 4)
except np.lib.polynomial.RankWarning:
msg = ["Failed to fit heat capacities to polynomial of degree 4."]
if len(self._volumes) < 5:
msg += ["At least 5 volume points are needed for the fitting."]
raise RuntimeError("\n".join(msg))
cv_p = np.dot(parameters, np.array([x ** 4, x ** 3, x ** 2, x, 1]))
self._volume_cv_parameters.append(parameters)
try:
parameters = np.polyfit(self._volumes, self._entropy[j], 4)
except np.lib.polynomial.RankWarning:
msg = ["Failed to fit entropies to polynomial of degree 4."]
if len(self._volumes) < 5:
msg += ["At least 5 volume points are needed for the fitting."]
raise RuntimeError("\n".join(msg))
dsdv_t = np.dot(
parameters[:4], np.array([4 * x ** 3, 3 * x ** 2, 2 * x, 1])
)
self._volume_entropy_parameters.append(parameters)
try:
parameters = np.polyfit(
self._temperatures[j - 1 : j + 2],
self._equiv_volumes[j - 1 : j + 2],
2,
)
except np.lib.polynomial.RankWarning:
msg = (
"Failed to fit equilibrium volumes vs T to "
"polynomial of degree 2."
)
raise RuntimeError(msg)
dvdt = parameters[0] * 2 * t + parameters[1]
cp.append(cv_p + t * dvdt * dsdv_t)
dsdv.append(dsdv_t)
self._volume_cv.append(np.array([self._volumes, self._cv[j]]).T)
self._volume_entropy.append(np.array([self._volumes, self._entropy[j]]).T)
self._cp_polyfit = cp
self._dsdv = dsdv | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def _get_num_elems(self, temperatures):
if self._t_max is None:
return len(temperatures)
else:
i = np.argmin(np.abs(temperatures - self._t_max))
return i + 1 | atztogo/phonopy | [
258,
193,
258,
13,
1355213300
] |
def test_confusion_matrix(self):
result_len = rl.confusion_matrix(LINKS_TRUE, LINKS_PRED, len(FULL_INDEX))
result_full_index = rl.confusion_matrix(LINKS_TRUE, LINKS_PRED, FULL_INDEX)
expected = numpy.array([[1, 2], [3, 3]])
numpy.testing.assert_array_equal(result_len, expected)
numpy.testing.assert_array_equal(result_full_index, expected) | J535D165/recordlinkage | [
779,
134,
779,
57,
1445158802
] |
def test_recall(self):
# confusion matrix
cm = rl.confusion_matrix(LINKS_TRUE, LINKS_PRED)
assert rl.recall(LINKS_TRUE, LINKS_PRED) == 1 / 3
assert rl.recall(cm) == 1 / 3 | J535D165/recordlinkage | [
779,
134,
779,
57,
1445158802
] |
def test_accuracy(self):
# confusion matrix
cm = rl.confusion_matrix(LINKS_TRUE, LINKS_PRED, len(FULL_INDEX))
assert rl.accuracy(LINKS_TRUE, LINKS_PRED, len(FULL_INDEX)) == 4 / 9
assert rl.accuracy(cm) == 4 / 9
assert rl.accuracy(LINKS_TRUE, LINKS_PRED, FULL_INDEX) == 4 / 9 | J535D165/recordlinkage | [
779,
134,
779,
57,
1445158802
] |
def test_fscore(self):
# confusion matrix
cm = rl.confusion_matrix(LINKS_TRUE, LINKS_PRED, len(FULL_INDEX))
prec = rl.precision(LINKS_TRUE, LINKS_PRED)
rec = rl.recall(LINKS_TRUE, LINKS_PRED)
expected = float(2 * prec * rec / (prec + rec))
assert rl.fscore(LINKS_TRUE, LINKS_PRED) == expected
assert rl.fscore(cm) == expected | J535D165/recordlinkage | [
779,
134,
779,
57,
1445158802
] |
def test_loads(self):
some_pvl = """ | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def setUp(self):
self.simple = data_dir / "pds3" / "simple_image_1.lbl"
rawurl = "https://raw.githubusercontent.com/planetarypy/pvl/main/"
self.url = rawurl + str(self.simple)
self.simplePVL = pvl.PVLModule(
{
"PDS_VERSION_ID": "PDS3",
"RECORD_TYPE": "FIXED_LENGTH",
"RECORD_BYTES": 824,
"LABEL_RECORDS": 1,
"FILE_RECORDS": 601,
"^IMAGE": 2,
"IMAGE": pvl.PVLObject(
{
"LINES": 600,
"LINE_SAMPLES": 824,
"SAMPLE_TYPE": "MSB_INTEGER",
"SAMPLE_BITS": 8,
"MEAN": 51.67785396440129,
"MEDIAN": 50.0,
"MINIMUM": 0,
"MAXIMUM": 255,
"STANDARD_DEVIATION": 16.97019,
"CHECKSUM": 25549531,
}
),
}
) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_load_w_Path(self):
self.assertEqual(self.simplePVL, pvl.load(self.simple)) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_loadu(self):
self.assertEqual(self.simplePVL, pvl.loadu(self.url))
self.assertEqual(
self.simplePVL, pvl.loadu(self.simple.resolve().as_uri())
) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_loadu_args(self, m_decode, m_loads):
pvl.loadu(self.url, data=None)
pvl.loadu(self.url, noturlopen="should be passed to loads")
m_decode.assert_called()
self.assertNotIn("data", m_loads.call_args_list[0][1])
self.assertIn("noturlopen", m_loads.call_args_list[1][1]) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def setUp(self):
self.cub = data_dir / "pattern.cub"
self.cubpvl = pvl.PVLModule(
IsisCube=pvl.PVLObject(
Core=pvl.PVLObject(
StartByte=65537,
Format="Tile",
TileSamples=128,
TileLines=128,
Dimensions=pvl.PVLGroup(Samples=90, Lines=90, Bands=1),
Pixels=pvl.PVLGroup(
Type="Real", ByteOrder="Lsb", Base=0.0, Multiplier=1.0
),
)
),
Label=pvl.PVLObject(Bytes=65536),
) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_load_cub_opened(self):
with open(self.cub, "rb") as f:
self.assertEqual(self.cubpvl, pvl.load(f)) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def setUp(self):
self.module = pvl.PVLModule(
a="b",
staygroup=pvl.PVLGroup(c="d"),
obj=pvl.PVLGroup(d="e", f=pvl.PVLGroup(g="h")),
) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_dumps_PVL(self):
s = """a = b; | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_dumps_ODL(self):
s = """A = b\r | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def setUp(self):
self.module = pvl.PVLModule(
a="b",
staygroup=pvl.PVLGroup(c="d"),
obj=pvl.PVLGroup(d="e", f=pvl.PVLGroup(g="h")),
)
self.string = """A = b\r | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_dump_Path(self):
mock_path = create_autospec(Path)
with patch("pvl.Path", autospec=True, return_value=mock_path):
pvl.dump(self.module, Path("dummy"))
self.assertEqual(
[call.write_text(self.string)], mock_path.method_calls
) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_dump_file_object(self):
with open("dummy", "w") as f:
pvl.dump(self.module, f)
self.assertEqual(
[call.write(self.string.encode())], f.method_calls
) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def test_str(self):
s = "A test string\n"
stream = io.StringIO(s)
self.assertEqual(s, pvl.decode_by_char(stream)) | planetarypy/pvl | [
16,
16,
16,
2,
1433009908
] |
def map_func(data):
from sklearn.cross_validation import StratifiedKFold
from sklearn import svm, cross_validation
kfold = StratifiedKFold(y=data['y'], n_folds=3)
# kfold = cross_validation.KFold(n=data.X.shape[0], n_folds=3)
# svc = SVC(C=1, kernel='linear')
for train, test in kfold:
# svc.fit(data['X'][train], data['y'][train])
# svc.predict(data['X'][test])
data['methods'].run(X=data["X"][train], y=data['y'][train])
return None | neurospin/pylearn-epac | [
12,
3,
12,
11,
1366214241
] |
def extractWwwNovicetranslationsCom(item):
'''
Parser for 'www.novicetranslations.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
tagmap = [
('PRC', 'PRC', 'translated'),
('Loiterous', 'Loiterous', 'oel'),
]
for tagname, name, tl_type in tagmap:
if tagname in item['tags']:
return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False | fake-name/ReadableWebProxy | [
191,
16,
191,
3,
1437712243
] |
def dsl_kwargs_decorator(*dsl_rules):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def __or__(self, other):
"""
:param Filter other:
:return:
"""
return self.apply_sequence([other]) | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def apply_sequence(self, others):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def apply_filter_sequence(self, filters):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def cast_to_apply_sequence(self, others):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def apply_operator(self,
op_func=None,
others=None,
op_mode=None,
**kwargs):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def apply_filter_operator(self,
op_func=None,
filters=None,
op_mode=None,
**kwargs):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def to_tuple(cls, *args):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def cast_to_apply_operator(self, others):
""" | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def to_filter(self, value):
"""
:param value:
:return:
"""
if isinstance(value, collections.Iterable):
return self.seq_to_filter(value)
return self.scalar_to_filter(value) | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def seq_to_filter(value):
"""
:param value:
:return:
"""
from .filter_cast_seq_value import FilterCastSeqValue
return FilterCastSeqValue(seq=value) | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def scalar_to_filter(value):
"""
:param value:
:return:
"""
from .filter_cast_scalar_value import FilterCastScalarValue
return FilterCastScalarValue(value=value) | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def i(self, *args, **kwargs):
"""
:param args:
:param kwargs:
:return:
"""
return self.intersect(*args, **kwargs) | w495/python-video-shot-detector | [
19,
3,
19,
5,
1434159207
] |
def extractSixtranslationTumblrCom(item):
'''
Parser for 'sixtranslation.tumblr.com'
'''
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
tagmap = [
('PRC', 'PRC', 'translated'),
('Loiterous', 'Loiterous', 'oel'),
]
for tagname, name, tl_type in tagmap:
if tagname in item['tags']:
return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False | fake-name/ReadableWebProxy | [
191,
16,
191,
3,
1437712243
] |
def create(kernel):
result = Creature()
result.template = "object/mobile/shared_dressed_fs_village_whip.iff"
result.attribute_template_id = 9
result.stfName("npc_name","human_base_male") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def notify_missing_directory():
for directory in missing_directory:
print(directory + '\n') | evanhenri/RNN-Trading-Bot | [
20,
10,
20,
2,
1441678366
] |
def test_episode_equations():
expected_scores = {}
for symbol, score in solve_episode_equations().items():
expected_scores[str(symbol)] = score
assert episode_scores == expected_scores | Diaoul/subliminal | [
2274,
315,
2274,
133,
1309825463
] |
def test_compute_score(episodes):
video = episodes['bbt_s07e05']
subtitle = Addic7edSubtitle(Language('eng'), True, None, 'the big BANG theory', 6, 4, None, None, '1080p', None)
expected_score = episode_scores['series'] + episode_scores['year'] + episode_scores['country']
assert compute_score(subtitle, video) == expected_score | Diaoul/subliminal | [
2274,
315,
2274,
133,
1309825463
] |
def test_compute_score_episode_imdb_id(movies):
video = movies['man_of_steel']
subtitle = OpenSubtitlesSubtitle(Language('eng'), True, None, 1, 'hash', 'movie', None,
'Man of Steel', 'man.of.steel.2013.720p.bluray.x264-felony.mkv', 2013, 770828,
None, None, '', 'utf-8')
assert compute_score(subtitle, video) == sum(movie_scores.get(m, 0) for m in
('imdb_id', 'title', 'year', 'country', 'release_group', 'source',
'resolution', 'video_codec')) | Diaoul/subliminal | [
2274,
315,
2274,
133,
1309825463
] |
def start_spark():
run('/home/mdindex/scripts/startSystems.sh') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def stop_spark():
run('/home/mdindex/scripts/stopSystems.sh') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def start_zookeeper():
run('/home/mdindex/scripts/startZookeeper.sh') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def stop_zookeeper():
run('/home/mdindex/scripts/stopZookeeper.sh') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def build_jar():
local('cd /Users/anil/Dev/repos/mdindex/; gradle shadowJar') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def update_jar():
if not exists('/data/mdindex/jars'):
run('mkdir -p /data/mdindex/jars')
put('../build/libs/amoeba-all.jar', '/data/mdindex/jars/') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def update_master_jar():
if not exists('/data/mdindex/jars'):
run('mkdir -p /data/mdindex/jars')
put('../build/libs/amoeba-all.jar', '/data/mdindex/jars/') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def update_config():
global counter
put('server/server.properties', '/home/mdindex/amoeba.properties')
run('echo "MACHINE_ID = %d" >> /home/mdindex/amoeba.properties' % counter)
counter += 1 | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def clean_cluster():
run('rm -R /data/mdindex/logs/hadoop/')
run('rm -R /home/mdindex/spark-1.6.0-bin-hadoop2.6/logs/')
run('rm -R /home/mdindex/spark-1.6.0-bin-hadoop2.6/work/') | mitdbg/mdindex | [
15,
3,
15,
12,
1436855133
] |
def create(kernel):
result = Creature()
result.template = "object/mobile/shared_dressed_diplomat_zabrak_male_01.iff"
result.attribute_template_id = 9
result.stfName("npc_name","zabrak_base_male") | anhstudios/swganh | [
62,
37,
62,
37,
1297996365
] |
def _init(self, maxsize):
self.maxsize = maxsize
self.queue = [] | holys/ledis-py | [
10,
4,
10,
1,
1413509569
] |
def _put(self, item):
self.queue.append(item) | holys/ledis-py | [
10,
4,
10,
1,
1413509569
] |
Subsets and Splits