repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
jtambasco/modesolverpy | modesolverpy/mode_solver.py | ModeSolverFullyVectorial.write_modes_to_file | def write_modes_to_file(
self,
filename="mode.dat",
plot=True,
fields_to_write=("Ex", "Ey", "Ez", "Hx", "Hy", "Hz"),
):
"""
Writes the mode fields to a file and optionally plots them.
Args:
filename (str): The nominal filename to use for the saved... | python | def write_modes_to_file(
self,
filename="mode.dat",
plot=True,
fields_to_write=("Ex", "Ey", "Ez", "Hx", "Hy", "Hz"),
):
"""
Writes the mode fields to a file and optionally plots them.
Args:
filename (str): The nominal filename to use for the saved... | [
"def",
"write_modes_to_file",
"(",
"self",
",",
"filename",
"=",
"\"mode.dat\"",
",",
"plot",
"=",
"True",
",",
"fields_to_write",
"=",
"(",
"\"Ex\"",
",",
"\"Ey\"",
",",
"\"Ez\"",
",",
"\"Hx\"",
",",
"\"Hy\"",
",",
"\"Hz\"",
")",
",",
")",
":",
"modes_d... | Writes the mode fields to a file and optionally plots them.
Args:
filename (str): The nominal filename to use for the saved
data. The suffix will be automatically be changed to
identifiy each field and mode number. Default is
'mode.dat'
... | [
"Writes",
"the",
"mode",
"fields",
"to",
"a",
"file",
"and",
"optionally",
"plots",
"them",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/mode_solver.py#L729-L799 |
brutus/wtforms-html5 | wtforms_html5.py | set_required | def set_required(field, render_kw=None, force=False):
"""
Returns *render_kw* with *required* set if the field is required.
Sets the *required* key if the `required` flag is set for the field (this
is mostly the case if it is set by validators). The `required` attribute
is used by browsers to indic... | python | def set_required(field, render_kw=None, force=False):
"""
Returns *render_kw* with *required* set if the field is required.
Sets the *required* key if the `required` flag is set for the field (this
is mostly the case if it is set by validators). The `required` attribute
is used by browsers to indic... | [
"def",
"set_required",
"(",
"field",
",",
"render_kw",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"render_kw",
"is",
"None",
":",
"render_kw",
"=",
"{",
"}",
"if",
"'required'",
"in",
"render_kw",
"and",
"not",
"force",
":",
"return",
"re... | Returns *render_kw* with *required* set if the field is required.
Sets the *required* key if the `required` flag is set for the field (this
is mostly the case if it is set by validators). The `required` attribute
is used by browsers to indicate a required field.
..note::
This won't change key... | [
"Returns",
"*",
"render_kw",
"*",
"with",
"*",
"required",
"*",
"set",
"if",
"the",
"field",
"is",
"required",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/wtforms_html5.py#L124-L143 |
brutus/wtforms-html5 | wtforms_html5.py | set_invalid | def set_invalid(field, render_kw=None):
"""
Returns *render_kw* with `invalid` added to *class* on validation errors.
Set (or appends) 'invalid' to the fields CSS class(es), if the *field* got
any errors. 'invalid' is also set by browsers if they detect errors on a
field.
"""
if render_kw ... | python | def set_invalid(field, render_kw=None):
"""
Returns *render_kw* with `invalid` added to *class* on validation errors.
Set (or appends) 'invalid' to the fields CSS class(es), if the *field* got
any errors. 'invalid' is also set by browsers if they detect errors on a
field.
"""
if render_kw ... | [
"def",
"set_invalid",
"(",
"field",
",",
"render_kw",
"=",
"None",
")",
":",
"if",
"render_kw",
"is",
"None",
":",
"render_kw",
"=",
"{",
"}",
"if",
"field",
".",
"errors",
":",
"classes",
"=",
"render_kw",
".",
"get",
"(",
"'class'",
")",
"or",
"ren... | Returns *render_kw* with `invalid` added to *class* on validation errors.
Set (or appends) 'invalid' to the fields CSS class(es), if the *field* got
any errors. 'invalid' is also set by browsers if they detect errors on a
field. | [
"Returns",
"*",
"render_kw",
"*",
"with",
"invalid",
"added",
"to",
"*",
"class",
"*",
"on",
"validation",
"errors",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/wtforms_html5.py#L146-L163 |
brutus/wtforms-html5 | wtforms_html5.py | set_minmax | def set_minmax(field, render_kw=None, force=False):
"""
Returns *render_kw* with *min* and *max* set if validators use them.
Sets *min* and / or *max* keys if a `Length` or `NumberRange` validator is
using them.
..note::
This won't change keys already present unless *force* is used.
... | python | def set_minmax(field, render_kw=None, force=False):
"""
Returns *render_kw* with *min* and *max* set if validators use them.
Sets *min* and / or *max* keys if a `Length` or `NumberRange` validator is
using them.
..note::
This won't change keys already present unless *force* is used.
... | [
"def",
"set_minmax",
"(",
"field",
",",
"render_kw",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"render_kw",
"is",
"None",
":",
"render_kw",
"=",
"{",
"}",
"for",
"validator",
"in",
"field",
".",
"validators",
":",
"if",
"isinstance",
"("... | Returns *render_kw* with *min* and *max* set if validators use them.
Sets *min* and / or *max* keys if a `Length` or `NumberRange` validator is
using them.
..note::
This won't change keys already present unless *force* is used. | [
"Returns",
"*",
"render_kw",
"*",
"with",
"*",
"min",
"*",
"and",
"*",
"max",
"*",
"set",
"if",
"validators",
"use",
"them",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/wtforms_html5.py#L166-L190 |
brutus/wtforms-html5 | wtforms_html5.py | set_title | def set_title(field, render_kw=None):
"""
Returns *render_kw* with *min* and *max* set if required.
If the field got a *description* but no *title* key is set, the *title* is
set to *description*.
"""
if render_kw is None:
render_kw = {}
if 'title' not in render_kw and getattr(fiel... | python | def set_title(field, render_kw=None):
"""
Returns *render_kw* with *min* and *max* set if required.
If the field got a *description* but no *title* key is set, the *title* is
set to *description*.
"""
if render_kw is None:
render_kw = {}
if 'title' not in render_kw and getattr(fiel... | [
"def",
"set_title",
"(",
"field",
",",
"render_kw",
"=",
"None",
")",
":",
"if",
"render_kw",
"is",
"None",
":",
"render_kw",
"=",
"{",
"}",
"if",
"'title'",
"not",
"in",
"render_kw",
"and",
"getattr",
"(",
"field",
",",
"'description'",
")",
":",
"ren... | Returns *render_kw* with *min* and *max* set if required.
If the field got a *description* but no *title* key is set, the *title* is
set to *description*. | [
"Returns",
"*",
"render_kw",
"*",
"with",
"*",
"min",
"*",
"and",
"*",
"max",
"*",
"set",
"if",
"required",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/wtforms_html5.py#L193-L205 |
brutus/wtforms-html5 | wtforms_html5.py | get_html5_kwargs | def get_html5_kwargs(field, render_kw=None, force=False):
"""
Returns a copy of *render_kw* with keys added for a bound *field*.
If some *render_kw* are given, the new keys are added to a copy of them,
which is then returned. If none are given, a dictionary containing only
the automatically genera... | python | def get_html5_kwargs(field, render_kw=None, force=False):
"""
Returns a copy of *render_kw* with keys added for a bound *field*.
If some *render_kw* are given, the new keys are added to a copy of them,
which is then returned. If none are given, a dictionary containing only
the automatically genera... | [
"def",
"get_html5_kwargs",
"(",
"field",
",",
"render_kw",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"UnboundField",
")",
":",
"msg",
"=",
"'This function needs a bound field not: {}'",
"raise",
"ValueError",
"(",
... | Returns a copy of *render_kw* with keys added for a bound *field*.
If some *render_kw* are given, the new keys are added to a copy of them,
which is then returned. If none are given, a dictionary containing only
the automatically generated keys is returned.
.. important::
This might add new ... | [
"Returns",
"a",
"copy",
"of",
"*",
"render_kw",
"*",
"with",
"keys",
"added",
"for",
"a",
"bound",
"*",
"field",
"*",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/wtforms_html5.py#L208-L254 |
brutus/wtforms-html5 | wtforms_html5.py | AutoAttrMeta.render_field | def render_field(self, field, render_kw):
"""
Returns the rendered field after adding auto–attributes.
Calls the field`s widget with the following kwargs:
1. the *render_kw* set on the field are used as based
2. and are updated with the *render_kw* arguments from the render cal... | python | def render_field(self, field, render_kw):
"""
Returns the rendered field after adding auto–attributes.
Calls the field`s widget with the following kwargs:
1. the *render_kw* set on the field are used as based
2. and are updated with the *render_kw* arguments from the render cal... | [
"def",
"render_field",
"(",
"self",
",",
"field",
",",
"render_kw",
")",
":",
"field_kw",
"=",
"getattr",
"(",
"field",
",",
"'render_kw'",
",",
"None",
")",
"if",
"field_kw",
"is",
"not",
"None",
":",
"render_kw",
"=",
"dict",
"(",
"field_kw",
",",
"*... | Returns the rendered field after adding auto–attributes.
Calls the field`s widget with the following kwargs:
1. the *render_kw* set on the field are used as based
2. and are updated with the *render_kw* arguments from the render call
3. this is used as an argument for a call to `get_ht... | [
"Returns",
"the",
"rendered",
"field",
"after",
"adding",
"auto–attributes",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/wtforms_html5.py#L266-L282 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | _AbstractStructure.x | def x(self):
'''
np.array: The grid points in x.
'''
if None not in (self.x_min, self.x_max, self.x_step) and \
self.x_min != self.x_max:
x = np.arange(self.x_min, self.x_max+self.x_step-self.y_step*0.1, self.x_step)
else:
x = np.array([])
... | python | def x(self):
'''
np.array: The grid points in x.
'''
if None not in (self.x_min, self.x_max, self.x_step) and \
self.x_min != self.x_max:
x = np.arange(self.x_min, self.x_max+self.x_step-self.y_step*0.1, self.x_step)
else:
x = np.array([])
... | [
"def",
"x",
"(",
"self",
")",
":",
"if",
"None",
"not",
"in",
"(",
"self",
".",
"x_min",
",",
"self",
".",
"x_max",
",",
"self",
".",
"x_step",
")",
"and",
"self",
".",
"x_min",
"!=",
"self",
".",
"x_max",
":",
"x",
"=",
"np",
".",
"arange",
... | np.array: The grid points in x. | [
"np",
".",
"array",
":",
"The",
"grid",
"points",
"in",
"x",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L130-L139 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | _AbstractStructure.y | def y(self):
'''
np.array: The grid points in y.
'''
if None not in (self.y_min, self.y_max, self.y_step) and \
self.y_min != self.y_max:
y = np.arange(self.y_min, self.y_max-self.y_step*0.1, self.y_step)
else:
y = np.array([])
retu... | python | def y(self):
'''
np.array: The grid points in y.
'''
if None not in (self.y_min, self.y_max, self.y_step) and \
self.y_min != self.y_max:
y = np.arange(self.y_min, self.y_max-self.y_step*0.1, self.y_step)
else:
y = np.array([])
retu... | [
"def",
"y",
"(",
"self",
")",
":",
"if",
"None",
"not",
"in",
"(",
"self",
".",
"y_min",
",",
"self",
".",
"y_max",
",",
"self",
".",
"y_step",
")",
"and",
"self",
".",
"y_min",
"!=",
"self",
".",
"y_max",
":",
"y",
"=",
"np",
".",
"arange",
... | np.array: The grid points in y. | [
"np",
".",
"array",
":",
"The",
"grid",
"points",
"in",
"y",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L142-L151 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | _AbstractStructure.eps_func | def eps_func(self):
'''
function: a function that when passed a `x` and `y` values,
returns the permittivity profile of the structure,
interpolating if necessary.
'''
interp_real = interpolate.interp2d(self.x, self.y, self.eps.real)
interp_imag = interpola... | python | def eps_func(self):
'''
function: a function that when passed a `x` and `y` values,
returns the permittivity profile of the structure,
interpolating if necessary.
'''
interp_real = interpolate.interp2d(self.x, self.y, self.eps.real)
interp_imag = interpola... | [
"def",
"eps_func",
"(",
"self",
")",
":",
"interp_real",
"=",
"interpolate",
".",
"interp2d",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"eps",
".",
"real",
")",
"interp_imag",
"=",
"interpolate",
".",
"interp2d",
"(",
"self",
".... | function: a function that when passed a `x` and `y` values,
returns the permittivity profile of the structure,
interpolating if necessary. | [
"function",
":",
"a",
"function",
"that",
"when",
"passed",
"a",
"x",
"and",
"y",
"values",
"returns",
"the",
"permittivity",
"profile",
"of",
"the",
"structure",
"interpolating",
"if",
"necessary",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L162-L171 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | _AbstractStructure.n_func | def n_func(self):
'''
function: a function that when passed a `x` and `y` values,
returns the refractive index profile of the structure,
interpolating if necessary.
'''
return interpolate.interp2d(self.x, self.y, self.n) | python | def n_func(self):
'''
function: a function that when passed a `x` and `y` values,
returns the refractive index profile of the structure,
interpolating if necessary.
'''
return interpolate.interp2d(self.x, self.y, self.n) | [
"def",
"n_func",
"(",
"self",
")",
":",
"return",
"interpolate",
".",
"interp2d",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"n",
")"
] | function: a function that when passed a `x` and `y` values,
returns the refractive index profile of the structure,
interpolating if necessary. | [
"function",
":",
"a",
"function",
"that",
"when",
"passed",
"a",
"x",
"and",
"y",
"values",
"returns",
"the",
"refractive",
"index",
"profile",
"of",
"the",
"structure",
"interpolating",
"if",
"necessary",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L174-L180 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | _AbstractStructure._add_material | def _add_material(self, x_bot_left, y_bot_left, x_top_right, y_top_right,
n_material, angle=0):
'''
A low-level function that allows writing a rectangle refractive
index profile to a `Structure`.
Args:
x_bot_left (float): The bottom-left x-coordinate of ... | python | def _add_material(self, x_bot_left, y_bot_left, x_top_right, y_top_right,
n_material, angle=0):
'''
A low-level function that allows writing a rectangle refractive
index profile to a `Structure`.
Args:
x_bot_left (float): The bottom-left x-coordinate of ... | [
"def",
"_add_material",
"(",
"self",
",",
"x_bot_left",
",",
"y_bot_left",
",",
"x_top_right",
",",
"y_top_right",
",",
"n_material",
",",
"angle",
"=",
"0",
")",
":",
"x_mask",
"=",
"np",
".",
"logical_and",
"(",
"x_bot_left",
"<=",
"self",
".",
"x",
",... | A low-level function that allows writing a rectangle refractive
index profile to a `Structure`.
Args:
x_bot_left (float): The bottom-left x-coordinate of the
rectangle.
y_bot_left (float): The bottom-left y-coordinate of the
rectangle.
... | [
"A",
"low",
"-",
"level",
"function",
"that",
"allows",
"writing",
"a",
"rectangle",
"refractive",
"index",
"profile",
"to",
"a",
"Structure",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L207-L239 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | _AbstractStructure.write_to_file | def write_to_file(self, filename='material_index.dat', plot=True):
'''
Write the refractive index profile to file.
Args:
filename (str): The nominal filename the refractive
index data should be saved to.
plot (bool): `True` if plots should be generates,
... | python | def write_to_file(self, filename='material_index.dat', plot=True):
'''
Write the refractive index profile to file.
Args:
filename (str): The nominal filename the refractive
index data should be saved to.
plot (bool): `True` if plots should be generates,
... | [
"def",
"write_to_file",
"(",
"self",
",",
"filename",
"=",
"'material_index.dat'",
",",
"plot",
"=",
"True",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"sys",
".",
"modules",
"[",
"__name__",
"]",
".",
"__file__",
")",
"+",
"'/'",
... | Write the refractive index profile to file.
Args:
filename (str): The nominal filename the refractive
index data should be saved to.
plot (bool): `True` if plots should be generates,
otherwise `False`. Default is `True`. | [
"Write",
"the",
"refractive",
"index",
"profile",
"to",
"file",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L241-L285 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | Slabs.add_slab | def add_slab(self, height, n_background=1., position='top'):
'''
Creates and adds a :class:`Slab` object.
Args:
height (float): Height of the slab.
n_background (float): The nominal refractive
index of the slab. Default is 1 (air).
Returns:
... | python | def add_slab(self, height, n_background=1., position='top'):
'''
Creates and adds a :class:`Slab` object.
Args:
height (float): Height of the slab.
n_background (float): The nominal refractive
index of the slab. Default is 1 (air).
Returns:
... | [
"def",
"add_slab",
"(",
"self",
",",
"height",
",",
"n_background",
"=",
"1.",
",",
"position",
"=",
"'top'",
")",
":",
"assert",
"position",
"in",
"(",
"'top'",
",",
"'bottom'",
")",
"name",
"=",
"str",
"(",
"self",
".",
"slab_count",
")",
"if",
"no... | Creates and adds a :class:`Slab` object.
Args:
height (float): Height of the slab.
n_background (float): The nominal refractive
index of the slab. Default is 1 (air).
Returns:
str: The name of the slab. | [
"Creates",
"and",
"adds",
"a",
":",
"class",
":",
"Slab",
"object",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L351-L390 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | Slabs.change_wavelength | def change_wavelength(self, wavelength):
'''
Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wav... | python | def change_wavelength(self, wavelength):
'''
Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wav... | [
"def",
"change_wavelength",
"(",
"self",
",",
"wavelength",
")",
":",
"for",
"name",
",",
"slab",
"in",
"self",
".",
"slabs",
".",
"items",
"(",
")",
":",
"const_args",
"=",
"slab",
".",
"_const_args",
"mat_args",
"=",
"slab",
".",
"_mat_params",
"const_... | Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wavelength. | [
"Changes",
"the",
"wavelength",
"of",
"the",
"structure",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L392-L415 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | Slabs.n | def n(self):
'''
np.array: The refractive index profile matrix
of the current slab.
'''
try:
n_mat = self.slabs['0'].n
for s in range(1, self.slab_count):
n_mat = np.vstack((self.slabs[str(s)].n, n_mat))
except KeyError:
... | python | def n(self):
'''
np.array: The refractive index profile matrix
of the current slab.
'''
try:
n_mat = self.slabs['0'].n
for s in range(1, self.slab_count):
n_mat = np.vstack((self.slabs[str(s)].n, n_mat))
except KeyError:
... | [
"def",
"n",
"(",
"self",
")",
":",
"try",
":",
"n_mat",
"=",
"self",
".",
"slabs",
"[",
"'0'",
"]",
".",
"n",
"for",
"s",
"in",
"range",
"(",
"1",
",",
"self",
".",
"slab_count",
")",
":",
"n_mat",
"=",
"np",
".",
"vstack",
"(",
"(",
"self",
... | np.array: The refractive index profile matrix
of the current slab. | [
"np",
".",
"array",
":",
"The",
"refractive",
"index",
"profile",
"matrix",
"of",
"the",
"current",
"slab",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L418-L429 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | Slab.add_material | def add_material(self, x_min, x_max, n, angle=0):
'''
Add a refractive index between two x-points.
Args:
x_min (float): The start x-point.
x_max (float): The stop x-point.
n (float, function): Refractive index between
`x_min` and `x_max`. E... | python | def add_material(self, x_min, x_max, n, angle=0):
'''
Add a refractive index between two x-points.
Args:
x_min (float): The start x-point.
x_max (float): The stop x-point.
n (float, function): Refractive index between
`x_min` and `x_max`. E... | [
"def",
"add_material",
"(",
"self",
",",
"x_min",
",",
"x_max",
",",
"n",
",",
"angle",
"=",
"0",
")",
":",
"self",
".",
"_mat_params",
".",
"append",
"(",
"[",
"x_min",
",",
"x_max",
",",
"n",
",",
"angle",
"]",
")",
"if",
"not",
"callable",
"("... | Add a refractive index between two x-points.
Args:
x_min (float): The start x-point.
x_max (float): The stop x-point.
n (float, function): Refractive index between
`x_min` and `x_max`. Either a constant (`float`), or
a function that accept... | [
"Add",
"a",
"refractive",
"index",
"between",
"two",
"x",
"-",
"points",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L479-L505 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | StructureAni.write_to_file | def write_to_file(self, filename='material_index.dat', plot=True):
'''
Write the refractive index profile to file.
Args:
filename (str): The nominal filename the refractive
index data should be saved to.
plot (bool): `True` if plots should be generates,
... | python | def write_to_file(self, filename='material_index.dat', plot=True):
'''
Write the refractive index profile to file.
Args:
filename (str): The nominal filename the refractive
index data should be saved to.
plot (bool): `True` if plots should be generates,
... | [
"def",
"write_to_file",
"(",
"self",
",",
"filename",
"=",
"'material_index.dat'",
",",
"plot",
"=",
"True",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"sys",
".",
"modules",
"[",
"__name__",
"]",
".",
"__file__",
")",
"+",
"'/'",
... | Write the refractive index profile to file.
Args:
filename (str): The nominal filename the refractive
index data should be saved to.
plot (bool): `True` if plots should be generates,
otherwise `False`. Default is `True`. | [
"Write",
"the",
"refractive",
"index",
"profile",
"to",
"file",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L666-L716 |
jtambasco/modesolverpy | modesolverpy/structure_base.py | StructureAni.change_wavelength | def change_wavelength(self, wavelength):
'''
Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wav... | python | def change_wavelength(self, wavelength):
'''
Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wav... | [
"def",
"change_wavelength",
"(",
"self",
",",
"wavelength",
")",
":",
"for",
"axis",
"in",
"self",
".",
"axes",
":",
"if",
"issubclass",
"(",
"type",
"(",
"axis",
")",
",",
"Slabs",
")",
":",
"axis",
".",
"change_wavelength",
"(",
"wavelength",
")",
"s... | Changes the wavelength of the structure.
This will affect the mode solver and potentially
the refractive indices used (provided functions
were provided as refractive indices).
Args:
wavelength (float): The new wavelength. | [
"Changes",
"the",
"wavelength",
"of",
"the",
"structure",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L718-L733 |
toomore/goristock | grs/mobileapi.py | covstr | def covstr(s):
""" convert string to int or float. """
try:
ret = int(s)
except ValueError:
ret = float(s)
return ret | python | def covstr(s):
""" convert string to int or float. """
try:
ret = int(s)
except ValueError:
ret = float(s)
return ret | [
"def",
"covstr",
"(",
"s",
")",
":",
"try",
":",
"ret",
"=",
"int",
"(",
"s",
")",
"except",
"ValueError",
":",
"ret",
"=",
"float",
"(",
"s",
")",
"return",
"ret"
] | convert string to int or float. | [
"convert",
"string",
"to",
"int",
"or",
"float",
"."
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/mobileapi.py#L25-L31 |
toomore/goristock | grs/mobileapi.py | mapi.output | def output(self):
#re = "{%(time)s} %(name)s %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s" % {
'''
re = """<table>
<tr><td>%(name)s</td><td>%(c)s</td><td>%(range)+.2f(%(pp)+.2f%%)</td></tr>
<tr><td>%(stock_no)s</td><td>%(value)s</td><td>%(time)s</td></tr></table>""" % {
... | python | def output(self):
#re = "{%(time)s} %(name)s %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s" % {
'''
re = """<table>
<tr><td>%(name)s</td><td>%(c)s</td><td>%(range)+.2f(%(pp)+.2f%%)</td></tr>
<tr><td>%(stock_no)s</td><td>%(value)s</td><td>%(time)s</td></tr></table>""" % {
... | [
"def",
"output",
"(",
"self",
")",
":",
"#re = \"{%(time)s} %(name)s %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s\" % {",
"if",
"covstr",
"(",
"self",
".",
"g",
"[",
"'range'",
"]",
")",
">",
"0",
":",
"css",
"=",
"\"red\"",
"elif",
"covstr",
"(",
"self"... | re = """<table>
<tr><td>%(name)s</td><td>%(c)s</td><td>%(range)+.2f(%(pp)+.2f%%)</td></tr>
<tr><td>%(stock_no)s</td><td>%(value)s</td><td>%(time)s</td></tr></table>""" % { | [
"re",
"=",
"<table",
">",
"<tr",
">",
"<td",
">",
"%",
"(",
"name",
")",
"s<",
"/",
"td",
">",
"<td",
">",
"%",
"(",
"c",
")",
"s<",
"/",
"td",
">",
"<td",
">",
"%",
"(",
"range",
")",
"+",
".",
"2f",
"(",
"%",
"(",
"pp",
")",
"+",
".... | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/mobileapi.py#L38-L72 |
toomore/goristock | grs/goristock.py | Rt_display | def Rt_display(stock_no):
""" For real time stock display
即時盤用,顯示目前查詢各股的股價資訊。
"""
a = twsk(stock_no).real
if a:
re = "{%(time)s} %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s" % {
'stock_no': stock_no,
'time': a['time'],
'c': a['c'],
'range': covstr(a['range'])... | python | def Rt_display(stock_no):
""" For real time stock display
即時盤用,顯示目前查詢各股的股價資訊。
"""
a = twsk(stock_no).real
if a:
re = "{%(time)s} %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s" % {
'stock_no': stock_no,
'time': a['time'],
'c': a['c'],
'range': covstr(a['range'])... | [
"def",
"Rt_display",
"(",
"stock_no",
")",
":",
"a",
"=",
"twsk",
"(",
"stock_no",
")",
".",
"real",
"if",
"a",
":",
"re",
"=",
"\"{%(time)s} %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s\"",
"%",
"{",
"'stock_no'",
":",
"stock_no",
",",
"'time'",
":",
... | For real time stock display
即時盤用,顯示目前查詢各股的股價資訊。 | [
"For",
"real",
"time",
"stock",
"display",
"即時盤用,顯示目前查詢各股的股價資訊。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L761-L777 |
toomore/goristock | grs/goristock.py | goristock.ckinv | def ckinv(self,oo):
""" check the value is date or not
檢查是否為日期格式
"""
pattern = re.compile(r"[0-9]{2}/[0-9]{2}/[0-9]{2}")
b = re.search(pattern, oo[0])
try:
b.group()
return True
except:
return False | python | def ckinv(self,oo):
""" check the value is date or not
檢查是否為日期格式
"""
pattern = re.compile(r"[0-9]{2}/[0-9]{2}/[0-9]{2}")
b = re.search(pattern, oo[0])
try:
b.group()
return True
except:
return False | [
"def",
"ckinv",
"(",
"self",
",",
"oo",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"[0-9]{2}/[0-9]{2}/[0-9]{2}\"",
")",
"b",
"=",
"re",
".",
"search",
"(",
"pattern",
",",
"oo",
"[",
"0",
"]",
")",
"try",
":",
"b",
".",
"group",
"(",
... | check the value is date or not
檢查是否為日期格式 | [
"check",
"the",
"value",
"is",
"date",
"or",
"not",
"檢查是否為日期格式"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L135-L145 |
toomore/goristock | grs/goristock.py | goristock.high_or_low | def high_or_low(self,one,two,rev=0):
""" Return ↑↓- for high, low or equal.
回傳漲跌標示
rev = 0
回傳 ↑↓-
rev = 1
回傳 1 -1 0
"""
if rev == 0:
if one > two:
re = '↑'.decode('utf-8')
elif one < two:
re = '↓'.decode('utf-8')
else:
re ... | python | def high_or_low(self,one,two,rev=0):
""" Return ↑↓- for high, low or equal.
回傳漲跌標示
rev = 0
回傳 ↑↓-
rev = 1
回傳 1 -1 0
"""
if rev == 0:
if one > two:
re = '↑'.decode('utf-8')
elif one < two:
re = '↓'.decode('utf-8')
else:
re ... | [
"def",
"high_or_low",
"(",
"self",
",",
"one",
",",
"two",
",",
"rev",
"=",
"0",
")",
":",
"if",
"rev",
"==",
"0",
":",
"if",
"one",
">",
"two",
":",
"re",
"=",
"'↑'.d",
"e",
"code('",
"u",
"tf-8')",
"",
"elif",
"one",
"<",
"two",
":",
"re",
... | Return ↑↓- for high, low or equal.
回傳漲跌標示
rev = 0
回傳 ↑↓-
rev = 1
回傳 1 -1 0 | [
"Return",
"↑↓",
"-",
"for",
"high",
"low",
"or",
"equal",
".",
"回傳漲跌標示",
"rev",
"=",
"0",
"回傳",
"↑↓",
"-",
"rev",
"=",
"1",
"回傳",
"1",
"-",
"1",
"0"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L147-L169 |
toomore/goristock | grs/goristock.py | goristock.goback | def goback(self,days = 1):
""" Go back days
刪除最新天數資料數據
days 代表刪除多少天數(倒退幾天)
"""
for i in xrange(days):
self.raw_data.pop()
self.data_date.pop()
self.stock_range.pop()
self.stock_vol.pop()
self.stock_open.pop()
self.stock_h.pop()
self.stock_l.pop() | python | def goback(self,days = 1):
""" Go back days
刪除最新天數資料數據
days 代表刪除多少天數(倒退幾天)
"""
for i in xrange(days):
self.raw_data.pop()
self.data_date.pop()
self.stock_range.pop()
self.stock_vol.pop()
self.stock_open.pop()
self.stock_h.pop()
self.stock_l.pop() | [
"def",
"goback",
"(",
"self",
",",
"days",
"=",
"1",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"days",
")",
":",
"self",
".",
"raw_data",
".",
"pop",
"(",
")",
"self",
".",
"data_date",
".",
"pop",
"(",
")",
"self",
".",
"stock_range",
".",
"p... | Go back days
刪除最新天數資料數據
days 代表刪除多少天數(倒退幾天) | [
"Go",
"back",
"days",
"刪除最新天數資料數據",
"days",
"代表刪除多少天數(倒退幾天)"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L171-L183 |
toomore/goristock | grs/goristock.py | goristock.fetch_data | def fetch_data(self, stock_no, nowdatetime, firsttime = 1):
""" Fetch data from twse.com.tw
return list.
從 twse.com.tw 下載資料,回傳格式為 list
"""
url = 'http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report%(year)d%(mon)02d/%(year)d%(mon)02d_F3_1_8_%(stock)... | python | def fetch_data(self, stock_no, nowdatetime, firsttime = 1):
""" Fetch data from twse.com.tw
return list.
從 twse.com.tw 下載資料,回傳格式為 list
"""
url = 'http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report%(year)d%(mon)02d/%(year)d%(mon)02d_F3_1_8_%(stock)... | [
"def",
"fetch_data",
"(",
"self",
",",
"stock_no",
",",
"nowdatetime",
",",
"firsttime",
"=",
"1",
")",
":",
"url",
"=",
"'http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/STOCK_DAY_print.php?genpage=genpage/Report%(year)d%(mon)02d/%(year)d%(mon)02d_F3_1_8_%(stock)s.php&type=csv&... | Fetch data from twse.com.tw
return list.
從 twse.com.tw 下載資料,回傳格式為 list | [
"Fetch",
"data",
"from",
"twse",
".",
"com",
".",
"tw",
"return",
"list",
".",
"從",
"twse",
".",
"com",
".",
"tw",
"下載資料,回傳格式為",
"list"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L186-L231 |
toomore/goristock | grs/goristock.py | goristock.list_data | def list_data(self, csv_read):
""" 將資料 list 化
return dictionary:
[stock_price]: Closing price (list)
收盤價格
[stock_name]: Stock name (str) and encode form big5 to utf-8
該股名稱,big5 → UTF-8
[data_date]: Stock date (list)
... | python | def list_data(self, csv_read):
""" 將資料 list 化
return dictionary:
[stock_price]: Closing price (list)
收盤價格
[stock_name]: Stock name (str) and encode form big5 to utf-8
該股名稱,big5 → UTF-8
[data_date]: Stock date (list)
... | [
"def",
"list_data",
"(",
"self",
",",
"csv_read",
")",
":",
"getr",
"=",
"[",
"]",
"getdate",
"=",
"[",
"]",
"getrange",
"=",
"[",
"]",
"getvol",
"=",
"[",
"]",
"getopen",
"=",
"[",
"]",
"geth",
"=",
"[",
"]",
"getl",
"=",
"[",
"]",
"otherinfo"... | 將資料 list 化
return dictionary:
[stock_price]: Closing price (list)
收盤價格
[stock_name]: Stock name (str) and encode form big5 to utf-8
該股名稱,big5 → UTF-8
[data_date]: Stock date (list)
數據日期資訊
[stock... | [
"將資料",
"list",
"化",
"return",
"dictionary",
":",
"[",
"stock_price",
"]",
":",
"Closing",
"price",
"(",
"list",
")",
"收盤價格",
"[",
"stock_name",
"]",
":",
"Stock",
"name",
"(",
"str",
")",
"and",
"encode",
"form",
"big5",
"to",
"utf",
"-",
"8",
"該股名稱,... | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L233-L295 |
toomore/goristock | grs/goristock.py | goristock.range_per | def range_per(self):
""" Range percentage
計算最新日之漲跌幅度百分比
"""
rp = float((self.raw_data[-1] - self.raw_data[-2]) / self.raw_data[-2] * 100)
return rp | python | def range_per(self):
""" Range percentage
計算最新日之漲跌幅度百分比
"""
rp = float((self.raw_data[-1] - self.raw_data[-2]) / self.raw_data[-2] * 100)
return rp | [
"def",
"range_per",
"(",
"self",
")",
":",
"rp",
"=",
"float",
"(",
"(",
"self",
".",
"raw_data",
"[",
"-",
"1",
"]",
"-",
"self",
".",
"raw_data",
"[",
"-",
"2",
"]",
")",
"/",
"self",
".",
"raw_data",
"[",
"-",
"2",
"]",
"*",
"100",
")",
... | Range percentage
計算最新日之漲跌幅度百分比 | [
"Range",
"percentage",
"計算最新日之漲跌幅度百分比"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L323-L328 |
toomore/goristock | grs/goristock.py | goristock.SD | def SD(self, days=45):
""" Standard Deviation.
計算 days 日內之標準差,預設 45 日
"""
if len(self.raw_data) >= days:
data = self.raw_data[-days:]
data_avg = float(sum(data) / days)
data2 = []
for x in data:
data2.append((x - data_avg ) ** 2)
return math.sqrt(sum(data2) / l... | python | def SD(self, days=45):
""" Standard Deviation.
計算 days 日內之標準差,預設 45 日
"""
if len(self.raw_data) >= days:
data = self.raw_data[-days:]
data_avg = float(sum(data) / days)
data2 = []
for x in data:
data2.append((x - data_avg ) ** 2)
return math.sqrt(sum(data2) / l... | [
"def",
"SD",
"(",
"self",
",",
"days",
"=",
"45",
")",
":",
"if",
"len",
"(",
"self",
".",
"raw_data",
")",
">=",
"days",
":",
"data",
"=",
"self",
".",
"raw_data",
"[",
"-",
"days",
":",
"]",
"data_avg",
"=",
"float",
"(",
"sum",
"(",
"data",
... | Standard Deviation.
計算 days 日內之標準差,預設 45 日 | [
"Standard",
"Deviation",
".",
"計算",
"days",
"日內之標準差,預設",
"45",
"日"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L352-L365 |
toomore/goristock | grs/goristock.py | goristock.SDAVG | def SDAVG(self, days=45):
""" the last 45 days average.
計算 days 日內之平均數,預設 45 日
"""
if len(self.raw_data) >= days:
data = self.raw_data[-days:]
data_avg = float(sum(data) / days)
return data_avg
else:
return 0 | python | def SDAVG(self, days=45):
""" the last 45 days average.
計算 days 日內之平均數,預設 45 日
"""
if len(self.raw_data) >= days:
data = self.raw_data[-days:]
data_avg = float(sum(data) / days)
return data_avg
else:
return 0 | [
"def",
"SDAVG",
"(",
"self",
",",
"days",
"=",
"45",
")",
":",
"if",
"len",
"(",
"self",
".",
"raw_data",
")",
">=",
"days",
":",
"data",
"=",
"self",
".",
"raw_data",
"[",
"-",
"days",
":",
"]",
"data_avg",
"=",
"float",
"(",
"sum",
"(",
"data... | the last 45 days average.
計算 days 日內之平均數,預設 45 日 | [
"the",
"last",
"45",
"days",
"average",
".",
"計算",
"days",
"日內之平均數,預設",
"45",
"日"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L368-L377 |
toomore/goristock | grs/goristock.py | goristock.CV | def CV(self, days=45):
""" Coefficient of Variation.
計算 days 日內之變異數,預設 45 日
"""
if len(self.raw_data) >= days:
data_avg = sum(self.raw_data[-days:]) / days
return self.SD / data_avg
else:
return 0 | python | def CV(self, days=45):
""" Coefficient of Variation.
計算 days 日內之變異數,預設 45 日
"""
if len(self.raw_data) >= days:
data_avg = sum(self.raw_data[-days:]) / days
return self.SD / data_avg
else:
return 0 | [
"def",
"CV",
"(",
"self",
",",
"days",
"=",
"45",
")",
":",
"if",
"len",
"(",
"self",
".",
"raw_data",
")",
">=",
"days",
":",
"data_avg",
"=",
"sum",
"(",
"self",
".",
"raw_data",
"[",
"-",
"days",
":",
"]",
")",
"/",
"days",
"return",
"self",... | Coefficient of Variation.
計算 days 日內之變異數,預設 45 日 | [
"Coefficient",
"of",
"Variation",
".",
"計算",
"days",
"日內之變異數,預設",
"45",
"日"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L380-L388 |
toomore/goristock | grs/goristock.py | goristock.TimeinOpen | def TimeinOpen(self):
""" In open market time.
在當日開市時刻,9 - 14
"""
now = TWTime().now.hour
if now >= 9 and now <= 14:
return True
else:
return False | python | def TimeinOpen(self):
""" In open market time.
在當日開市時刻,9 - 14
"""
now = TWTime().now.hour
if now >= 9 and now <= 14:
return True
else:
return False | [
"def",
"TimeinOpen",
"(",
"self",
")",
":",
"now",
"=",
"TWTime",
"(",
")",
".",
"now",
".",
"hour",
"if",
"now",
">=",
"9",
"and",
"now",
"<=",
"14",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | In open market time.
在當日開市時刻,9 - 14 | [
"In",
"open",
"market",
"time",
".",
"在當日開市時刻,9",
"-",
"14"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L391-L399 |
toomore/goristock | grs/goristock.py | goristock.MAC | def MAC(self,days,rev = 0):
""" Comparing yesterday price is high, low or equal.
return ↑,↓ or -
與前一天 days 日收盤價移動平均比較
rev = 0
回傳 ↑,↓ or -
rev = 1
回傳 1,-1 or 0
"""
yesterday = self.raw_data[:]
yesterday.pop()
yes_MA = float(sum(yesterday[-days:]) / ... | python | def MAC(self,days,rev = 0):
""" Comparing yesterday price is high, low or equal.
return ↑,↓ or -
與前一天 days 日收盤價移動平均比較
rev = 0
回傳 ↑,↓ or -
rev = 1
回傳 1,-1 or 0
"""
yesterday = self.raw_data[:]
yesterday.pop()
yes_MA = float(sum(yesterday[-days:]) / ... | [
"def",
"MAC",
"(",
"self",
",",
"days",
",",
"rev",
"=",
"0",
")",
":",
"yesterday",
"=",
"self",
".",
"raw_data",
"[",
":",
"]",
"yesterday",
".",
"pop",
"(",
")",
"yes_MA",
"=",
"float",
"(",
"sum",
"(",
"yesterday",
"[",
"-",
"days",
":",
"]... | Comparing yesterday price is high, low or equal.
return ↑,↓ or -
與前一天 days 日收盤價移動平均比較
rev = 0
回傳 ↑,↓ or -
rev = 1
回傳 1,-1 or 0 | [
"Comparing",
"yesterday",
"price",
"is",
"high",
"low",
"or",
"equal",
".",
"return",
"↑",
"↓",
"or",
"-",
"與前一天",
"days",
"日收盤價移動平均比較",
"rev",
"=",
"0",
"回傳",
"↑",
"↓",
"or",
"-",
"rev",
"=",
"1",
"回傳",
"1",
"-",
"1",
"or",
"0"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L409-L423 |
toomore/goristock | grs/goristock.py | goristock.MA_serial | def MA_serial(self,days,rev=0):
""" see make_serial()
收盤價移動平均 list 化,資料格式請見 def make_serial()
"""
return self.make_serial(self.raw_data,days,rev) | python | def MA_serial(self,days,rev=0):
""" see make_serial()
收盤價移動平均 list 化,資料格式請見 def make_serial()
"""
return self.make_serial(self.raw_data,days,rev) | [
"def",
"MA_serial",
"(",
"self",
",",
"days",
",",
"rev",
"=",
"0",
")",
":",
"return",
"self",
".",
"make_serial",
"(",
"self",
".",
"raw_data",
",",
"days",
",",
"rev",
")"
] | see make_serial()
收盤價移動平均 list 化,資料格式請見 def make_serial() | [
"see",
"make_serial",
"()",
"收盤價移動平均",
"list",
"化,資料格式請見",
"def",
"make_serial",
"()"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L425-L429 |
toomore/goristock | grs/goristock.py | goristock.MACVOL | def MACVOL(self,days,rev=0):
""" Comparing yesterday volume is high, low or equal.
return ↑,↓ or -
與前一天 days 日成交量移動平均比較
rev = 0
回傳 ↑,↓ or -
rev = 1
回傳 1,-1 or 0
"""
yesterday = self.stock_vol[:]
yesterday.pop()
yes_MAVOL = float(sum(yesterday[-days... | python | def MACVOL(self,days,rev=0):
""" Comparing yesterday volume is high, low or equal.
return ↑,↓ or -
與前一天 days 日成交量移動平均比較
rev = 0
回傳 ↑,↓ or -
rev = 1
回傳 1,-1 or 0
"""
yesterday = self.stock_vol[:]
yesterday.pop()
yes_MAVOL = float(sum(yesterday[-days... | [
"def",
"MACVOL",
"(",
"self",
",",
"days",
",",
"rev",
"=",
"0",
")",
":",
"yesterday",
"=",
"self",
".",
"stock_vol",
"[",
":",
"]",
"yesterday",
".",
"pop",
"(",
")",
"yes_MAVOL",
"=",
"float",
"(",
"sum",
"(",
"yesterday",
"[",
"-",
"days",
":... | Comparing yesterday volume is high, low or equal.
return ↑,↓ or -
與前一天 days 日成交量移動平均比較
rev = 0
回傳 ↑,↓ or -
rev = 1
回傳 1,-1 or 0 | [
"Comparing",
"yesterday",
"volume",
"is",
"high",
"low",
"or",
"equal",
".",
"return",
"↑",
"↓",
"or",
"-",
"與前一天",
"days",
"日成交量移動平均比較",
"rev",
"=",
"0",
"回傳",
"↑",
"↓",
"or",
"-",
"rev",
"=",
"1",
"回傳",
"1",
"-",
"1",
"or",
"0"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L439-L453 |
toomore/goristock | grs/goristock.py | goristock.MAVOL_serial | def MAVOL_serial(self,days,rev=0):
""" see make_serial()
成較量移動平均 list 化,資料格式請見 def make_serial()
"""
return self.make_serial(self.stock_vol,days,rev=0) | python | def MAVOL_serial(self,days,rev=0):
""" see make_serial()
成較量移動平均 list 化,資料格式請見 def make_serial()
"""
return self.make_serial(self.stock_vol,days,rev=0) | [
"def",
"MAVOL_serial",
"(",
"self",
",",
"days",
",",
"rev",
"=",
"0",
")",
":",
"return",
"self",
".",
"make_serial",
"(",
"self",
".",
"stock_vol",
",",
"days",
",",
"rev",
"=",
"0",
")"
] | see make_serial()
成較量移動平均 list 化,資料格式請見 def make_serial() | [
"see",
"make_serial",
"()",
"成較量移動平均",
"list",
"化,資料格式請見",
"def",
"make_serial",
"()"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L455-L459 |
toomore/goristock | grs/goristock.py | goristock.VOLMAX3 | def VOLMAX3(self):
""" Volume is the max in last 3 days.
三日內最大成交量
"""
if self.stock_vol[-1] > self.stock_vol[-2] and self.stock_vol[-1] > self.stock_vol[-3]:
return True
else:
return False | python | def VOLMAX3(self):
""" Volume is the max in last 3 days.
三日內最大成交量
"""
if self.stock_vol[-1] > self.stock_vol[-2] and self.stock_vol[-1] > self.stock_vol[-3]:
return True
else:
return False | [
"def",
"VOLMAX3",
"(",
"self",
")",
":",
"if",
"self",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"self",
".",
"stock_vol",
"[",
"-",
"2",
"]",
"and",
"self",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"self",
".",
"stock_vol",
"[",
"-",
"3",
... | Volume is the max in last 3 days.
三日內最大成交量 | [
"Volume",
"is",
"the",
"max",
"in",
"last",
"3",
"days",
".",
"三日內最大成交量"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L462-L469 |
toomore/goristock | grs/goristock.py | goristock.MAO | def MAO(self,day1,day2,rev=0):
""" This is MAO(Moving Average Oscillator), not BIAS.
It's only 'MAday1 - MAday2'.
乖離率,MAday1 - MAday2 兩日之移動平均之差
return list:
[0] is the times of high, low or equal
[0] is times
[1] is the MAO data
[1] rev=0:↑ ↓ or -,rev=1:1... | python | def MAO(self,day1,day2,rev=0):
""" This is MAO(Moving Average Oscillator), not BIAS.
It's only 'MAday1 - MAday2'.
乖離率,MAday1 - MAday2 兩日之移動平均之差
return list:
[0] is the times of high, low or equal
[0] is times
[1] is the MAO data
[1] rev=0:↑ ↓ or -,rev=1:1... | [
"def",
"MAO",
"(",
"self",
",",
"day1",
",",
"day2",
",",
"rev",
"=",
"0",
")",
":",
"day1MA",
"=",
"self",
".",
"MA_serial",
"(",
"day1",
")",
"[",
"1",
"]",
"day2MA",
"=",
"self",
".",
"MA_serial",
"(",
"day2",
")",
"[",
"1",
"]",
"bw",
"="... | This is MAO(Moving Average Oscillator), not BIAS.
It's only 'MAday1 - MAday2'.
乖離率,MAday1 - MAday2 兩日之移動平均之差
return list:
[0] is the times of high, low or equal
[0] is times
[1] is the MAO data
[1] rev=0:↑ ↓ or -,rev=1:1 -1 0
回傳:
[0]
... | [
"This",
"is",
"MAO",
"(",
"Moving",
"Average",
"Oscillator",
")",
"not",
"BIAS",
".",
"It",
"s",
"only",
"MAday1",
"-",
"MAday2",
".",
"乖離率,MAday1",
"-",
"MAday2",
"兩日之移動平均之差"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L472-L508 |
toomore/goristock | grs/goristock.py | goristock.ckMAO | def ckMAO(self,data,s=5,pm=False):
"""判斷正負乖離位置
s = 取樣判斷區間
pm = True(正)/False(負) 乖離
return [T/F, 第幾個轉折日, 乖離值]
"""
c = data[-s:]
if pm:
ckvalue = max(c)
preckvalue = max(c) > 0
else:
ckvalue = min(c)
preckvalue = max(c) < 0
return [s - c.index(ckvalue... | python | def ckMAO(self,data,s=5,pm=False):
"""判斷正負乖離位置
s = 取樣判斷區間
pm = True(正)/False(負) 乖離
return [T/F, 第幾個轉折日, 乖離值]
"""
c = data[-s:]
if pm:
ckvalue = max(c)
preckvalue = max(c) > 0
else:
ckvalue = min(c)
preckvalue = max(c) < 0
return [s - c.index(ckvalue... | [
"def",
"ckMAO",
"(",
"self",
",",
"data",
",",
"s",
"=",
"5",
",",
"pm",
"=",
"False",
")",
":",
"c",
"=",
"data",
"[",
"-",
"s",
":",
"]",
"if",
"pm",
":",
"ckvalue",
"=",
"max",
"(",
"c",
")",
"preckvalue",
"=",
"max",
"(",
"c",
")",
">... | 判斷正負乖離位置
s = 取樣判斷區間
pm = True(正)/False(負) 乖離
return [T/F, 第幾個轉折日, 乖離值] | [
"判斷正負乖離位置",
"s",
"=",
"取樣判斷區間",
"pm",
"=",
"True(正)",
"/",
"False(負)",
"乖離",
"return",
"[",
"T",
"/",
"F",
"第幾個轉折日",
"乖離值",
"]"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L511-L526 |
toomore/goristock | grs/goristock.py | goristock.RABC | def RABC(self):
""" Return ABC
轉折點 ABC
"""
A = self.raw_data[-3]*2 - self.raw_data[-6]
B = self.raw_data[-2]*2 - self.raw_data[-5]
C = self.raw_data[-1]*2 - self.raw_data[-4]
return '(%.2f,%.2f,%.2f)' % (A,B,C) | python | def RABC(self):
""" Return ABC
轉折點 ABC
"""
A = self.raw_data[-3]*2 - self.raw_data[-6]
B = self.raw_data[-2]*2 - self.raw_data[-5]
C = self.raw_data[-1]*2 - self.raw_data[-4]
return '(%.2f,%.2f,%.2f)' % (A,B,C) | [
"def",
"RABC",
"(",
"self",
")",
":",
"A",
"=",
"self",
".",
"raw_data",
"[",
"-",
"3",
"]",
"*",
"2",
"-",
"self",
".",
"raw_data",
"[",
"-",
"6",
"]",
"B",
"=",
"self",
".",
"raw_data",
"[",
"-",
"2",
"]",
"*",
"2",
"-",
"self",
".",
"r... | Return ABC
轉折點 ABC | [
"Return",
"ABC",
"轉折點",
"ABC"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L530-L537 |
toomore/goristock | grs/goristock.py | goristock.make_serial | def make_serial(self,data,days,rev=0):
""" make data in list
if data enough, will return:
[0] is the times of high, low or equal
[1] is the serial of data.
or return '?'
資料數據 list 化,days 移動平均值
[0] 回傳次數
[1] 回傳數據
"""
raw = data[:]
result = []
... | python | def make_serial(self,data,days,rev=0):
""" make data in list
if data enough, will return:
[0] is the times of high, low or equal
[1] is the serial of data.
or return '?'
資料數據 list 化,days 移動平均值
[0] 回傳次數
[1] 回傳數據
"""
raw = data[:]
result = []
... | [
"def",
"make_serial",
"(",
"self",
",",
"data",
",",
"days",
",",
"rev",
"=",
"0",
")",
":",
"raw",
"=",
"data",
"[",
":",
"]",
"result",
"=",
"[",
"]",
"try",
":",
"while",
"len",
"(",
"raw",
")",
">=",
"days",
":",
"result",
".",
"append",
... | make data in list
if data enough, will return:
[0] is the times of high, low or equal
[1] is the serial of data.
or return '?'
資料數據 list 化,days 移動平均值
[0] 回傳次數
[1] 回傳數據 | [
"make",
"data",
"in",
"list",
"if",
"data",
"enough",
"will",
"return",
":",
"[",
"0",
"]",
"is",
"the",
"times",
"of",
"high",
"low",
"or",
"equal",
"[",
"1",
"]",
"is",
"the",
"serial",
"of",
"data",
"."
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L540-L564 |
toomore/goristock | grs/goristock.py | goristock.cum_serial | def cum_serial(self, raw,rev=0):
""" Cumulate serial data
and return times(int)
計算數據重複(持續)次數
"""
org = raw[1:]
diff = raw[:-1]
result = []
for i in xrange(len(org)):
result.append(self.high_or_low(org[i], diff[i],rev))
times = 0
try:
if result[-1] == result[-... | python | def cum_serial(self, raw,rev=0):
""" Cumulate serial data
and return times(int)
計算數據重複(持續)次數
"""
org = raw[1:]
diff = raw[:-1]
result = []
for i in xrange(len(org)):
result.append(self.high_or_low(org[i], diff[i],rev))
times = 0
try:
if result[-1] == result[-... | [
"def",
"cum_serial",
"(",
"self",
",",
"raw",
",",
"rev",
"=",
"0",
")",
":",
"org",
"=",
"raw",
"[",
"1",
":",
"]",
"diff",
"=",
"raw",
"[",
":",
"-",
"1",
"]",
"result",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"org",
... | Cumulate serial data
and return times(int)
計算數據重複(持續)次數 | [
"Cumulate",
"serial",
"data",
"and",
"return",
"times",
"(",
"int",
")",
"計算數據重複(持續)次數"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L566-L598 |
toomore/goristock | grs/goristock.py | goristock.display | def display(self,*arg):
""" For simple Demo
測試用顯示樣式。
"""
print self.stock_name,self.stock_no
print '%s %s %s(%+.2f%%)' % (self.data_date[-1],self.raw_data[-1],self.stock_range[-1],self.range_per)
for i in arg:
print ' - MA%02s %.2f %s(%s)' % (i,self.MA(i),self.MAC(i),self.MA_serial(i)... | python | def display(self,*arg):
""" For simple Demo
測試用顯示樣式。
"""
print self.stock_name,self.stock_no
print '%s %s %s(%+.2f%%)' % (self.data_date[-1],self.raw_data[-1],self.stock_range[-1],self.range_per)
for i in arg:
print ' - MA%02s %.2f %s(%s)' % (i,self.MA(i),self.MAC(i),self.MA_serial(i)... | [
"def",
"display",
"(",
"self",
",",
"*",
"arg",
")",
":",
"print",
"self",
".",
"stock_name",
",",
"self",
".",
"stock_no",
"print",
"'%s %s %s(%+.2f%%)'",
"%",
"(",
"self",
".",
"data_date",
"[",
"-",
"1",
"]",
",",
"self",
".",
"raw_data",
"[",
"-"... | For simple Demo
測試用顯示樣式。 | [
"For",
"simple",
"Demo",
"測試用顯示樣式。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L601-L612 |
toomore/goristock | grs/goristock.py | goristock.XMPP_display | def XMPP_display(self,*arg):
""" For XMPP Demo
輸出到 XMPP 之樣式。
"""
MA = ''
for i in arg:
MAs = '- MA%02s: %.2f %s(%s)\n' % (
unicode(i),
self.MA(i),
self.MAC(i),
unicode(self.MA_serial(i)[0])
)
MA = MA + MAs
vol = '- Volume: %s %s(%s)' % (
... | python | def XMPP_display(self,*arg):
""" For XMPP Demo
輸出到 XMPP 之樣式。
"""
MA = ''
for i in arg:
MAs = '- MA%02s: %.2f %s(%s)\n' % (
unicode(i),
self.MA(i),
self.MAC(i),
unicode(self.MA_serial(i)[0])
)
MA = MA + MAs
vol = '- Volume: %s %s(%s)' % (
... | [
"def",
"XMPP_display",
"(",
"self",
",",
"*",
"arg",
")",
":",
"MA",
"=",
"''",
"for",
"i",
"in",
"arg",
":",
"MAs",
"=",
"'- MA%02s: %.2f %s(%s)\\n'",
"%",
"(",
"unicode",
"(",
"i",
")",
",",
"self",
".",
"MA",
"(",
"i",
")",
",",
"self",
".",
... | For XMPP Demo
輸出到 XMPP 之樣式。 | [
"For",
"XMPP",
"Demo",
"輸出到",
"XMPP",
"之樣式。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L616-L658 |
toomore/goristock | grs/goristock.py | goristock.Task_display | def Task_display(self):
""" For Task overall stock display
顯示資訊樣式之一,兩行資訊。
"""
re = """%(stock_name)s %(stock_no)s %(stock_date)s
Today: %(stock_price)s %(stock_range)s
=-=-=-=""" % {
'stock_name': unicode(self.stock_name),
'stock_no': unicode(self.stock_no),
'stock_date': uni... | python | def Task_display(self):
""" For Task overall stock display
顯示資訊樣式之一,兩行資訊。
"""
re = """%(stock_name)s %(stock_no)s %(stock_date)s
Today: %(stock_price)s %(stock_range)s
=-=-=-=""" % {
'stock_name': unicode(self.stock_name),
'stock_no': unicode(self.stock_no),
'stock_date': uni... | [
"def",
"Task_display",
"(",
"self",
")",
":",
"re",
"=",
"\"\"\"%(stock_name)s %(stock_no)s %(stock_date)s\nToday: %(stock_price)s %(stock_range)s\n=-=-=-=\"\"\"",
"%",
"{",
"'stock_name'",
":",
"unicode",
"(",
"self",
".",
"stock_name",
")",
",",
"'stock_no'",
":",
"unic... | For Task overall stock display
顯示資訊樣式之一,兩行資訊。 | [
"For",
"Task",
"overall",
"stock",
"display",
"顯示資訊樣式之一,兩行資訊。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L662-L675 |
toomore/goristock | grs/goristock.py | goristock.Cmd_display | def Cmd_display(self):
""" For Task overall stock display
一行顯示資訊,用於終端機顯示樣式。
"""
re = "%(stock_no)s %(stock_name)s %(stock_date)s %(stock_price)s %(stock_range)s %(stock_range_per).2f%% %(RABC)s %(stock_vol)s" % {
'stock_name': unicode(self.stock_name),
'stock_no': unicode(self.stock_... | python | def Cmd_display(self):
""" For Task overall stock display
一行顯示資訊,用於終端機顯示樣式。
"""
re = "%(stock_no)s %(stock_name)s %(stock_date)s %(stock_price)s %(stock_range)s %(stock_range_per).2f%% %(RABC)s %(stock_vol)s" % {
'stock_name': unicode(self.stock_name),
'stock_no': unicode(self.stock_... | [
"def",
"Cmd_display",
"(",
"self",
")",
":",
"re",
"=",
"\"%(stock_no)s %(stock_name)s %(stock_date)s %(stock_price)s %(stock_range)s %(stock_range_per).2f%% %(RABC)s %(stock_vol)s\"",
"%",
"{",
"'stock_name'",
":",
"unicode",
"(",
"self",
".",
"stock_name",
")",
",",
"'stock... | For Task overall stock display
一行顯示資訊,用於終端機顯示樣式。 | [
"For",
"Task",
"overall",
"stock",
"display",
"一行顯示資訊,用於終端機顯示樣式。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L679-L693 |
toomore/goristock | grs/goristock.py | goristock.gchart | def gchart(self, s = 0, size = [], candle = 20):
""" Chart for serious stocks
輸出 Google Chart 圖表。
s = 資料筆數
size = 圖表寬度、高度 [寬度,高度]
candle = K 棒的寬度
"""
if s == 0:
s = len(self.raw_data)
if len(size) == 2:
sw,sh = size
else:
sh = 300
sw = 25 * s
... | python | def gchart(self, s = 0, size = [], candle = 20):
""" Chart for serious stocks
輸出 Google Chart 圖表。
s = 資料筆數
size = 圖表寬度、高度 [寬度,高度]
candle = K 棒的寬度
"""
if s == 0:
s = len(self.raw_data)
if len(size) == 2:
sw,sh = size
else:
sh = 300
sw = 25 * s
... | [
"def",
"gchart",
"(",
"self",
",",
"s",
"=",
"0",
",",
"size",
"=",
"[",
"]",
",",
"candle",
"=",
"20",
")",
":",
"if",
"s",
"==",
"0",
":",
"s",
"=",
"len",
"(",
"self",
".",
"raw_data",
")",
"if",
"len",
"(",
"size",
")",
"==",
"2",
":"... | Chart for serious stocks
輸出 Google Chart 圖表。
s = 資料筆數
size = 圖表寬度、高度 [寬度,高度]
candle = K 棒的寬度 | [
"Chart",
"for",
"serious",
"stocks",
"輸出",
"Google",
"Chart",
"圖表。",
"s",
"=",
"資料筆數",
"size",
"=",
"圖表寬度、高度",
"[",
"寬度",
"高度",
"]",
"candle",
"=",
"K",
"棒的寬度"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L696-L750 |
toomore/goristock | grs/BSR.py | BSR.buy | def buy(self, no, price, value):
''' 買 '''
self.money += -price*value
try:
self.store[no] += value
except:
self.store[no] = value
try:
self.avgprice[no]['buy'] += [price]
except:
try:
self.avgprice[no]['buy'] = [price]
except:
self.avgprice[no] = {}
... | python | def buy(self, no, price, value):
''' 買 '''
self.money += -price*value
try:
self.store[no] += value
except:
self.store[no] = value
try:
self.avgprice[no]['buy'] += [price]
except:
try:
self.avgprice[no]['buy'] = [price]
except:
self.avgprice[no] = {}
... | [
"def",
"buy",
"(",
"self",
",",
"no",
",",
"price",
",",
"value",
")",
":",
"self",
".",
"money",
"+=",
"-",
"price",
"*",
"value",
"try",
":",
"self",
".",
"store",
"[",
"no",
"]",
"+=",
"value",
"except",
":",
"self",
".",
"store",
"[",
"no",... | 買 | [
"買"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/BSR.py#L35-L49 |
toomore/goristock | grs/BSR.py | BSR.sell | def sell(self, no, price, value):
''' 賣 '''
self.money += price*value
try:
self.store[no] += -value
except:
self.store[no] = -value
try:
self.avgprice[no]['sell'] += [price]
except:
try:
self.avgprice[no]['sell'] = [price]
except:
self.avgprice[no] =... | python | def sell(self, no, price, value):
''' 賣 '''
self.money += price*value
try:
self.store[no] += -value
except:
self.store[no] = -value
try:
self.avgprice[no]['sell'] += [price]
except:
try:
self.avgprice[no]['sell'] = [price]
except:
self.avgprice[no] =... | [
"def",
"sell",
"(",
"self",
",",
"no",
",",
"price",
",",
"value",
")",
":",
"self",
".",
"money",
"+=",
"price",
"*",
"value",
"try",
":",
"self",
".",
"store",
"[",
"no",
"]",
"+=",
"-",
"value",
"except",
":",
"self",
".",
"store",
"[",
"no"... | 賣 | [
"賣"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/BSR.py#L51-L65 |
toomore/goristock | grs/BSR.py | BSR.showinfo | def showinfo(self):
''' 總覽顯示 '''
print 'money:',self.money
print 'store:',self.store
print 'avgprice:',self.avgprice | python | def showinfo(self):
''' 總覽顯示 '''
print 'money:',self.money
print 'store:',self.store
print 'avgprice:',self.avgprice | [
"def",
"showinfo",
"(",
"self",
")",
":",
"print",
"'money:'",
",",
"self",
".",
"money",
"print",
"'store:'",
",",
"self",
".",
"store",
"print",
"'avgprice:'",
",",
"self",
".",
"avgprice"
] | 總覽顯示 | [
"總覽顯示"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/BSR.py#L67-L71 |
toomore/goristock | grs/twseno.py | twseno.search | def search(self,q):
""" Search. """
import re
pattern = re.compile("%s" % q)
result = {}
for i in self.allstockno:
b = re.search(pattern, self.allstockno[i])
try:
b.group()
result[i] = self.allstockno[i]
except:
pass
return result | python | def search(self,q):
""" Search. """
import re
pattern = re.compile("%s" % q)
result = {}
for i in self.allstockno:
b = re.search(pattern, self.allstockno[i])
try:
b.group()
result[i] = self.allstockno[i]
except:
pass
return result | [
"def",
"search",
"(",
"self",
",",
"q",
")",
":",
"import",
"re",
"pattern",
"=",
"re",
".",
"compile",
"(",
"\"%s\"",
"%",
"q",
")",
"result",
"=",
"{",
"}",
"for",
"i",
"in",
"self",
".",
"allstockno",
":",
"b",
"=",
"re",
".",
"search",
"(",... | Search. | [
"Search",
"."
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/twseno.py#L72-L85 |
jtambasco/modesolverpy | modesolverpy/_mode_solver_lib.py | trapz2 | def trapz2(f, x=None, y=None, dx=1.0, dy=1.0):
"""Double integrate."""
return numpy.trapz(numpy.trapz(f, x=y, dx=dy), x=x, dx=dx) | python | def trapz2(f, x=None, y=None, dx=1.0, dy=1.0):
"""Double integrate."""
return numpy.trapz(numpy.trapz(f, x=y, dx=dy), x=x, dx=dx) | [
"def",
"trapz2",
"(",
"f",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"dx",
"=",
"1.0",
",",
"dy",
"=",
"1.0",
")",
":",
"return",
"numpy",
".",
"trapz",
"(",
"numpy",
".",
"trapz",
"(",
"f",
",",
"x",
"=",
"y",
",",
"dx",
"=",
"d... | Double integrate. | [
"Double",
"integrate",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/_mode_solver_lib.py#L22-L24 |
jtambasco/modesolverpy | modesolverpy/_mode_solver_lib.py | _ModeSolverVectorial.solve | def solve(self, neigs=4, tol=0, guess=None, mode_profiles=True, initial_mode_guess=None):
"""
This function finds the eigenmodes.
Parameters
----------
neigs : int
number of eigenmodes to find
tol : float
Relative accuracy for eigenvalues. The def... | python | def solve(self, neigs=4, tol=0, guess=None, mode_profiles=True, initial_mode_guess=None):
"""
This function finds the eigenmodes.
Parameters
----------
neigs : int
number of eigenmodes to find
tol : float
Relative accuracy for eigenvalues. The def... | [
"def",
"solve",
"(",
"self",
",",
"neigs",
"=",
"4",
",",
"tol",
"=",
"0",
",",
"guess",
"=",
"None",
",",
"mode_profiles",
"=",
"True",
",",
"initial_mode_guess",
"=",
"None",
")",
":",
"from",
"scipy",
".",
"sparse",
".",
"linalg",
"import",
"eigen... | This function finds the eigenmodes.
Parameters
----------
neigs : int
number of eigenmodes to find
tol : float
Relative accuracy for eigenvalues. The default value of 0 implies machine precision.
guess : float
a guess for the refractive index.... | [
"This",
"function",
"finds",
"the",
"eigenmodes",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/_mode_solver_lib.py#L926-L1003 |
toomore/goristock | grs/realtime.py | twsk.real | def real(self):
""" Real time data """
try:
unch = sum([covstr(self.stock[3]),covstr(self.stock[4])])/2
re = {'name': unicode(self.stock[36].replace(' ',''), 'cp950'),
'no': self.stock[0],
'range': self.stock[1],
'time': self.stock[2],
'max': self.stoc... | python | def real(self):
""" Real time data """
try:
unch = sum([covstr(self.stock[3]),covstr(self.stock[4])])/2
re = {'name': unicode(self.stock[36].replace(' ',''), 'cp950'),
'no': self.stock[0],
'range': self.stock[1],
'time': self.stock[2],
'max': self.stoc... | [
"def",
"real",
"(",
"self",
")",
":",
"try",
":",
"unch",
"=",
"sum",
"(",
"[",
"covstr",
"(",
"self",
".",
"stock",
"[",
"3",
"]",
")",
",",
"covstr",
"(",
"self",
".",
"stock",
"[",
"4",
"]",
")",
"]",
")",
"/",
"2",
"re",
"=",
"{",
"'n... | Real time data | [
"Real",
"time",
"data"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/realtime.py#L46-L91 |
toomore/goristock | grs/cttwt.py | TWTime.now | def now(self):
''' Display Taiwan Time now
顯示台灣此刻時間
'''
localtime = datetime.datetime.now()
return localtime + datetime.timedelta(hours = time.timezone/60/60 + self.TimeZone) | python | def now(self):
''' Display Taiwan Time now
顯示台灣此刻時間
'''
localtime = datetime.datetime.now()
return localtime + datetime.timedelta(hours = time.timezone/60/60 + self.TimeZone) | [
"def",
"now",
"(",
"self",
")",
":",
"localtime",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"return",
"localtime",
"+",
"datetime",
".",
"timedelta",
"(",
"hours",
"=",
"time",
".",
"timezone",
"/",
"60",
"/",
"60",
"+",
"self",
".",
... | Display Taiwan Time now
顯示台灣此刻時間 | [
"Display",
"Taiwan",
"Time",
"now",
"顯示台灣此刻時間"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/cttwt.py#L37-L42 |
toomore/goristock | grs/cttwt.py | TWTime.date | def date(self):
''' Display Taiwan date now
顯示台灣此刻日期
'''
localtime = datetime.date.today()
return localtime + datetime.timedelta(hours = time.timezone/60/60 + self.TimeZone) | python | def date(self):
''' Display Taiwan date now
顯示台灣此刻日期
'''
localtime = datetime.date.today()
return localtime + datetime.timedelta(hours = time.timezone/60/60 + self.TimeZone) | [
"def",
"date",
"(",
"self",
")",
":",
"localtime",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"return",
"localtime",
"+",
"datetime",
".",
"timedelta",
"(",
"hours",
"=",
"time",
".",
"timezone",
"/",
"60",
"/",
"60",
"+",
"self",
".",
"... | Display Taiwan date now
顯示台灣此刻日期 | [
"Display",
"Taiwan",
"date",
"now",
"顯示台灣此刻日期"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/cttwt.py#L45-L50 |
toomore/goristock | ck4buy.py | allck | def allck():
''' 檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。 '''
for i in twseno().allstockno:
a = goristock.goristock(i)
try:
if a.stock_vol[-1] > 1000*1000 and a.raw_data[-1] > 10:
#a.goback(3) ## 倒退天數
ck4m(a)
except:
pass | python | def allck():
''' 檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。 '''
for i in twseno().allstockno:
a = goristock.goristock(i)
try:
if a.stock_vol[-1] > 1000*1000 and a.raw_data[-1] > 10:
#a.goback(3) ## 倒退天數
ck4m(a)
except:
pass | [
"def",
"allck",
"(",
")",
":",
"for",
"i",
"in",
"twseno",
"(",
")",
".",
"allstockno",
":",
"a",
"=",
"goristock",
".",
"goristock",
"(",
"i",
")",
"try",
":",
"if",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"1000",
"*",
"1000",
"and",
... | 檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。 | [
"檢查所有股票買賣點,剔除$10以下、成交量小於1000張的股票。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/ck4buy.py#L28-L37 |
jtambasco/modesolverpy | modesolverpy/design.py | directional_coupler_lc | def directional_coupler_lc(wavelength_nm, n_eff_1, n_eff_2):
'''
Calculates the coherence length (100% power transfer) of a
directional coupler.
Args:
wavelength_nm (float): The wavelength in [nm] the
directional coupler should operate at.
n_eff_1 (float): n_eff of the funda... | python | def directional_coupler_lc(wavelength_nm, n_eff_1, n_eff_2):
'''
Calculates the coherence length (100% power transfer) of a
directional coupler.
Args:
wavelength_nm (float): The wavelength in [nm] the
directional coupler should operate at.
n_eff_1 (float): n_eff of the funda... | [
"def",
"directional_coupler_lc",
"(",
"wavelength_nm",
",",
"n_eff_1",
",",
"n_eff_2",
")",
":",
"wavelength_m",
"=",
"wavelength_nm",
"*",
"1.e-9",
"dn_eff",
"=",
"(",
"n_eff_1",
"-",
"n_eff_2",
")",
".",
"real",
"lc_m",
"=",
"wavelength_m",
"/",
"(",
"2.",... | Calculates the coherence length (100% power transfer) of a
directional coupler.
Args:
wavelength_nm (float): The wavelength in [nm] the
directional coupler should operate at.
n_eff_1 (float): n_eff of the fundamental (even)
supermode of the directional coupler.
n... | [
"Calculates",
"the",
"coherence",
"length",
"(",
"100%",
"power",
"transfer",
")",
"of",
"a",
"directional",
"coupler",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/design.py#L4-L26 |
jtambasco/modesolverpy | modesolverpy/design.py | grating_coupler_period | def grating_coupler_period(wavelength,
n_eff,
n_clad,
incidence_angle_deg,
diffration_order=1):
'''
Calculate the period needed for a grating coupler.
Args:
wavelength (float): The target wav... | python | def grating_coupler_period(wavelength,
n_eff,
n_clad,
incidence_angle_deg,
diffration_order=1):
'''
Calculate the period needed for a grating coupler.
Args:
wavelength (float): The target wav... | [
"def",
"grating_coupler_period",
"(",
"wavelength",
",",
"n_eff",
",",
"n_clad",
",",
"incidence_angle_deg",
",",
"diffration_order",
"=",
"1",
")",
":",
"k0",
"=",
"2.",
"*",
"np",
".",
"pi",
"/",
"wavelength",
"beta",
"=",
"n_eff",
".",
"real",
"*",
"k... | Calculate the period needed for a grating coupler.
Args:
wavelength (float): The target wavelength for the
grating coupler.
n_eff (float): The effective index of the mode
of a waveguide with the width of the grating
coupler.
n_clad (float): The refractive... | [
"Calculate",
"the",
"period",
"needed",
"for",
"a",
"grating",
"coupler",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/design.py#L29-L60 |
toomore/goristock | grs/timeser.py | oop | def oop(aa):
""" For cmd output. """
return ('%s %s %s %.2f %+.2f %s %s %s %s %+.2f %s %s %.2f %.4f %.4f' % (aa.stock_no, aa.stock_name, aa.data_date[-1], aa.raw_data[-1], aa.range_per, aa.MAC(3), aa.MAC(6), aa.MAC(18), aa.MAO(3,6)[1], aa.MAO(3,6)[0][1][-1], aa.MAO(3,6)[0][0], aa.RABC, aa.stock_vol[-1]/1000, aa.SD,... | python | def oop(aa):
""" For cmd output. """
return ('%s %s %s %.2f %+.2f %s %s %s %s %+.2f %s %s %.2f %.4f %.4f' % (aa.stock_no, aa.stock_name, aa.data_date[-1], aa.raw_data[-1], aa.range_per, aa.MAC(3), aa.MAC(6), aa.MAC(18), aa.MAO(3,6)[1], aa.MAO(3,6)[0][1][-1], aa.MAO(3,6)[0][0], aa.RABC, aa.stock_vol[-1]/1000, aa.SD,... | [
"def",
"oop",
"(",
"aa",
")",
":",
"return",
"(",
"'%s %s %s %.2f %+.2f %s %s %s %s %+.2f %s %s %.2f %.4f %.4f'",
"%",
"(",
"aa",
".",
"stock_no",
",",
"aa",
".",
"stock_name",
",",
"aa",
".",
"data_date",
"[",
"-",
"1",
"]",
",",
"aa",
".",
"raw_data",
"[... | For cmd output. | [
"For",
"cmd",
"output",
"."
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/timeser.py#L25-L27 |
toomore/goristock | grs/timeser.py | overall | def overall(goback = 0, case = 1):
""" To run all over the stock and to find who match the 'case'
'goback' is back to what days ago.
0 is the last day.
"""
from twseno import twseno
for i in twseno().allstock:
#timetest(i)
try:
if case == 1:
try:
a = goristock(i)
... | python | def overall(goback = 0, case = 1):
""" To run all over the stock and to find who match the 'case'
'goback' is back to what days ago.
0 is the last day.
"""
from twseno import twseno
for i in twseno().allstock:
#timetest(i)
try:
if case == 1:
try:
a = goristock(i)
... | [
"def",
"overall",
"(",
"goback",
"=",
"0",
",",
"case",
"=",
"1",
")",
":",
"from",
"twseno",
"import",
"twseno",
"for",
"i",
"in",
"twseno",
"(",
")",
".",
"allstock",
":",
"#timetest(i)",
"try",
":",
"if",
"case",
"==",
"1",
":",
"try",
":",
"a... | To run all over the stock and to find who match the 'case'
'goback' is back to what days ago.
0 is the last day. | [
"To",
"run",
"all",
"over",
"the",
"stock",
"and",
"to",
"find",
"who",
"match",
"the",
"case",
"goback",
"is",
"back",
"to",
"what",
"days",
"ago",
".",
"0",
"is",
"the",
"last",
"day",
"."
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/timeser.py#L41-L98 |
brutus/wtforms-html5 | setup.py | read_file | def read_file(filename, prepend_paths=[]):
"""
Returns the contents of *filename* (UTF-8).
If *prepend_paths* is set, join those before the *fielname*.
If it is `True`, prepend the path to `setup.py`.
"""
if prepend_paths is True:
prepend_paths = [
os.path.abspath(os.path.dirname(__file__)),
... | python | def read_file(filename, prepend_paths=[]):
"""
Returns the contents of *filename* (UTF-8).
If *prepend_paths* is set, join those before the *fielname*.
If it is `True`, prepend the path to `setup.py`.
"""
if prepend_paths is True:
prepend_paths = [
os.path.abspath(os.path.dirname(__file__)),
... | [
"def",
"read_file",
"(",
"filename",
",",
"prepend_paths",
"=",
"[",
"]",
")",
":",
"if",
"prepend_paths",
"is",
"True",
":",
"prepend_paths",
"=",
"[",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
... | Returns the contents of *filename* (UTF-8).
If *prepend_paths* is set, join those before the *fielname*.
If it is `True`, prepend the path to `setup.py`. | [
"Returns",
"the",
"contents",
"of",
"*",
"filename",
"*",
"(",
"UTF",
"-",
"8",
")",
"."
] | train | https://github.com/brutus/wtforms-html5/blob/a00ab7c68e6238bfa317f40ec3de807dae8ed85e/setup.py#L33-L50 |
toomore/goristock | grs/twseopen.py | twseopen.loaddate | def loaddate(self):
''' 載入檔案
檔案依據 http://www.twse.com.tw/ch/trading/trading_days.php
'''
ld = csv.reader(open('./%s/opendate.csv' % _CSVFILEPATH, 'r'))
re = {}
re['close'] = []
re['open'] = []
for i in ld:
''' 0 = 休市, 1 = 開市 '''
if i[1] == '0':
re['close'] += [da... | python | def loaddate(self):
''' 載入檔案
檔案依據 http://www.twse.com.tw/ch/trading/trading_days.php
'''
ld = csv.reader(open('./%s/opendate.csv' % _CSVFILEPATH, 'r'))
re = {}
re['close'] = []
re['open'] = []
for i in ld:
''' 0 = 休市, 1 = 開市 '''
if i[1] == '0':
re['close'] += [da... | [
"def",
"loaddate",
"(",
"self",
")",
":",
"ld",
"=",
"csv",
".",
"reader",
"(",
"open",
"(",
"'./%s/opendate.csv'",
"%",
"_CSVFILEPATH",
",",
"'r'",
")",
")",
"re",
"=",
"{",
"}",
"re",
"[",
"'close'",
"]",
"=",
"[",
"]",
"re",
"[",
"'open'",
"]"... | 載入檔案
檔案依據 http://www.twse.com.tw/ch/trading/trading_days.php | [
"載入檔案",
"檔案依據",
"http",
":",
"//",
"www",
".",
"twse",
".",
"com",
".",
"tw",
"/",
"ch",
"/",
"trading",
"/",
"trading_days",
".",
"php"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/twseopen.py#L41-L58 |
toomore/goristock | grs/twseopen.py | twseopen.ooc | def ooc(self):
''' Open or close
回傳 True:開市,False:休市。
'''
if self.ptime.date() in self.ocdate['close']: ## 判對是否為法定休市
return False
elif self.ptime.date() in self.ocdate['open']: ## 判對是否為法定開市
return True
else:
''' 判斷是否為每週開休市 '''
if self.ptime.weekday() <= 4:
ret... | python | def ooc(self):
''' Open or close
回傳 True:開市,False:休市。
'''
if self.ptime.date() in self.ocdate['close']: ## 判對是否為法定休市
return False
elif self.ptime.date() in self.ocdate['open']: ## 判對是否為法定開市
return True
else:
''' 判斷是否為每週開休市 '''
if self.ptime.weekday() <= 4:
ret... | [
"def",
"ooc",
"(",
"self",
")",
":",
"if",
"self",
".",
"ptime",
".",
"date",
"(",
")",
"in",
"self",
".",
"ocdate",
"[",
"'close'",
"]",
":",
"## 判對是否為法定休市",
"return",
"False",
"elif",
"self",
".",
"ptime",
".",
"date",
"(",
")",
"in",
"self",
"... | Open or close
回傳 True:開市,False:休市。 | [
"Open",
"or",
"close",
"回傳",
"True:開市,False:休市。"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/twseopen.py#L60-L73 |
toomore/goristock | grs/all_portf.py | all_portf.ck_portf_001 | def ck_portf_001(self):
''' 3-6負乖離且向上,三日內最大量,成交量大於 1000 張,收盤價大於 10 元。(較嚴謹的選股)'''
return self.a.MAO(3,6)[1] == '↑'.decode('utf-8') and (self.a.MAO(3,6)[0][1][-1] < 0 or ( self.a.MAO(3,6)[0][1][-1] < 1 and self.a.MAO(3,6)[0][1][-1] > 0 and self.a.MAO(3,6)[0][1][-2] < 0 and self.a.MAO(3,6)[0][0] == 3)) and self.a... | python | def ck_portf_001(self):
''' 3-6負乖離且向上,三日內最大量,成交量大於 1000 張,收盤價大於 10 元。(較嚴謹的選股)'''
return self.a.MAO(3,6)[1] == '↑'.decode('utf-8') and (self.a.MAO(3,6)[0][1][-1] < 0 or ( self.a.MAO(3,6)[0][1][-1] < 1 and self.a.MAO(3,6)[0][1][-1] > 0 and self.a.MAO(3,6)[0][1][-2] < 0 and self.a.MAO(3,6)[0][0] == 3)) and self.a... | [
"def",
"ck_portf_001",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"MAO",
"(",
"3",
",",
"6",
")",
"[",
"1",
"]",
"==",
"'↑'.d",
"e",
"code('",
"u",
"tf-8') ",
"a",
"d (",
"e",
"lf.a",
".",
"M",
"A",
"O(3",
",",
"6",
")",
"[",
"... | 3-6負乖離且向上,三日內最大量,成交量大於 1000 張,收盤價大於 10 元。(較嚴謹的選股) | [
"3",
"-",
"6負乖離且向上,三日內最大量,成交量大於",
"1000",
"張,收盤價大於",
"10",
"元。(較嚴謹的選股)"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L28-L30 |
toomore/goristock | grs/all_portf.py | all_portf.ck_portf_002 | def ck_portf_002(self):
''' 3日均價大於6日均價,6日均價大於18日均價。(短中長線呈現多頭的態勢) '''
return self.a.MA(3) > self.a.MA(6) > self.a.MA(18) and self.a.MAC(18) == '↑'.decode('utf-8') and self.a.stock_vol[-1] > 1000*1000 and self.a.raw_data[-1] > 10 | python | def ck_portf_002(self):
''' 3日均價大於6日均價,6日均價大於18日均價。(短中長線呈現多頭的態勢) '''
return self.a.MA(3) > self.a.MA(6) > self.a.MA(18) and self.a.MAC(18) == '↑'.decode('utf-8') and self.a.stock_vol[-1] > 1000*1000 and self.a.raw_data[-1] > 10 | [
"def",
"ck_portf_002",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"MA",
"(",
"3",
")",
">",
"self",
".",
"a",
".",
"MA",
"(",
"6",
")",
">",
"self",
".",
"a",
".",
"MA",
"(",
"18",
")",
"and",
"self",
".",
"a",
".",
"MAC",
"(... | 3日均價大於6日均價,6日均價大於18日均價。(短中長線呈現多頭的態勢) | [
"3日均價大於6日均價,6日均價大於18日均價。(短中長線呈現多頭的態勢)"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L32-L34 |
toomore/goristock | grs/all_portf.py | all_portf.ck_portf_003 | def ck_portf_003(self):
''' 當日成交量,大於前三天的總成交量。(短線多空動能) '''
return self.a.stock_vol[-1] > sum(self.a.stock_vol[-4:-1]) and self.a.stock_vol[-1] > 1000*1000 and self.a.raw_data[-1] > 10 | python | def ck_portf_003(self):
''' 當日成交量,大於前三天的總成交量。(短線多空動能) '''
return self.a.stock_vol[-1] > sum(self.a.stock_vol[-4:-1]) and self.a.stock_vol[-1] > 1000*1000 and self.a.raw_data[-1] > 10 | [
"def",
"ck_portf_003",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"sum",
"(",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"4",
":",
"-",
"1",
"]",
")",
"and",
"self",
".",
"a",
".",
"stock_... | 當日成交量,大於前三天的總成交量。(短線多空動能) | [
"當日成交量,大於前三天的總成交量。(短線多空動能)"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L36-L38 |
toomore/goristock | grs/all_portf.py | all_portf.ck_portf_004 | def ck_portf_004(self):
''' 價走平一個半月。(箱型整理、盤整) '''
return self.a.SD < 0.25 and self.a.stock_vol[-1] > 1000*1000 and self.a.raw_data[-1] > 10 | python | def ck_portf_004(self):
''' 價走平一個半月。(箱型整理、盤整) '''
return self.a.SD < 0.25 and self.a.stock_vol[-1] > 1000*1000 and self.a.raw_data[-1] > 10 | [
"def",
"ck_portf_004",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"SD",
"<",
"0.25",
"and",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"1000",
"*",
"1000",
"and",
"self",
".",
"a",
".",
"raw_data",
"[",
"-",
"1",
... | 價走平一個半月。(箱型整理、盤整) | [
"價走平一個半月。(箱型整理、盤整)"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L40-L42 |
toomore/goristock | grs/all_portf.py | B4P.GLI | def GLI(self, pm=False):
''' 判斷乖離 '''
return list(self.a.ckMAO(self.a.MAO(3,6)[0][1], pm=pm))[0] | python | def GLI(self, pm=False):
''' 判斷乖離 '''
return list(self.a.ckMAO(self.a.MAO(3,6)[0][1], pm=pm))[0] | [
"def",
"GLI",
"(",
"self",
",",
"pm",
"=",
"False",
")",
":",
"return",
"list",
"(",
"self",
".",
"a",
".",
"ckMAO",
"(",
"self",
".",
"a",
".",
"MAO",
"(",
"3",
",",
"6",
")",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"pm",
"=",
"pm",
")",
")... | 判斷乖離 | [
"判斷乖離"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L53-L55 |
toomore/goristock | grs/all_portf.py | B4P.B1 | def B1(self):
''' 量大收紅 '''
return self.a.stock_vol[-1] > self.a.stock_vol[-2] and self.a.PUPTY | python | def B1(self):
''' 量大收紅 '''
return self.a.stock_vol[-1] > self.a.stock_vol[-2] and self.a.PUPTY | [
"def",
"B1",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"2",
"]",
"and",
"self",
".",
"a",
".",
"PUPTY"
] | 量大收紅 | [
"量大收紅"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L69-L71 |
toomore/goristock | grs/all_portf.py | B4P.B2 | def B2(self):
''' 量縮價不跌 '''
return self.a.stock_vol[-1] < self.a.stock_vol[-2] and self.a.PUPTY | python | def B2(self):
''' 量縮價不跌 '''
return self.a.stock_vol[-1] < self.a.stock_vol[-2] and self.a.PUPTY | [
"def",
"B2",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
"<",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"2",
"]",
"and",
"self",
".",
"a",
".",
"PUPTY"
] | 量縮價不跌 | [
"量縮價不跌"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L74-L76 |
toomore/goristock | grs/all_portf.py | B4P.S1 | def S1(self):
''' 量大收黑 '''
return self.a.stock_vol[-1] > self.a.stock_vol[-2] and not self.a.PUPTY | python | def S1(self):
''' 量大收黑 '''
return self.a.stock_vol[-1] > self.a.stock_vol[-2] and not self.a.PUPTY | [
"def",
"S1",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
">",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"2",
"]",
"and",
"not",
"self",
".",
"a",
".",
"PUPTY"
] | 量大收黑 | [
"量大收黑"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L90-L92 |
toomore/goristock | grs/all_portf.py | B4P.S2 | def S2(self):
''' 量縮價跌 '''
return self.a.stock_vol[-1] < self.a.stock_vol[-2] and not self.a.PUPTY | python | def S2(self):
''' 量縮價跌 '''
return self.a.stock_vol[-1] < self.a.stock_vol[-2] and not self.a.PUPTY | [
"def",
"S2",
"(",
"self",
")",
":",
"return",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"1",
"]",
"<",
"self",
".",
"a",
".",
"stock_vol",
"[",
"-",
"2",
"]",
"and",
"not",
"self",
".",
"a",
".",
"PUPTY"
] | 量縮價跌 | [
"量縮價跌"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L95-L97 |
toomore/goristock | grs/all_portf.py | B4P.B4PB | def B4PB(self):
''' 判斷是否為四大買點 '''
return self.ckMinsGLI and (self.B1 or self.B2 or self.B3 or self.B4) | python | def B4PB(self):
''' 判斷是否為四大買點 '''
return self.ckMinsGLI and (self.B1 or self.B2 or self.B3 or self.B4) | [
"def",
"B4PB",
"(",
"self",
")",
":",
"return",
"self",
".",
"ckMinsGLI",
"and",
"(",
"self",
".",
"B1",
"or",
"self",
".",
"B2",
"or",
"self",
".",
"B3",
"or",
"self",
".",
"B4",
")"
] | 判斷是否為四大買點 | [
"判斷是否為四大買點"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L110-L112 |
toomore/goristock | grs/all_portf.py | B4P.B4PS | def B4PS(self):
''' 判斷是否為四大賣點 '''
return self.ckPlusGLI and (self.S1 or self.S2 or self.S3 or self.S4) | python | def B4PS(self):
''' 判斷是否為四大賣點 '''
return self.ckPlusGLI and (self.S1 or self.S2 or self.S3 or self.S4) | [
"def",
"B4PS",
"(",
"self",
")",
":",
"return",
"self",
".",
"ckPlusGLI",
"and",
"(",
"self",
".",
"S1",
"or",
"self",
".",
"S2",
"or",
"self",
".",
"S3",
"or",
"self",
".",
"S4",
")"
] | 判斷是否為四大賣點 | [
"判斷是否為四大賣點"
] | train | https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/all_portf.py#L115-L117 |
jtambasco/modesolverpy | modesolverpy/coupling_efficiency.py | reflection | def reflection(n1, n2):
'''
Calculate the power reflection at the interface
of two refractive index materials.
Args:
n1 (float): Refractive index of material 1.
n2 (float): Refractive index of material 2.
Returns:
float: The percentage of reflected power.
'''
r = ab... | python | def reflection(n1, n2):
'''
Calculate the power reflection at the interface
of two refractive index materials.
Args:
n1 (float): Refractive index of material 1.
n2 (float): Refractive index of material 2.
Returns:
float: The percentage of reflected power.
'''
r = ab... | [
"def",
"reflection",
"(",
"n1",
",",
"n2",
")",
":",
"r",
"=",
"abs",
"(",
"(",
"n1",
"-",
"n2",
")",
"/",
"(",
"n1",
"+",
"n2",
")",
")",
"**",
"2",
"return",
"r"
] | Calculate the power reflection at the interface
of two refractive index materials.
Args:
n1 (float): Refractive index of material 1.
n2 (float): Refractive index of material 2.
Returns:
float: The percentage of reflected power. | [
"Calculate",
"the",
"power",
"reflection",
"at",
"the",
"interface",
"of",
"two",
"refractive",
"index",
"materials",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/coupling_efficiency.py#L25-L38 |
jtambasco/modesolverpy | modesolverpy/coupling_efficiency.py | coupling_efficiency | def coupling_efficiency(mode_solver, fibre_mfd,
fibre_offset_x=0, fibre_offset_y=0,
n_eff_fibre=1.441):
'''
Finds the coupling efficiency between a solved
fundamental mode and a fibre of given MFD.
Args:
mode_solver (_ModeSolver): Mode solver that... | python | def coupling_efficiency(mode_solver, fibre_mfd,
fibre_offset_x=0, fibre_offset_y=0,
n_eff_fibre=1.441):
'''
Finds the coupling efficiency between a solved
fundamental mode and a fibre of given MFD.
Args:
mode_solver (_ModeSolver): Mode solver that... | [
"def",
"coupling_efficiency",
"(",
"mode_solver",
",",
"fibre_mfd",
",",
"fibre_offset_x",
"=",
"0",
",",
"fibre_offset_y",
"=",
"0",
",",
"n_eff_fibre",
"=",
"1.441",
")",
":",
"etas",
"=",
"[",
"]",
"gaus",
"=",
"_make_gaussian",
"(",
"mode_solver",
".",
... | Finds the coupling efficiency between a solved
fundamental mode and a fibre of given MFD.
Args:
mode_solver (_ModeSolver): Mode solver that
has found a fundamental mode.
fibre_mfd (float): The mode-field diameter
(MFD) of the fibre.
fibre_offset_x (float): Offset... | [
"Finds",
"the",
"coupling",
"efficiency",
"between",
"a",
"solved",
"fundamental",
"mode",
"and",
"a",
"fibre",
"of",
"given",
"MFD",
"."
] | train | https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/coupling_efficiency.py#L54-L89 |
wdecoster/nanolyse | nanolyse/NanoLyse.py | getIndex | def getIndex(reference):
'''
Find the reference folder using the location of the script file
Create the index, test if successful
'''
if reference:
reffas = reference
else:
parent_directory = path.dirname(path.abspath(path.dirname(__file__)))
reffas = path.join(parent_dir... | python | def getIndex(reference):
'''
Find the reference folder using the location of the script file
Create the index, test if successful
'''
if reference:
reffas = reference
else:
parent_directory = path.dirname(path.abspath(path.dirname(__file__)))
reffas = path.join(parent_dir... | [
"def",
"getIndex",
"(",
"reference",
")",
":",
"if",
"reference",
":",
"reffas",
"=",
"reference",
"else",
":",
"parent_directory",
"=",
"path",
".",
"dirname",
"(",
"path",
".",
"abspath",
"(",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
")",
"... | Find the reference folder using the location of the script file
Create the index, test if successful | [
"Find",
"the",
"reference",
"folder",
"using",
"the",
"location",
"of",
"the",
"script",
"file",
"Create",
"the",
"index",
"test",
"if",
"successful"
] | train | https://github.com/wdecoster/nanolyse/blob/026631b3a88097c91d84070f1cfc035c825d0878/nanolyse/NanoLyse.py#L81-L98 |
wdecoster/nanolyse | nanolyse/NanoLyse.py | align | def align(aligner, reads):
'''
Test if reads can get aligned to the lambda genome,
if not: write to stdout
'''
i = 0
for record in SeqIO.parse(reads, "fastq"):
try:
next(aligner.map(str(record.seq)))
i += 1
except StopIteration:
print(record.fo... | python | def align(aligner, reads):
'''
Test if reads can get aligned to the lambda genome,
if not: write to stdout
'''
i = 0
for record in SeqIO.parse(reads, "fastq"):
try:
next(aligner.map(str(record.seq)))
i += 1
except StopIteration:
print(record.fo... | [
"def",
"align",
"(",
"aligner",
",",
"reads",
")",
":",
"i",
"=",
"0",
"for",
"record",
"in",
"SeqIO",
".",
"parse",
"(",
"reads",
",",
"\"fastq\"",
")",
":",
"try",
":",
"next",
"(",
"aligner",
".",
"map",
"(",
"str",
"(",
"record",
".",
"seq",
... | Test if reads can get aligned to the lambda genome,
if not: write to stdout | [
"Test",
"if",
"reads",
"can",
"get",
"aligned",
"to",
"the",
"lambda",
"genome",
"if",
"not",
":",
"write",
"to",
"stdout"
] | train | https://github.com/wdecoster/nanolyse/blob/026631b3a88097c91d84070f1cfc035c825d0878/nanolyse/NanoLyse.py#L101-L113 |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2016_05_31/table/_deserialization.py | _convert_json_response_to_entities | def _convert_json_response_to_entities(response, property_resolver, require_encryption,
key_encryption_key, key_resolver):
''' Converts the response to tables class.
'''
if response is None or response.body is None:
return None
entities = _list()
enti... | python | def _convert_json_response_to_entities(response, property_resolver, require_encryption,
key_encryption_key, key_resolver):
''' Converts the response to tables class.
'''
if response is None or response.body is None:
return None
entities = _list()
enti... | [
"def",
"_convert_json_response_to_entities",
"(",
"response",
",",
"property_resolver",
",",
"require_encryption",
",",
"key_encryption_key",
",",
"key_resolver",
")",
":",
"if",
"response",
"is",
"None",
"or",
"response",
".",
"body",
"is",
"None",
":",
"return",
... | Converts the response to tables class. | [
"Converts",
"the",
"response",
"to",
"tables",
"class",
"."
] | train | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2016_05_31/table/_deserialization.py#L243-L266 |
openstack/proliantutils | proliantutils/ilo/ipmi.py | _exec_ipmitool | def _exec_ipmitool(driver_info, command):
"""Execute the ipmitool command.
This uses the lanplus interface to communicate with the BMC device driver.
:param driver_info: the ipmitool parameters for accessing a node.
:param command: the ipmitool command to be executed.
"""
ipmi_cmd = ("ipmitoo... | python | def _exec_ipmitool(driver_info, command):
"""Execute the ipmitool command.
This uses the lanplus interface to communicate with the BMC device driver.
:param driver_info: the ipmitool parameters for accessing a node.
:param command: the ipmitool command to be executed.
"""
ipmi_cmd = ("ipmitoo... | [
"def",
"_exec_ipmitool",
"(",
"driver_info",
",",
"command",
")",
":",
"ipmi_cmd",
"=",
"(",
"\"ipmitool -H %(address)s\"",
"\" -I lanplus -U %(user)s -P %(passwd)s %(cmd)s\"",
"%",
"{",
"'address'",
":",
"driver_info",
"[",
"'address'",
"]",
",",
"'user'",
":",
"driv... | Execute the ipmitool command.
This uses the lanplus interface to communicate with the BMC device driver.
:param driver_info: the ipmitool parameters for accessing a node.
:param command: the ipmitool command to be executed. | [
"Execute",
"the",
"ipmitool",
"command",
"."
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ipmi.py#L32-L53 |
openstack/proliantutils | proliantutils/ilo/ipmi.py | get_nic_capacity | def get_nic_capacity(driver_info, ilo_fw):
"""Gets the FRU data to see if it is NIC data
Gets the FRU data in loop from 0-255 FRU Ids
and check if the returned data is NIC data. Couldn't
find any easy way to detect if it is NIC data. We should't be
hardcoding the FRU Id.
:param driver_info: Co... | python | def get_nic_capacity(driver_info, ilo_fw):
"""Gets the FRU data to see if it is NIC data
Gets the FRU data in loop from 0-255 FRU Ids
and check if the returned data is NIC data. Couldn't
find any easy way to detect if it is NIC data. We should't be
hardcoding the FRU Id.
:param driver_info: Co... | [
"def",
"get_nic_capacity",
"(",
"driver_info",
",",
"ilo_fw",
")",
":",
"i",
"=",
"0x0",
"value",
"=",
"None",
"ilo_fw_rev",
"=",
"get_ilo_version",
"(",
"ilo_fw",
")",
"or",
"DEFAULT_FW_REV",
"# Note(vmud213): iLO firmware versions >= 2.3 support reading the FRU",
"# i... | Gets the FRU data to see if it is NIC data
Gets the FRU data in loop from 0-255 FRU Ids
and check if the returned data is NIC data. Couldn't
find any easy way to detect if it is NIC data. We should't be
hardcoding the FRU Id.
:param driver_info: Contains the access credentials to access
... | [
"Gets",
"the",
"FRU",
"data",
"to",
"see",
"if",
"it",
"is",
"NIC",
"data"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ipmi.py#L76-L117 |
openstack/proliantutils | proliantutils/ilo/ipmi.py | _parse_ipmi_nic_capacity | def _parse_ipmi_nic_capacity(nic_out):
"""Parse the FRU output for NIC capacity
Parses the FRU output. Seraches for the key "Product Name"
in FRU output and greps for maximum speed supported by the
NIC adapter.
:param nic_out: the FRU output for NIC adapter.
:returns: the max capacity supporte... | python | def _parse_ipmi_nic_capacity(nic_out):
"""Parse the FRU output for NIC capacity
Parses the FRU output. Seraches for the key "Product Name"
in FRU output and greps for maximum speed supported by the
NIC adapter.
:param nic_out: the FRU output for NIC adapter.
:returns: the max capacity supporte... | [
"def",
"_parse_ipmi_nic_capacity",
"(",
"nic_out",
")",
":",
"if",
"(",
"(",
"\"Device not present\"",
"in",
"nic_out",
")",
"or",
"(",
"\"Unknown FRU header\"",
"in",
"nic_out",
")",
"or",
"not",
"nic_out",
")",
":",
"return",
"None",
"capacity",
"=",
"None",... | Parse the FRU output for NIC capacity
Parses the FRU output. Seraches for the key "Product Name"
in FRU output and greps for maximum speed supported by the
NIC adapter.
:param nic_out: the FRU output for NIC adapter.
:returns: the max capacity supported by the NIC adapter. | [
"Parse",
"the",
"FRU",
"output",
"for",
"NIC",
"capacity"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ipmi.py#L120-L156 |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2016_05_31/table/_encryption.py | _extract_encryption_metadata | def _extract_encryption_metadata(entity, require_encryption, key_encryption_key, key_resolver):
'''
Extracts the encryption metadata from the given entity, setting them to be utf-8 strings.
If no encryption metadata is present, will return None for all return values unless
require_encryption is true, in... | python | def _extract_encryption_metadata(entity, require_encryption, key_encryption_key, key_resolver):
'''
Extracts the encryption metadata from the given entity, setting them to be utf-8 strings.
If no encryption metadata is present, will return None for all return values unless
require_encryption is true, in... | [
"def",
"_extract_encryption_metadata",
"(",
"entity",
",",
"require_encryption",
",",
"key_encryption_key",
",",
"key_resolver",
")",
":",
"_validate_not_none",
"(",
"'entity'",
",",
"entity",
")",
"try",
":",
"encrypted_properties_list",
"=",
"_decode_base64_to_bytes",
... | Extracts the encryption metadata from the given entity, setting them to be utf-8 strings.
If no encryption metadata is present, will return None for all return values unless
require_encryption is true, in which case the method will throw.
:param entity:
The entity being retrieved and decrypted. Cou... | [
"Extracts",
"the",
"encryption",
"metadata",
"from",
"the",
"given",
"entity",
"setting",
"them",
"to",
"be",
"utf",
"-",
"8",
"strings",
".",
"If",
"no",
"encryption",
"metadata",
"is",
"present",
"will",
"return",
"None",
"for",
"all",
"return",
"values",
... | train | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2016_05_31/table/_encryption.py#L215-L284 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayController.logical_drives | def logical_drives(self):
"""Gets the resource HPELogicalDriveCollection of ArrayControllers"""
return logical_drive.HPELogicalDriveCollection(
self._conn, utils.get_subresource_path_by(
self, ['Links', 'LogicalDrives']),
redfish_version=self.redfish_version) | python | def logical_drives(self):
"""Gets the resource HPELogicalDriveCollection of ArrayControllers"""
return logical_drive.HPELogicalDriveCollection(
self._conn, utils.get_subresource_path_by(
self, ['Links', 'LogicalDrives']),
redfish_version=self.redfish_version) | [
"def",
"logical_drives",
"(",
"self",
")",
":",
"return",
"logical_drive",
".",
"HPELogicalDriveCollection",
"(",
"self",
".",
"_conn",
",",
"utils",
".",
"get_subresource_path_by",
"(",
"self",
",",
"[",
"'Links'",
",",
"'LogicalDrives'",
"]",
")",
",",
"redf... | Gets the resource HPELogicalDriveCollection of ArrayControllers | [
"Gets",
"the",
"resource",
"HPELogicalDriveCollection",
"of",
"ArrayControllers"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L47-L53 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayController.physical_drives | def physical_drives(self):
"""Gets the resource HPEPhysicalDriveCollection of ArrayControllers"""
return physical_drive.HPEPhysicalDriveCollection(
self._conn, utils.get_subresource_path_by(
self, ['Links', 'PhysicalDrives']),
redfish_version=self.redfish_version) | python | def physical_drives(self):
"""Gets the resource HPEPhysicalDriveCollection of ArrayControllers"""
return physical_drive.HPEPhysicalDriveCollection(
self._conn, utils.get_subresource_path_by(
self, ['Links', 'PhysicalDrives']),
redfish_version=self.redfish_version) | [
"def",
"physical_drives",
"(",
"self",
")",
":",
"return",
"physical_drive",
".",
"HPEPhysicalDriveCollection",
"(",
"self",
".",
"_conn",
",",
"utils",
".",
"get_subresource_path_by",
"(",
"self",
",",
"[",
"'Links'",
",",
"'PhysicalDrives'",
"]",
")",
",",
"... | Gets the resource HPEPhysicalDriveCollection of ArrayControllers | [
"Gets",
"the",
"resource",
"HPEPhysicalDriveCollection",
"of",
"ArrayControllers"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L57-L62 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.logical_drives_maximum_size_mib | def logical_drives_maximum_size_mib(self):
"""Gets the biggest logical drive
:returns the size in MiB.
"""
return utils.max_safe([member.logical_drives.maximum_size_mib
for member in self.get_members()]) | python | def logical_drives_maximum_size_mib(self):
"""Gets the biggest logical drive
:returns the size in MiB.
"""
return utils.max_safe([member.logical_drives.maximum_size_mib
for member in self.get_members()]) | [
"def",
"logical_drives_maximum_size_mib",
"(",
"self",
")",
":",
"return",
"utils",
".",
"max_safe",
"(",
"[",
"member",
".",
"logical_drives",
".",
"maximum_size_mib",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
"]",
")"
] | Gets the biggest logical drive
:returns the size in MiB. | [
"Gets",
"the",
"biggest",
"logical",
"drive"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L74-L80 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.physical_drives_maximum_size_mib | def physical_drives_maximum_size_mib(self):
"""Gets the biggest disk
:returns the size in MiB.
"""
return utils.max_safe([member.physical_drives.maximum_size_mib
for member in self.get_members()]) | python | def physical_drives_maximum_size_mib(self):
"""Gets the biggest disk
:returns the size in MiB.
"""
return utils.max_safe([member.physical_drives.maximum_size_mib
for member in self.get_members()]) | [
"def",
"physical_drives_maximum_size_mib",
"(",
"self",
")",
":",
"return",
"utils",
".",
"max_safe",
"(",
"[",
"member",
".",
"physical_drives",
".",
"maximum_size_mib",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
"]",
")"
] | Gets the biggest disk
:returns the size in MiB. | [
"Gets",
"the",
"biggest",
"disk"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L84-L90 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.has_ssd | def has_ssd(self):
"""Return true if any of the drive under ArrayControllers is ssd"""
for member in self.get_members():
if member.physical_drives.has_ssd:
return True
return False | python | def has_ssd(self):
"""Return true if any of the drive under ArrayControllers is ssd"""
for member in self.get_members():
if member.physical_drives.has_ssd:
return True
return False | [
"def",
"has_ssd",
"(",
"self",
")",
":",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
":",
"if",
"member",
".",
"physical_drives",
".",
"has_ssd",
":",
"return",
"True",
"return",
"False"
] | Return true if any of the drive under ArrayControllers is ssd | [
"Return",
"true",
"if",
"any",
"of",
"the",
"drive",
"under",
"ArrayControllers",
"is",
"ssd"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L94-L99 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.has_rotational | def has_rotational(self):
"""Return true if any of the drive under ArrayControllers is ssd"""
for member in self.get_members():
if member.physical_drives.has_rotational:
return True
return False | python | def has_rotational(self):
"""Return true if any of the drive under ArrayControllers is ssd"""
for member in self.get_members():
if member.physical_drives.has_rotational:
return True
return False | [
"def",
"has_rotational",
"(",
"self",
")",
":",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
":",
"if",
"member",
".",
"physical_drives",
".",
"has_rotational",
":",
"return",
"True",
"return",
"False"
] | Return true if any of the drive under ArrayControllers is ssd | [
"Return",
"true",
"if",
"any",
"of",
"the",
"drive",
"under",
"ArrayControllers",
"is",
"ssd"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L103-L108 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.logical_raid_levels | def logical_raid_levels(self):
"""Gets the raid level for each logical volume
:returns the set of list of raid levels configured
"""
lg_raid_lvls = set()
for member in self.get_members():
lg_raid_lvls.update(member.logical_drives.logical_raid_levels)
return l... | python | def logical_raid_levels(self):
"""Gets the raid level for each logical volume
:returns the set of list of raid levels configured
"""
lg_raid_lvls = set()
for member in self.get_members():
lg_raid_lvls.update(member.logical_drives.logical_raid_levels)
return l... | [
"def",
"logical_raid_levels",
"(",
"self",
")",
":",
"lg_raid_lvls",
"=",
"set",
"(",
")",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
":",
"lg_raid_lvls",
".",
"update",
"(",
"member",
".",
"logical_drives",
".",
"logical_raid_levels",
")",... | Gets the raid level for each logical volume
:returns the set of list of raid levels configured | [
"Gets",
"the",
"raid",
"level",
"for",
"each",
"logical",
"volume"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L112-L120 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.array_controller_by_location | def array_controller_by_location(self, location):
"""Returns array controller instance by location
:returns Instance of array controller
"""
for member in self.get_members():
if member.location == location:
return member | python | def array_controller_by_location(self, location):
"""Returns array controller instance by location
:returns Instance of array controller
"""
for member in self.get_members():
if member.location == location:
return member | [
"def",
"array_controller_by_location",
"(",
"self",
",",
"location",
")",
":",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
":",
"if",
"member",
".",
"location",
"==",
"location",
":",
"return",
"member"
] | Returns array controller instance by location
:returns Instance of array controller | [
"Returns",
"array",
"controller",
"instance",
"by",
"location"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L142-L149 |
openstack/proliantutils | proliantutils/redfish/resources/system/storage/array_controller.py | HPEArrayControllerCollection.array_controller_by_model | def array_controller_by_model(self, model):
"""Returns array controller instance by model
:returns Instance of array controller
"""
for member in self.get_members():
if member.model == model:
return member | python | def array_controller_by_model(self, model):
"""Returns array controller instance by model
:returns Instance of array controller
"""
for member in self.get_members():
if member.model == model:
return member | [
"def",
"array_controller_by_model",
"(",
"self",
",",
"model",
")",
":",
"for",
"member",
"in",
"self",
".",
"get_members",
"(",
")",
":",
"if",
"member",
".",
"model",
"==",
"model",
":",
"return",
"member"
] | Returns array controller instance by model
:returns Instance of array controller | [
"Returns",
"array",
"controller",
"instance",
"by",
"model"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/system/storage/array_controller.py#L151-L158 |
openstack/proliantutils | proliantutils/redfish/utils.py | get_subresource_path_by | def get_subresource_path_by(resource, subresource_path):
"""Helper function to find the resource path
:param resource: ResourceBase instance from which the path is loaded.
:param subresource_path: JSON field to fetch the value from.
Either a string, or a list of strings in case of a nested fiel... | python | def get_subresource_path_by(resource, subresource_path):
"""Helper function to find the resource path
:param resource: ResourceBase instance from which the path is loaded.
:param subresource_path: JSON field to fetch the value from.
Either a string, or a list of strings in case of a nested fiel... | [
"def",
"get_subresource_path_by",
"(",
"resource",
",",
"subresource_path",
")",
":",
"if",
"isinstance",
"(",
"subresource_path",
",",
"six",
".",
"string_types",
")",
":",
"subresource_path",
"=",
"[",
"subresource_path",
"]",
"elif",
"not",
"subresource_path",
... | Helper function to find the resource path
:param resource: ResourceBase instance from which the path is loaded.
:param subresource_path: JSON field to fetch the value from.
Either a string, or a list of strings in case of a nested field.
It should also include the '@odata.id'
:raise... | [
"Helper",
"function",
"to",
"find",
"the",
"resource",
"path"
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/utils.py#L30-L59 |
openstack/proliantutils | proliantutils/redfish/utils.py | get_supported_boot_mode | def get_supported_boot_mode(supported_boot_mode):
"""Return bios and uefi support.
:param supported_boot_mode: Supported boot modes
:return: A tuple of 'true'/'false' based on bios and uefi
support respectively.
"""
boot_mode_bios = 'false'
boot_mode_uefi = '... | python | def get_supported_boot_mode(supported_boot_mode):
"""Return bios and uefi support.
:param supported_boot_mode: Supported boot modes
:return: A tuple of 'true'/'false' based on bios and uefi
support respectively.
"""
boot_mode_bios = 'false'
boot_mode_uefi = '... | [
"def",
"get_supported_boot_mode",
"(",
"supported_boot_mode",
")",
":",
"boot_mode_bios",
"=",
"'false'",
"boot_mode_uefi",
"=",
"'false'",
"if",
"(",
"supported_boot_mode",
"==",
"sys_cons",
".",
"SUPPORTED_LEGACY_BIOS_ONLY",
")",
":",
"boot_mode_bios",
"=",
"'true'",
... | Return bios and uefi support.
:param supported_boot_mode: Supported boot modes
:return: A tuple of 'true'/'false' based on bios and uefi
support respectively. | [
"Return",
"bios",
"and",
"uefi",
"support",
"."
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/utils.py#L62-L83 |
openstack/proliantutils | proliantutils/redfish/utils.py | get_allowed_operations | def get_allowed_operations(resource, subresouce_path):
"""Helper function to get the HTTP allowed methods.
:param resource: ResourceBase instance from which the path is loaded.
:param subresource_path: JSON field to fetch the value from.
Either a string, or a list of strings in case of a nested... | python | def get_allowed_operations(resource, subresouce_path):
"""Helper function to get the HTTP allowed methods.
:param resource: ResourceBase instance from which the path is loaded.
:param subresource_path: JSON field to fetch the value from.
Either a string, or a list of strings in case of a nested... | [
"def",
"get_allowed_operations",
"(",
"resource",
",",
"subresouce_path",
")",
":",
"uri",
"=",
"get_subresource_path_by",
"(",
"resource",
",",
"subresouce_path",
")",
"response",
"=",
"resource",
".",
"_conn",
".",
"get",
"(",
"path",
"=",
"uri",
")",
"retur... | Helper function to get the HTTP allowed methods.
:param resource: ResourceBase instance from which the path is loaded.
:param subresource_path: JSON field to fetch the value from.
Either a string, or a list of strings in case of a nested field.
:returns: A list of allowed HTTP methods. | [
"Helper",
"function",
"to",
"get",
"the",
"HTTP",
"allowed",
"methods",
"."
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/utils.py#L86-L96 |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2017_04_17/common/retry.py | _Retry._set_next_host_location | def _set_next_host_location(self, context):
'''
A function which sets the next host location on the request, if applicable.
:param ~azure.storage.models.RetryContext context:
The retry context containing the previous host location and the request
to evaluate and possi... | python | def _set_next_host_location(self, context):
'''
A function which sets the next host location on the request, if applicable.
:param ~azure.storage.models.RetryContext context:
The retry context containing the previous host location and the request
to evaluate and possi... | [
"def",
"_set_next_host_location",
"(",
"self",
",",
"context",
")",
":",
"if",
"len",
"(",
"context",
".",
"request",
".",
"host_locations",
")",
">",
"1",
":",
"# If there's more than one possible location, retry to the alternative",
"if",
"context",
".",
"location_m... | A function which sets the next host location on the request, if applicable.
:param ~azure.storage.models.RetryContext context:
The retry context containing the previous host location and the request
to evaluate and possibly modify. | [
"A",
"function",
"which",
"sets",
"the",
"next",
"host",
"location",
"on",
"the",
"request",
"if",
"applicable",
"."
] | train | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2017_04_17/common/retry.py#L98-L113 |
openstack/proliantutils | proliantutils/redfish/connector.py | HPEConnector._op | def _op(self, method, path='', data=None, headers=None):
"""Overrides the base method to support retrying the operation.
:param method: The HTTP method to be used, e.g: GET, POST,
PUT, PATCH, etc...
:param path: The sub-URI path to the resource.
:param data: Optional JSON da... | python | def _op(self, method, path='', data=None, headers=None):
"""Overrides the base method to support retrying the operation.
:param method: The HTTP method to be used, e.g: GET, POST,
PUT, PATCH, etc...
:param path: The sub-URI path to the resource.
:param data: Optional JSON da... | [
"def",
"_op",
"(",
"self",
",",
"method",
",",
"path",
"=",
"''",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"resp",
"=",
"super",
"(",
"HPEConnector",
",",
"self",
")",
".",
"_op",
"(",
"method",
",",
"path",
",",
"data",
... | Overrides the base method to support retrying the operation.
:param method: The HTTP method to be used, e.g: GET, POST,
PUT, PATCH, etc...
:param path: The sub-URI path to the resource.
:param data: Optional JSON data.
:param headers: Optional dictionary of headers.
... | [
"Overrides",
"the",
"base",
"method",
"to",
"support",
"retrying",
"the",
"operation",
"."
] | train | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/connector.py#L38-L55 |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2015_04_05/file/fileservice.py | FileService.generate_file_shared_access_signature | def generate_file_shared_access_signature(self, share_name,
directory_name=None,
file_name=None,
permission=None,
expiry=None,
... | python | def generate_file_shared_access_signature(self, share_name,
directory_name=None,
file_name=None,
permission=None,
expiry=None,
... | [
"def",
"generate_file_shared_access_signature",
"(",
"self",
",",
"share_name",
",",
"directory_name",
"=",
"None",
",",
"file_name",
"=",
"None",
",",
"permission",
"=",
"None",
",",
"expiry",
"=",
"None",
",",
"start",
"=",
"None",
",",
"id",
"=",
"None",
... | Generates a shared access signature for the file.
Use the returned signature with the sas_token parameter of FileService.
:param str share_name:
Name of share.
:param str directory_name:
Name of directory. SAS tokens cannot be created for directories, so
thi... | [
"Generates",
"a",
"shared",
"access",
"signature",
"for",
"the",
"file",
".",
"Use",
"the",
"returned",
"signature",
"with",
"the",
"sas_token",
"parameter",
"of",
"FileService",
"."
] | train | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2015_04_05/file/fileservice.py#L342-L442 |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2015_04_05/file/fileservice.py | FileService.set_file_service_properties | def set_file_service_properties(self, hour_metrics=None, minute_metrics=None,
cors=None, timeout=None):
'''
Sets the properties of a storage account's File service, including
Azure Storage Analytics. If an element (ex HourMetrics) is left as None, the
... | python | def set_file_service_properties(self, hour_metrics=None, minute_metrics=None,
cors=None, timeout=None):
'''
Sets the properties of a storage account's File service, including
Azure Storage Analytics. If an element (ex HourMetrics) is left as None, the
... | [
"def",
"set_file_service_properties",
"(",
"self",
",",
"hour_metrics",
"=",
"None",
",",
"minute_metrics",
"=",
"None",
",",
"cors",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"request",
"=",
"HTTPRequest",
"(",
")",
"request",
".",
"method",
"="... | Sets the properties of a storage account's File service, including
Azure Storage Analytics. If an element (ex HourMetrics) is left as None, the
existing settings on the service for that functionality are preserved.
:param Metrics hour_metrics:
The hour metrics settings provide a su... | [
"Sets",
"the",
"properties",
"of",
"a",
"storage",
"account",
"s",
"File",
"service",
"including",
"Azure",
"Storage",
"Analytics",
".",
"If",
"an",
"element",
"(",
"ex",
"HourMetrics",
")",
"is",
"left",
"as",
"None",
"the",
"existing",
"settings",
"on",
... | train | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2015_04_05/file/fileservice.py#L444-L477 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.