partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
vq_function
:Quality function using muparser to generate new Quality for every vertex<br>It's possibile to use the following per-vertex variables in the expression:<br>x, y, z, nx, ny, nz (normal), r, g, b (color), q (quality), rad, vi, <br>and all custom <i>vertex attributes</i> already defined by user. function function to...
meshlabxml/mp_func.py
def vq_function(script, function='vi', normalize=False, color=False): """:Quality function using muparser to generate new Quality for every vertex<br>It's possibile to use the following per-vertex variables in the expression:<br>x, y, z, nx, ny, nz (normal), r, g, b (color), q (quality), rad, vi, <br>and all custom...
def vq_function(script, function='vi', normalize=False, color=False): """:Quality function using muparser to generate new Quality for every vertex<br>It's possibile to use the following per-vertex variables in the expression:<br>x, y, z, nx, ny, nz (normal), r, g, b (color), q (quality), rad, vi, <br>and all custom...
[ ":", "Quality", "function", "using", "muparser", "to", "generate", "new", "Quality", "for", "every", "vertex<br", ">", "It", "s", "possibile", "to", "use", "the", "following", "per", "-", "vertex", "variables", "in", "the", "expression", ":", "<br", ">", "...
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/mp_func.py#L317-L345
[ "def", "vq_function", "(", "script", ",", "function", "=", "'vi'", ",", "normalize", "=", "False", ",", "color", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Per Vertex Quality Function\">\\n'", ",", "' <Param nam...
177cce21e92baca500f56a932d66bd9a33257af8
test
quatrefoil
Rainbow colored voronoi quatrefoil (3,4) torus knot
examples/quatrefoil_voronoi.py
def quatrefoil(): """ Rainbow colored voronoi quatrefoil (3,4) torus knot """ start_time = time.time() os.chdir(THIS_SCRIPTPATH) #ml_version = '1.3.4BETA' ml_version = '2016.12' # Add meshlabserver directory to OS PATH; omit this if it is already in # your PATH meshlabserver_path = 'C:...
def quatrefoil(): """ Rainbow colored voronoi quatrefoil (3,4) torus knot """ start_time = time.time() os.chdir(THIS_SCRIPTPATH) #ml_version = '1.3.4BETA' ml_version = '2016.12' # Add meshlabserver directory to OS PATH; omit this if it is already in # your PATH meshlabserver_path = 'C:...
[ "Rainbow", "colored", "voronoi", "quatrefoil", "(", "3", "4", ")", "torus", "knot" ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/examples/quatrefoil_voronoi.py#L37-L216
[ "def", "quatrefoil", "(", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "os", ".", "chdir", "(", "THIS_SCRIPTPATH", ")", "#ml_version = '1.3.4BETA'", "ml_version", "=", "'2016.12'", "# Add meshlabserver directory to OS PATH; omit this if it is already in", ...
177cce21e92baca500f56a932d66bd9a33257af8
test
flip
Invert faces orientation, flipping the normals of the mesh. If requested, it tries to guess the right orientation; mainly it decides to flip all the faces if the minimum/maximum vertexes have not outward point normals for a few directions. Works well for single component watertight objects. Args: ...
meshlabxml/normals.py
def flip(script, force_flip=False, selected=False): """ Invert faces orientation, flipping the normals of the mesh. If requested, it tries to guess the right orientation; mainly it decides to flip all the faces if the minimum/maximum vertexes have not outward point normals for a few directions. Works w...
def flip(script, force_flip=False, selected=False): """ Invert faces orientation, flipping the normals of the mesh. If requested, it tries to guess the right orientation; mainly it decides to flip all the faces if the minimum/maximum vertexes have not outward point normals for a few directions. Works w...
[ "Invert", "faces", "orientation", "flipping", "the", "normals", "of", "the", "mesh", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/normals.py#L33-L69
[ "def", "flip", "(", "script", ",", "force_flip", "=", "False", ",", "selected", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Invert Faces Orientation\">\\n'", ",", "' <Param name=\"forceFlip\" '", ",", "'value=\"{}\" ...
177cce21e92baca500f56a932d66bd9a33257af8
test
point_sets
Compute the normals of the vertices of a mesh without exploiting the triangle connectivity, useful for dataset with no faces. Args: script: the FilterScript object or script filename to write the filter to. neighbors (int): The number of neighbors used to estimate normals. ...
meshlabxml/normals.py
def point_sets(script, neighbors=10, smooth_iteration=0, flip=False, viewpoint_pos=(0.0, 0.0, 0.0)): """ Compute the normals of the vertices of a mesh without exploiting the triangle connectivity, useful for dataset with no faces. Args: script: the FilterScript object or script f...
def point_sets(script, neighbors=10, smooth_iteration=0, flip=False, viewpoint_pos=(0.0, 0.0, 0.0)): """ Compute the normals of the vertices of a mesh without exploiting the triangle connectivity, useful for dataset with no faces. Args: script: the FilterScript object or script f...
[ "Compute", "the", "normals", "of", "the", "vertices", "of", "a", "mesh", "without", "exploiting", "the", "triangle", "connectivity", "useful", "for", "dataset", "with", "no", "faces", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/normals.py#L87-L137
[ "def", "point_sets", "(", "script", ",", "neighbors", "=", "10", ",", "smooth_iteration", "=", "0", ",", "flip", "=", "False", ",", "viewpoint_pos", "=", "(", "0.0", ",", "0.0", ",", "0.0", ")", ")", ":", "filter_xml", "=", "''", ".", "join", "(", ...
177cce21e92baca500f56a932d66bd9a33257af8
test
laplacian
Laplacian smooth of the mesh: for each vertex it calculates the average position with nearest vertex Args: script: the FilterScript object or script filename to write the filter to. iterations (int): The number of times that the whole algorithm (normal smoothing + ve...
meshlabxml/smooth.py
def laplacian(script, iterations=1, boundary=True, cotangent_weight=True, selected=False): """ Laplacian smooth of the mesh: for each vertex it calculates the average position with nearest vertex Args: script: the FilterScript object or script filename to write the fil...
def laplacian(script, iterations=1, boundary=True, cotangent_weight=True, selected=False): """ Laplacian smooth of the mesh: for each vertex it calculates the average position with nearest vertex Args: script: the FilterScript object or script filename to write the fil...
[ "Laplacian", "smooth", "of", "the", "mesh", ":", "for", "each", "vertex", "it", "calculates", "the", "average", "position", "with", "nearest", "vertex" ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/smooth.py#L5-L56
[ "def", "laplacian", "(", "script", ",", "iterations", "=", "1", ",", "boundary", "=", "True", ",", "cotangent_weight", "=", "True", ",", "selected", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Laplacian Smooth\"...
177cce21e92baca500f56a932d66bd9a33257af8
test
taubin
The lambda & mu Taubin smoothing, it make two steps of smoothing, forth and back, for each iteration. Based on: Gabriel Taubin "A signal processing approach to fair surface design" Siggraph 1995 Args: script: the FilterScript object or script filename to write the filte...
meshlabxml/smooth.py
def taubin(script, iterations=10, t_lambda=0.5, t_mu=-0.53, selected=False): """ The lambda & mu Taubin smoothing, it make two steps of smoothing, forth and back, for each iteration. Based on: Gabriel Taubin "A signal processing approach to fair surface design" Siggraph 1995 Args: ...
def taubin(script, iterations=10, t_lambda=0.5, t_mu=-0.53, selected=False): """ The lambda & mu Taubin smoothing, it make two steps of smoothing, forth and back, for each iteration. Based on: Gabriel Taubin "A signal processing approach to fair surface design" Siggraph 1995 Args: ...
[ "The", "lambda", "&", "mu", "Taubin", "smoothing", "it", "make", "two", "steps", "of", "smoothing", "forth", "and", "back", "for", "each", "iteration", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/smooth.py#L75-L126
[ "def", "taubin", "(", "script", ",", "iterations", "=", "10", ",", "t_lambda", "=", "0.5", ",", "t_mu", "=", "-", "0.53", ",", "selected", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Taubin Smooth\">\\n'", "...
177cce21e92baca500f56a932d66bd9a33257af8
test
twostep
Two Step Smoothing, a feature preserving/enhancing fairing filter. It is based on a Normal Smoothing step where similar normals are averaged together and a step where the vertexes are fitted on the new normals. Based on: A. Belyaev and Y. Ohtake, "A Comparison of Mesh Smoothing Methods" Proc. ...
meshlabxml/smooth.py
def twostep(script, iterations=3, angle_threshold=60, normal_steps=20, fit_steps=20, selected=False): """ Two Step Smoothing, a feature preserving/enhancing fairing filter. It is based on a Normal Smoothing step where similar normals are averaged together and a step where the vertexes are fitte...
def twostep(script, iterations=3, angle_threshold=60, normal_steps=20, fit_steps=20, selected=False): """ Two Step Smoothing, a feature preserving/enhancing fairing filter. It is based on a Normal Smoothing step where similar normals are averaged together and a step where the vertexes are fitte...
[ "Two", "Step", "Smoothing", "a", "feature", "preserving", "/", "enhancing", "fairing", "filter", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/smooth.py#L129-L194
[ "def", "twostep", "(", "script", ",", "iterations", "=", "3", ",", "angle_threshold", "=", "60", ",", "normal_steps", "=", "20", ",", "fit_steps", "=", "20", ",", "selected", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' ...
177cce21e92baca500f56a932d66bd9a33257af8
test
depth
A laplacian smooth that is constrained to move vertices only along the view direction. Args: script: the FilterScript object or script filename to write the filter to. iterations (int): The number of times that the whole algorithm (normal smoothing + vertex fitting) ...
meshlabxml/smooth.py
def depth(script, iterations=3, viewpoint=(0, 0, 0), selected=False): """ A laplacian smooth that is constrained to move vertices only along the view direction. Args: script: the FilterScript object or script filename to write the filter to. iterations (int): The number of t...
def depth(script, iterations=3, viewpoint=(0, 0, 0), selected=False): """ A laplacian smooth that is constrained to move vertices only along the view direction. Args: script: the FilterScript object or script filename to write the filter to. iterations (int): The number of t...
[ "A", "laplacian", "smooth", "that", "is", "constrained", "to", "move", "vertices", "only", "along", "the", "view", "direction", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/smooth.py#L197-L239
[ "def", "depth", "(", "script", ",", "iterations", "=", "3", ",", "viewpoint", "=", "(", "0", ",", "0", ",", "0", ")", ",", "selected", "=", "False", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Depth Smooth\">\\n'", ",",...
177cce21e92baca500f56a932d66bd9a33257af8
test
measure_aabb
Measure the axis aligned bounding box (aabb) of a mesh in multiple coordinate systems. Args: fbasename (str): filename of input model log (str): filename of log file coord_system (enum in ['CARTESIAN', 'CYLINDRICAL'] Coordinate system to use: 'CARTESIAN': lis...
meshlabxml/files.py
def measure_aabb(fbasename=None, log=None, coord_system='CARTESIAN'): """ Measure the axis aligned bounding box (aabb) of a mesh in multiple coordinate systems. Args: fbasename (str): filename of input model log (str): filename of log file coord_system (enum in ['CARTESIAN', 'CYLIND...
def measure_aabb(fbasename=None, log=None, coord_system='CARTESIAN'): """ Measure the axis aligned bounding box (aabb) of a mesh in multiple coordinate systems. Args: fbasename (str): filename of input model log (str): filename of log file coord_system (enum in ['CARTESIAN', 'CYLIND...
[ "Measure", "the", "axis", "aligned", "bounding", "box", "(", "aabb", ")", "of", "a", "mesh", "in", "multiple", "coordinate", "systems", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L17-L111
[ "def", "measure_aabb", "(", "fbasename", "=", "None", ",", "log", "=", "None", ",", "coord_system", "=", "'CARTESIAN'", ")", ":", "# TODO: add center point, spherical coordinate system", "fext", "=", "os", ".", "path", ".", "splitext", "(", "fbasename", ")", "["...
177cce21e92baca500f56a932d66bd9a33257af8
test
measure_section
Measure a cross section of a mesh Perform a plane cut in one of the major axes (X, Y, Z). If you want to cut on a different plane you will need to rotate the model in place, perform the cut, and rotate it back. Args: fbasename (str): filename of input model log (str): filename ...
meshlabxml/files.py
def measure_section(fbasename=None, log=None, axis='z', offset=0.0, rotate_x_angle=None, ml_version=ml_version): """Measure a cross section of a mesh Perform a plane cut in one of the major axes (X, Y, Z). If you want to cut on a different plane you will need to rotate the model in ...
def measure_section(fbasename=None, log=None, axis='z', offset=0.0, rotate_x_angle=None, ml_version=ml_version): """Measure a cross section of a mesh Perform a plane cut in one of the major axes (X, Y, Z). If you want to cut on a different plane you will need to rotate the model in ...
[ "Measure", "a", "cross", "section", "of", "a", "mesh", "Perform", "a", "plane", "cut", "in", "one", "of", "the", "major", "axes", "(", "X", "Y", "Z", ")", ".", "If", "you", "want", "to", "cut", "on", "a", "different", "plane", "you", "will", "need"...
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L114-L149
[ "def", "measure_section", "(", "fbasename", "=", "None", ",", "log", "=", "None", ",", "axis", "=", "'z'", ",", "offset", "=", "0.0", ",", "rotate_x_angle", "=", "None", ",", "ml_version", "=", "ml_version", ")", ":", "ml_script1_file", "=", "'TEMP3D_measu...
177cce21e92baca500f56a932d66bd9a33257af8
test
polylinesort
Sort separate line segments in obj format into a continuous polyline or polylines. NOT FINISHED; DO NOT USE Also measures the length of each polyline Return polyline and polylineMeta (lengths)
meshlabxml/files.py
def polylinesort(fbasename=None, log=None): """Sort separate line segments in obj format into a continuous polyline or polylines. NOT FINISHED; DO NOT USE Also measures the length of each polyline Return polyline and polylineMeta (lengths) """ fext = os.path.splitext(fbasename)[1][1:].strip()...
def polylinesort(fbasename=None, log=None): """Sort separate line segments in obj format into a continuous polyline or polylines. NOT FINISHED; DO NOT USE Also measures the length of each polyline Return polyline and polylineMeta (lengths) """ fext = os.path.splitext(fbasename)[1][1:].strip()...
[ "Sort", "separate", "line", "segments", "in", "obj", "format", "into", "a", "continuous", "polyline", "or", "polylines", ".", "NOT", "FINISHED", ";", "DO", "NOT", "USE" ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L152-L190
[ "def", "polylinesort", "(", "fbasename", "=", "None", ",", "log", "=", "None", ")", ":", "fext", "=", "os", ".", "path", ".", "splitext", "(", "fbasename", ")", "[", "1", "]", "[", "1", ":", "]", ".", "strip", "(", ")", ".", "lower", "(", ")", ...
177cce21e92baca500f56a932d66bd9a33257af8
test
measure_topology
Measures mesh topology Args: fbasename (str): input filename. log (str): filename to log output Returns: dict: dictionary with the following keys: vert_num (int): number of vertices edge_num (int): number of edges face_num (int): number of faces ...
meshlabxml/files.py
def measure_topology(fbasename=None, log=None, ml_version=ml_version): """Measures mesh topology Args: fbasename (str): input filename. log (str): filename to log output Returns: dict: dictionary with the following keys: vert_num (int): number of vertices ed...
def measure_topology(fbasename=None, log=None, ml_version=ml_version): """Measures mesh topology Args: fbasename (str): input filename. log (str): filename to log output Returns: dict: dictionary with the following keys: vert_num (int): number of vertices ed...
[ "Measures", "mesh", "topology" ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L220-L250
[ "def", "measure_topology", "(", "fbasename", "=", "None", ",", "log", "=", "None", ",", "ml_version", "=", "ml_version", ")", ":", "ml_script1_file", "=", "'TEMP3D_measure_topology.mlx'", "ml_script1", "=", "mlx", ".", "FilterScript", "(", "file_in", "=", "fbase...
177cce21e92baca500f56a932d66bd9a33257af8
test
measure_all
Measures mesh geometry, aabb and topology.
meshlabxml/files.py
def measure_all(fbasename=None, log=None, ml_version=ml_version): """Measures mesh geometry, aabb and topology.""" ml_script1_file = 'TEMP3D_measure_gAndT.mlx' if ml_version == '1.3.4BETA': file_out = 'TEMP3D_aabb.xyz' else: file_out = None ml_script1 = mlx.FilterScript(file_in=fbas...
def measure_all(fbasename=None, log=None, ml_version=ml_version): """Measures mesh geometry, aabb and topology.""" ml_script1_file = 'TEMP3D_measure_gAndT.mlx' if ml_version == '1.3.4BETA': file_out = 'TEMP3D_aabb.xyz' else: file_out = None ml_script1 = mlx.FilterScript(file_in=fbas...
[ "Measures", "mesh", "geometry", "aabb", "and", "topology", "." ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L253-L279
[ "def", "measure_all", "(", "fbasename", "=", "None", ",", "log", "=", "None", ",", "ml_version", "=", "ml_version", ")", ":", "ml_script1_file", "=", "'TEMP3D_measure_gAndT.mlx'", "if", "ml_version", "==", "'1.3.4BETA'", ":", "file_out", "=", "'TEMP3D_aabb.xyz'", ...
177cce21e92baca500f56a932d66bd9a33257af8
test
measure_dimension
Measure a dimension of a mesh
meshlabxml/files.py
def measure_dimension(fbasename=None, log=None, axis1=None, offset1=0.0, axis2=None, offset2=0.0, ml_version=ml_version): """Measure a dimension of a mesh""" axis1 = axis1.lower() axis2 = axis2.lower() ml_script1_file = 'TEMP3D_measure_dimension.mlx' file_out = 'TEMP3D_measure_...
def measure_dimension(fbasename=None, log=None, axis1=None, offset1=0.0, axis2=None, offset2=0.0, ml_version=ml_version): """Measure a dimension of a mesh""" axis1 = axis1.lower() axis2 = axis2.lower() ml_script1_file = 'TEMP3D_measure_dimension.mlx' file_out = 'TEMP3D_measure_...
[ "Measure", "a", "dimension", "of", "a", "mesh" ]
3DLIRIOUS/MeshLabXML
python
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/files.py#L282-L322
[ "def", "measure_dimension", "(", "fbasename", "=", "None", ",", "log", "=", "None", ",", "axis1", "=", "None", ",", "offset1", "=", "0.0", ",", "axis2", "=", "None", ",", "offset2", "=", "0.0", ",", "ml_version", "=", "ml_version", ")", ":", "axis1", ...
177cce21e92baca500f56a932d66bd9a33257af8
test
lowercase_ext
This is a helper used by UploadSet.save to provide lowercase extensions for all processed files, to compare with configured extensions in the same case. .. versionchanged:: 0.1.4 Filenames without extensions are no longer lowercased, only the extension is returned in lowercase, if an extensio...
flask_uploads.py
def lowercase_ext(filename): """ This is a helper used by UploadSet.save to provide lowercase extensions for all processed files, to compare with configured extensions in the same case. .. versionchanged:: 0.1.4 Filenames without extensions are no longer lowercased, only the extension...
def lowercase_ext(filename): """ This is a helper used by UploadSet.save to provide lowercase extensions for all processed files, to compare with configured extensions in the same case. .. versionchanged:: 0.1.4 Filenames without extensions are no longer lowercased, only the extension...
[ "This", "is", "a", "helper", "used", "by", "UploadSet", ".", "save", "to", "provide", "lowercase", "extensions", "for", "all", "processed", "files", "to", "compare", "with", "configured", "extensions", "in", "the", "same", "case", "." ]
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L88-L106
[ "def", "lowercase_ext", "(", "filename", ")", ":", "if", "'.'", "in", "filename", ":", "main", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "return", "main", "+", "ext", ".", "lower", "(", ")", "# For consistency with os.pat...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
patch_request_class
By default, Flask will accept uploads to an arbitrary size. While Werkzeug switches uploads from memory to a temporary file when they hit 500 KiB, it's still possible for someone to overload your disk space with a gigantic file. This patches the app's request class's `~werkzeug.BaseRequest.max_cont...
flask_uploads.py
def patch_request_class(app, size=64 * 1024 * 1024): """ By default, Flask will accept uploads to an arbitrary size. While Werkzeug switches uploads from memory to a temporary file when they hit 500 KiB, it's still possible for someone to overload your disk space with a gigantic file. This patc...
def patch_request_class(app, size=64 * 1024 * 1024): """ By default, Flask will accept uploads to an arbitrary size. While Werkzeug switches uploads from memory to a temporary file when they hit 500 KiB, it's still possible for someone to overload your disk space with a gigantic file. This patc...
[ "By", "default", "Flask", "will", "accept", "uploads", "to", "an", "arbitrary", "size", ".", "While", "Werkzeug", "switches", "uploads", "from", "memory", "to", "a", "temporary", "file", "when", "they", "hit", "500", "KiB", "it", "s", "still", "possible", ...
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L115-L149
[ "def", "patch_request_class", "(", "app", ",", "size", "=", "64", "*", "1024", "*", "1024", ")", ":", "if", "size", "is", "None", ":", "if", "isinstance", "(", "app", ".", "request_class", ".", "__dict__", "[", "'max_content_length'", "]", ",", "property...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
config_for_set
This is a helper function for `configure_uploads` that extracts the configuration for a single set. :param uset: The upload set. :param app: The app to load the configuration from. :param defaults: A dict with keys `url` and `dest` from the `UPLOADS_DEFAULT_DEST` and `DEFAULT_UPLOA...
flask_uploads.py
def config_for_set(uset, app, defaults=None): """ This is a helper function for `configure_uploads` that extracts the configuration for a single set. :param uset: The upload set. :param app: The app to load the configuration from. :param defaults: A dict with keys `url` and `dest` from the ...
def config_for_set(uset, app, defaults=None): """ This is a helper function for `configure_uploads` that extracts the configuration for a single set. :param uset: The upload set. :param app: The app to load the configuration from. :param defaults: A dict with keys `url` and `dest` from the ...
[ "This", "is", "a", "helper", "function", "for", "configure_uploads", "that", "extracts", "the", "configuration", "for", "a", "single", "set", "." ]
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L152-L190
[ "def", "config_for_set", "(", "uset", ",", "app", ",", "defaults", "=", "None", ")", ":", "config", "=", "app", ".", "config", "prefix", "=", "'UPLOADED_%s_'", "%", "uset", ".", "name", ".", "upper", "(", ")", "using_defaults", "=", "False", "if", "def...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
configure_uploads
Call this after the app has been configured. It will go through all the upload sets, get their configuration, and store the configuration on the app. It will also register the uploads module if it hasn't been set. This can be called multiple times with different upload sets. .. versionchanged:: 0.1.3 ...
flask_uploads.py
def configure_uploads(app, upload_sets): """ Call this after the app has been configured. It will go through all the upload sets, get their configuration, and store the configuration on the app. It will also register the uploads module if it hasn't been set. This can be called multiple times with di...
def configure_uploads(app, upload_sets): """ Call this after the app has been configured. It will go through all the upload sets, get their configuration, and store the configuration on the app. It will also register the uploads module if it hasn't been set. This can be called multiple times with di...
[ "Call", "this", "after", "the", "app", "has", "been", "configured", ".", "It", "will", "go", "through", "all", "the", "upload", "sets", "get", "their", "configuration", "and", "store", "the", "configuration", "on", "the", "app", ".", "It", "will", "also", ...
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L193-L222
[ "def", "configure_uploads", "(", "app", ",", "upload_sets", ")", ":", "if", "isinstance", "(", "upload_sets", ",", "UploadSet", ")", ":", "upload_sets", "=", "(", "upload_sets", ",", ")", "if", "not", "hasattr", "(", "app", ",", "'upload_set_config'", ")", ...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
UploadSet.config
This gets the current configuration. By default, it looks up the current application and gets the configuration from there. But if you don't want to go to the full effort of setting an application, or it's otherwise outside of a request context, set the `_config` attribute to an `UploadC...
flask_uploads.py
def config(self): """ This gets the current configuration. By default, it looks up the current application and gets the configuration from there. But if you don't want to go to the full effort of setting an application, or it's otherwise outside of a request context, set the `_co...
def config(self): """ This gets the current configuration. By default, it looks up the current application and gets the configuration from there. But if you don't want to go to the full effort of setting an application, or it's otherwise outside of a request context, set the `_co...
[ "This", "gets", "the", "current", "configuration", ".", "By", "default", "it", "looks", "up", "the", "current", "application", "and", "gets", "the", "configuration", "from", "there", ".", "But", "if", "you", "don", "t", "want", "to", "go", "to", "the", "...
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L315-L329
[ "def", "config", "(", "self", ")", ":", "if", "self", ".", "_config", "is", "not", "None", ":", "return", "self", ".", "_config", "try", ":", "return", "current_app", ".", "upload_set_config", "[", "self", ".", "name", "]", "except", "AttributeError", ":...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
UploadSet.url
This function gets the URL a file uploaded to this set would be accessed at. It doesn't check whether said file exists. :param filename: The filename to return the URL for.
flask_uploads.py
def url(self, filename): """ This function gets the URL a file uploaded to this set would be accessed at. It doesn't check whether said file exists. :param filename: The filename to return the URL for. """ base = self.config.base_url if base is None: ...
def url(self, filename): """ This function gets the URL a file uploaded to this set would be accessed at. It doesn't check whether said file exists. :param filename: The filename to return the URL for. """ base = self.config.base_url if base is None: ...
[ "This", "function", "gets", "the", "URL", "a", "file", "uploaded", "to", "this", "set", "would", "be", "accessed", "at", ".", "It", "doesn", "t", "check", "whether", "said", "file", "exists", "." ]
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L331-L343
[ "def", "url", "(", "self", ",", "filename", ")", ":", "base", "=", "self", ".", "config", ".", "base_url", "if", "base", "is", "None", ":", "return", "url_for", "(", "'_uploads.uploaded_file'", ",", "setname", "=", "self", ".", "name", ",", "filename", ...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
UploadSet.path
This returns the absolute path of a file uploaded to this set. It doesn't actually check whether said file exists. :param filename: The filename to return the path for. :param folder: The subfolder within the upload set previously used to save to.
flask_uploads.py
def path(self, filename, folder=None): """ This returns the absolute path of a file uploaded to this set. It doesn't actually check whether said file exists. :param filename: The filename to return the path for. :param folder: The subfolder within the upload set previously used ...
def path(self, filename, folder=None): """ This returns the absolute path of a file uploaded to this set. It doesn't actually check whether said file exists. :param filename: The filename to return the path for. :param folder: The subfolder within the upload set previously used ...
[ "This", "returns", "the", "absolute", "path", "of", "a", "file", "uploaded", "to", "this", "set", ".", "It", "doesn", "t", "actually", "check", "whether", "said", "file", "exists", "." ]
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L345-L358
[ "def", "path", "(", "self", ",", "filename", ",", "folder", "=", "None", ")", ":", "if", "folder", "is", "not", "None", ":", "target_folder", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config", ".", "destination", ",", "folder", ")", "...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
UploadSet.extension_allowed
This determines whether a specific extension is allowed. It is called by `file_allowed`, so if you override that but still want to check extensions, call back into this. :param ext: The extension to check, without the dot.
flask_uploads.py
def extension_allowed(self, ext): """ This determines whether a specific extension is allowed. It is called by `file_allowed`, so if you override that but still want to check extensions, call back into this. :param ext: The extension to check, without the dot. """ ...
def extension_allowed(self, ext): """ This determines whether a specific extension is allowed. It is called by `file_allowed`, so if you override that but still want to check extensions, call back into this. :param ext: The extension to check, without the dot. """ ...
[ "This", "determines", "whether", "a", "specific", "extension", "is", "allowed", ".", "It", "is", "called", "by", "file_allowed", "so", "if", "you", "override", "that", "but", "still", "want", "to", "check", "extensions", "call", "back", "into", "this", "." ]
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L372-L381
[ "def", "extension_allowed", "(", "self", ",", "ext", ")", ":", "return", "(", "(", "ext", "in", "self", ".", "config", ".", "allow", ")", "or", "(", "ext", "in", "self", ".", "extensions", "and", "ext", "not", "in", "self", ".", "config", ".", "den...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
UploadSet.save
This saves a `werkzeug.FileStorage` into this upload set. If the upload is not allowed, an `UploadNotAllowed` error will be raised. Otherwise, the file will be saved and its name (including the folder) will be returned. :param storage: The uploaded file to save. :param folder: T...
flask_uploads.py
def save(self, storage, folder=None, name=None): """ This saves a `werkzeug.FileStorage` into this upload set. If the upload is not allowed, an `UploadNotAllowed` error will be raised. Otherwise, the file will be saved and its name (including the folder) will be returned. ...
def save(self, storage, folder=None, name=None): """ This saves a `werkzeug.FileStorage` into this upload set. If the upload is not allowed, an `UploadNotAllowed` error will be raised. Otherwise, the file will be saved and its name (including the folder) will be returned. ...
[ "This", "saves", "a", "werkzeug", ".", "FileStorage", "into", "this", "upload", "set", ".", "If", "the", "upload", "is", "not", "allowed", "an", "UploadNotAllowed", "error", "will", "be", "raised", ".", "Otherwise", "the", "file", "will", "be", "saved", "a...
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L386-L431
[ "def", "save", "(", "self", ",", "storage", ",", "folder", "=", "None", ",", "name", "=", "None", ")", ":", "if", "not", "isinstance", "(", "storage", ",", "FileStorage", ")", ":", "raise", "TypeError", "(", "\"storage must be a werkzeug.FileStorage\"", ")",...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
UploadSet.resolve_conflict
If a file with the selected name already exists in the target folder, this method is called to resolve the conflict. It should return a new basename for the file. The default implementation splits the name and extension and adds a suffix to the name consisting of an underscore and a num...
flask_uploads.py
def resolve_conflict(self, target_folder, basename): """ If a file with the selected name already exists in the target folder, this method is called to resolve the conflict. It should return a new basename for the file. The default implementation splits the name and extension an...
def resolve_conflict(self, target_folder, basename): """ If a file with the selected name already exists in the target folder, this method is called to resolve the conflict. It should return a new basename for the file. The default implementation splits the name and extension an...
[ "If", "a", "file", "with", "the", "selected", "name", "already", "exists", "in", "the", "target", "folder", "this", "method", "is", "called", "to", "resolve", "the", "conflict", ".", "It", "should", "return", "a", "new", "basename", "for", "the", "file", ...
maxcountryman/flask-uploads
python
https://github.com/maxcountryman/flask-uploads/blob/dc24fa0c53d605876e5b4502cadffdf1a4345b1d/flask_uploads.py#L433-L452
[ "def", "resolve_conflict", "(", "self", ",", "target_folder", ",", "basename", ")", ":", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "basename", ")", "count", "=", "0", "while", "True", ":", "count", "=", "count", "+", "1", "new...
dc24fa0c53d605876e5b4502cadffdf1a4345b1d
test
get_vprof_version
Returns actual version specified in filename.
setup.py
def get_vprof_version(filename): """Returns actual version specified in filename.""" with open(filename) as src_file: version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", src_file.read(), re.M) if version_match: return version_match.group...
def get_vprof_version(filename): """Returns actual version specified in filename.""" with open(filename) as src_file: version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", src_file.read(), re.M) if version_match: return version_match.group...
[ "Returns", "actual", "version", "specified", "in", "filename", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/setup.py#L112-L119
[ "def", "get_vprof_version", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "src_file", ":", "version_match", "=", "re", ".", "search", "(", "r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\"", ",", "src_file", ".", "read", "(", ")", ",", "r...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_remove_duplicates
Removes duplicate objects. http://www.peterbe.com/plog/uniqifiers-benchmark.
vprof/memory_profiler.py
def _remove_duplicates(objects): """Removes duplicate objects. http://www.peterbe.com/plog/uniqifiers-benchmark. """ seen, uniq = set(), [] for obj in objects: obj_id = id(obj) if obj_id in seen: continue seen.add(obj_id) uniq.append(obj) return uniq
def _remove_duplicates(objects): """Removes duplicate objects. http://www.peterbe.com/plog/uniqifiers-benchmark. """ seen, uniq = set(), [] for obj in objects: obj_id = id(obj) if obj_id in seen: continue seen.add(obj_id) uniq.append(obj) return uniq
[ "Removes", "duplicate", "objects", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L21-L33
[ "def", "_remove_duplicates", "(", "objects", ")", ":", "seen", ",", "uniq", "=", "set", "(", ")", ",", "[", "]", "for", "obj", "in", "objects", ":", "obj_id", "=", "id", "(", "obj", ")", "if", "obj_id", "in", "seen", ":", "continue", "seen", ".", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_get_obj_count_difference
Returns count difference in two collections of Python objects.
vprof/memory_profiler.py
def _get_obj_count_difference(objs1, objs2): """Returns count difference in two collections of Python objects.""" clean_obj_list1 = _process_in_memory_objects(objs1) clean_obj_list2 = _process_in_memory_objects(objs2) obj_count_1 = _get_object_count_by_type(clean_obj_list1) obj_count_2 = _get_object...
def _get_obj_count_difference(objs1, objs2): """Returns count difference in two collections of Python objects.""" clean_obj_list1 = _process_in_memory_objects(objs1) clean_obj_list2 = _process_in_memory_objects(objs2) obj_count_1 = _get_object_count_by_type(clean_obj_list1) obj_count_2 = _get_object...
[ "Returns", "count", "difference", "in", "two", "collections", "of", "Python", "objects", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L56-L62
[ "def", "_get_obj_count_difference", "(", "objs1", ",", "objs2", ")", ":", "clean_obj_list1", "=", "_process_in_memory_objects", "(", "objs1", ")", "clean_obj_list2", "=", "_process_in_memory_objects", "(", "objs2", ")", "obj_count_1", "=", "_get_object_count_by_type", "...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_format_obj_count
Formats object count.
vprof/memory_profiler.py
def _format_obj_count(objects): """Formats object count.""" result = [] regex = re.compile(r'<(?P<type>\w+) \'(?P<name>\S+)\'>') for obj_type, obj_count in objects.items(): if obj_count != 0: match = re.findall(regex, repr(obj_type)) if match: obj_type, ob...
def _format_obj_count(objects): """Formats object count.""" result = [] regex = re.compile(r'<(?P<type>\w+) \'(?P<name>\S+)\'>') for obj_type, obj_count in objects.items(): if obj_count != 0: match = re.findall(regex, repr(obj_type)) if match: obj_type, ob...
[ "Formats", "object", "count", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L65-L75
[ "def", "_format_obj_count", "(", "objects", ")", ":", "result", "=", "[", "]", "regex", "=", "re", ".", "compile", "(", "r'<(?P<type>\\w+) \\'(?P<name>\\S+)\\'>'", ")", "for", "obj_type", ",", "obj_count", "in", "objects", ".", "items", "(", ")", ":", "if", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeEventsTracker._trace_memory_usage
Checks memory usage when 'line' event occur.
vprof/memory_profiler.py
def _trace_memory_usage(self, frame, event, arg): #pylint: disable=unused-argument """Checks memory usage when 'line' event occur.""" if event == 'line' and frame.f_code.co_filename in self.target_modules: self._events_list.append( (frame.f_lineno, self._process.memory_info(...
def _trace_memory_usage(self, frame, event, arg): #pylint: disable=unused-argument """Checks memory usage when 'line' event occur.""" if event == 'line' and frame.f_code.co_filename in self.target_modules: self._events_list.append( (frame.f_lineno, self._process.memory_info(...
[ "Checks", "memory", "usage", "when", "line", "event", "occur", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L101-L107
[ "def", "_trace_memory_usage", "(", "self", ",", "frame", ",", "event", ",", "arg", ")", ":", "#pylint: disable=unused-argument", "if", "event", "==", "'line'", "and", "frame", ".", "f_code", ".", "co_filename", "in", "self", ".", "target_modules", ":", "self",...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeEventsTracker.code_events
Returns processed memory usage.
vprof/memory_profiler.py
def code_events(self): """Returns processed memory usage.""" if self._resulting_events: return self._resulting_events for i, (lineno, mem, func, fname) in enumerate(self._events_list): mem_in_mb = float(mem - self.mem_overhead) / _BYTES_IN_MB if (self._resulti...
def code_events(self): """Returns processed memory usage.""" if self._resulting_events: return self._resulting_events for i, (lineno, mem, func, fname) in enumerate(self._events_list): mem_in_mb = float(mem - self.mem_overhead) / _BYTES_IN_MB if (self._resulti...
[ "Returns", "processed", "memory", "usage", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L110-L125
[ "def", "code_events", "(", "self", ")", ":", "if", "self", ".", "_resulting_events", ":", "return", "self", ".", "_resulting_events", "for", "i", ",", "(", "lineno", ",", "mem", ",", "func", ",", "fname", ")", "in", "enumerate", "(", "self", ".", "_eve...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeEventsTracker.obj_overhead
Returns all objects that are considered a profiler overhead. Objects are hardcoded for convenience.
vprof/memory_profiler.py
def obj_overhead(self): """Returns all objects that are considered a profiler overhead. Objects are hardcoded for convenience. """ overhead = [ self, self._resulting_events, self._events_list, self._process ] overhead_count ...
def obj_overhead(self): """Returns all objects that are considered a profiler overhead. Objects are hardcoded for convenience. """ overhead = [ self, self._resulting_events, self._events_list, self._process ] overhead_count ...
[ "Returns", "all", "objects", "that", "are", "considered", "a", "profiler", "overhead", ".", "Objects", "are", "hardcoded", "for", "convenience", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L128-L142
[ "def", "obj_overhead", "(", "self", ")", ":", "overhead", "=", "[", "self", ",", "self", ".", "_resulting_events", ",", "self", ".", "_events_list", ",", "self", ".", "_process", "]", "overhead_count", "=", "_get_object_count_by_type", "(", "overhead", ")", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeEventsTracker.compute_mem_overhead
Returns memory overhead.
vprof/memory_profiler.py
def compute_mem_overhead(self): """Returns memory overhead.""" self.mem_overhead = (self._process.memory_info().rss - builtins.initial_rss_size)
def compute_mem_overhead(self): """Returns memory overhead.""" self.mem_overhead = (self._process.memory_info().rss - builtins.initial_rss_size)
[ "Returns", "memory", "overhead", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L144-L147
[ "def", "compute_mem_overhead", "(", "self", ")", ":", "self", ".", "mem_overhead", "=", "(", "self", ".", "_process", ".", "memory_info", "(", ")", ".", "rss", "-", "builtins", ".", "initial_rss_size", ")" ]
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
MemoryProfiler.profile_package
Returns memory stats for a package.
vprof/memory_profiler.py
def profile_package(self): """Returns memory stats for a package.""" target_modules = base_profiler.get_pkg_module_names(self._run_object) try: with _CodeEventsTracker(target_modules) as prof: prof.compute_mem_overhead() runpy.run_path(self._run_object...
def profile_package(self): """Returns memory stats for a package.""" target_modules = base_profiler.get_pkg_module_names(self._run_object) try: with _CodeEventsTracker(target_modules) as prof: prof.compute_mem_overhead() runpy.run_path(self._run_object...
[ "Returns", "memory", "stats", "for", "a", "package", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L156-L165
[ "def", "profile_package", "(", "self", ")", ":", "target_modules", "=", "base_profiler", ".", "get_pkg_module_names", "(", "self", ".", "_run_object", ")", "try", ":", "with", "_CodeEventsTracker", "(", "target_modules", ")", "as", "prof", ":", "prof", ".", "c...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
MemoryProfiler.profile_module
Returns memory stats for a module.
vprof/memory_profiler.py
def profile_module(self): """Returns memory stats for a module.""" target_modules = {self._run_object} try: with open(self._run_object, 'rb') as srcfile,\ _CodeEventsTracker(target_modules) as prof: code = compile(srcfile.read(), self._run_object, 'exe...
def profile_module(self): """Returns memory stats for a module.""" target_modules = {self._run_object} try: with open(self._run_object, 'rb') as srcfile,\ _CodeEventsTracker(target_modules) as prof: code = compile(srcfile.read(), self._run_object, 'exe...
[ "Returns", "memory", "stats", "for", "a", "module", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L167-L178
[ "def", "profile_module", "(", "self", ")", ":", "target_modules", "=", "{", "self", ".", "_run_object", "}", "try", ":", "with", "open", "(", "self", ".", "_run_object", ",", "'rb'", ")", "as", "srcfile", ",", "_CodeEventsTracker", "(", "target_modules", "...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
MemoryProfiler.profile_function
Returns memory stats for a function.
vprof/memory_profiler.py
def profile_function(self): """Returns memory stats for a function.""" target_modules = {self._run_object.__code__.co_filename} with _CodeEventsTracker(target_modules) as prof: prof.compute_mem_overhead() result = self._run_object(*self._run_args, **self._run_kwargs) ...
def profile_function(self): """Returns memory stats for a function.""" target_modules = {self._run_object.__code__.co_filename} with _CodeEventsTracker(target_modules) as prof: prof.compute_mem_overhead() result = self._run_object(*self._run_args, **self._run_kwargs) ...
[ "Returns", "memory", "stats", "for", "a", "function", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L180-L186
[ "def", "profile_function", "(", "self", ")", ":", "target_modules", "=", "{", "self", ".", "_run_object", ".", "__code__", ".", "co_filename", "}", "with", "_CodeEventsTracker", "(", "target_modules", ")", "as", "prof", ":", "prof", ".", "compute_mem_overhead", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
MemoryProfiler.run
Collects memory stats for specified Python program.
vprof/memory_profiler.py
def run(self): """Collects memory stats for specified Python program.""" existing_objects = _get_in_memory_objects() prof, result = self.profile() new_objects = _get_in_memory_objects() new_obj_count = _get_obj_count_difference(new_objects, existing_objects) result_obj_c...
def run(self): """Collects memory stats for specified Python program.""" existing_objects = _get_in_memory_objects() prof, result = self.profile() new_objects = _get_in_memory_objects() new_obj_count = _get_obj_count_difference(new_objects, existing_objects) result_obj_c...
[ "Collects", "memory", "stats", "for", "specified", "Python", "program", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/memory_profiler.py#L188-L207
[ "def", "run", "(", "self", ")", ":", "existing_objects", "=", "_get_in_memory_objects", "(", ")", "prof", ",", "result", "=", "self", ".", "profile", "(", ")", "new_objects", "=", "_get_in_memory_objects", "(", ")", "new_obj_count", "=", "_get_obj_count_differen...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
get_pkg_module_names
Returns module filenames from package. Args: package_path: Path to Python package. Returns: A set of module filenames.
vprof/base_profiler.py
def get_pkg_module_names(package_path): """Returns module filenames from package. Args: package_path: Path to Python package. Returns: A set of module filenames. """ module_names = set() for fobj, modname, _ in pkgutil.iter_modules(path=[package_path]): filename = os.pat...
def get_pkg_module_names(package_path): """Returns module filenames from package. Args: package_path: Path to Python package. Returns: A set of module filenames. """ module_names = set() for fobj, modname, _ in pkgutil.iter_modules(path=[package_path]): filename = os.pat...
[ "Returns", "module", "filenames", "from", "package", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L10-L23
[ "def", "get_pkg_module_names", "(", "package_path", ")", ":", "module_names", "=", "set", "(", ")", "for", "fobj", ",", "modname", ",", "_", "in", "pkgutil", ".", "iter_modules", "(", "path", "=", "[", "package_path", "]", ")", ":", "filename", "=", "os"...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
run_in_separate_process
Runs function in separate process. This function is used instead of a decorator, since Python multiprocessing module can't serialize decorated function on all platforms.
vprof/base_profiler.py
def run_in_separate_process(func, *args, **kwargs): """Runs function in separate process. This function is used instead of a decorator, since Python multiprocessing module can't serialize decorated function on all platforms. """ manager = multiprocessing.Manager() manager_dict = manager.dict() ...
def run_in_separate_process(func, *args, **kwargs): """Runs function in separate process. This function is used instead of a decorator, since Python multiprocessing module can't serialize decorated function on all platforms. """ manager = multiprocessing.Manager() manager_dict = manager.dict() ...
[ "Runs", "function", "in", "separate", "process", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L65-L80
[ "def", "run_in_separate_process", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "manager", "=", "multiprocessing", ".", "Manager", "(", ")", "manager_dict", "=", "manager", ".", "dict", "(", ")", "process", "=", "ProcessWithException", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
BaseProfiler.get_run_object_type
Determines run object type.
vprof/base_profiler.py
def get_run_object_type(run_object): """Determines run object type.""" if isinstance(run_object, tuple): return 'function' run_object, _, _ = run_object.partition(' ') if os.path.isdir(run_object): return 'package' return 'module'
def get_run_object_type(run_object): """Determines run object type.""" if isinstance(run_object, tuple): return 'function' run_object, _, _ = run_object.partition(' ') if os.path.isdir(run_object): return 'package' return 'module'
[ "Determines", "run", "object", "type", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L101-L108
[ "def", "get_run_object_type", "(", "run_object", ")", ":", "if", "isinstance", "(", "run_object", ",", "tuple", ")", ":", "return", "'function'", "run_object", ",", "_", ",", "_", "=", "run_object", ".", "partition", "(", "' '", ")", "if", "os", ".", "pa...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
BaseProfiler.init_module
Initializes profiler with a module.
vprof/base_profiler.py
def init_module(self, run_object): """Initializes profiler with a module.""" self.profile = self.profile_module self._run_object, _, self._run_args = run_object.partition(' ') self._object_name = '%s (module)' % self._run_object self._globs = { '__file__': self._run_o...
def init_module(self, run_object): """Initializes profiler with a module.""" self.profile = self.profile_module self._run_object, _, self._run_args = run_object.partition(' ') self._object_name = '%s (module)' % self._run_object self._globs = { '__file__': self._run_o...
[ "Initializes", "profiler", "with", "a", "module", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L110-L123
[ "def", "init_module", "(", "self", ",", "run_object", ")", ":", "self", ".", "profile", "=", "self", ".", "profile_module", "self", ".", "_run_object", ",", "_", ",", "self", ".", "_run_args", "=", "run_object", ".", "partition", "(", "' '", ")", "self",...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
BaseProfiler.init_package
Initializes profiler with a package.
vprof/base_profiler.py
def init_package(self, run_object): """Initializes profiler with a package.""" self.profile = self.profile_package self._run_object, _, self._run_args = run_object.partition(' ') self._object_name = '%s (package)' % self._run_object self._replace_sysargs()
def init_package(self, run_object): """Initializes profiler with a package.""" self.profile = self.profile_package self._run_object, _, self._run_args = run_object.partition(' ') self._object_name = '%s (package)' % self._run_object self._replace_sysargs()
[ "Initializes", "profiler", "with", "a", "package", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L125-L130
[ "def", "init_package", "(", "self", ",", "run_object", ")", ":", "self", ".", "profile", "=", "self", ".", "profile_package", "self", ".", "_run_object", ",", "_", ",", "self", ".", "_run_args", "=", "run_object", ".", "partition", "(", "' '", ")", "self...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
BaseProfiler.init_function
Initializes profiler with a function.
vprof/base_profiler.py
def init_function(self, run_object): """Initializes profiler with a function.""" self.profile = self.profile_function self._run_object, self._run_args, self._run_kwargs = run_object filename = inspect.getsourcefile(self._run_object) self._object_name = '%s @ %s (function)' % ( ...
def init_function(self, run_object): """Initializes profiler with a function.""" self.profile = self.profile_function self._run_object, self._run_args, self._run_kwargs = run_object filename = inspect.getsourcefile(self._run_object) self._object_name = '%s @ %s (function)' % ( ...
[ "Initializes", "profiler", "with", "a", "function", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L132-L138
[ "def", "init_function", "(", "self", ",", "run_object", ")", ":", "self", ".", "profile", "=", "self", ".", "profile_function", "self", ".", "_run_object", ",", "self", ".", "_run_args", ",", "self", ".", "_run_kwargs", "=", "run_object", "filename", "=", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
BaseProfiler._replace_sysargs
Replaces sys.argv with proper args to pass to script.
vprof/base_profiler.py
def _replace_sysargs(self): """Replaces sys.argv with proper args to pass to script.""" sys.argv[:] = [self._run_object] if self._run_args: sys.argv += self._run_args.split()
def _replace_sysargs(self): """Replaces sys.argv with proper args to pass to script.""" sys.argv[:] = [self._run_object] if self._run_args: sys.argv += self._run_args.split()
[ "Replaces", "sys", ".", "argv", "with", "proper", "args", "to", "pass", "to", "script", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/base_profiler.py#L140-L144
[ "def", "_replace_sysargs", "(", "self", ")", ":", "sys", ".", "argv", "[", ":", "]", "=", "[", "self", ".", "_run_object", "]", "if", "self", ".", "_run_args", ":", "sys", ".", "argv", "+=", "self", ".", "_run_args", ".", "split", "(", ")" ]
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_StatProfiler.sample
Samples current stack and adds result in self._stats. Args: signum: Signal that activates handler. frame: Frame on top of the stack when signal is handled.
vprof/flame_graph.py
def sample(self, signum, frame): #pylint: disable=unused-argument """Samples current stack and adds result in self._stats. Args: signum: Signal that activates handler. frame: Frame on top of the stack when signal is handled. """ stack = [] while frame an...
def sample(self, signum, frame): #pylint: disable=unused-argument """Samples current stack and adds result in self._stats. Args: signum: Signal that activates handler. frame: Frame on top of the stack when signal is handled. """ stack = [] while frame an...
[ "Samples", "current", "stack", "and", "adds", "result", "in", "self", ".", "_stats", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L37-L52
[ "def", "sample", "(", "self", ",", "signum", ",", "frame", ")", ":", "#pylint: disable=unused-argument", "stack", "=", "[", "]", "while", "frame", "and", "frame", "!=", "self", ".", "base_frame", ":", "stack", ".", "append", "(", "(", "frame", ".", "f_co...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_StatProfiler._insert_stack
Inserts stack into the call tree. Args: stack: Call stack. sample_count: Sample count of call stack. call_tree: Call tree.
vprof/flame_graph.py
def _insert_stack(stack, sample_count, call_tree): """Inserts stack into the call tree. Args: stack: Call stack. sample_count: Sample count of call stack. call_tree: Call tree. """ curr_level = call_tree for func in stack: next_lev...
def _insert_stack(stack, sample_count, call_tree): """Inserts stack into the call tree. Args: stack: Call stack. sample_count: Sample count of call stack. call_tree: Call tree. """ curr_level = call_tree for func in stack: next_lev...
[ "Inserts", "stack", "into", "the", "call", "tree", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L55-L73
[ "def", "_insert_stack", "(", "stack", ",", "sample_count", ",", "call_tree", ")", ":", "curr_level", "=", "call_tree", "for", "func", "in", "stack", ":", "next_level_index", "=", "{", "node", "[", "'stack'", "]", ":", "node", "for", "node", "in", "curr_lev...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_StatProfiler._fill_sample_count
Counts and fills sample counts inside call tree.
vprof/flame_graph.py
def _fill_sample_count(self, node): """Counts and fills sample counts inside call tree.""" node['sampleCount'] += sum( self._fill_sample_count(child) for child in node['children']) return node['sampleCount']
def _fill_sample_count(self, node): """Counts and fills sample counts inside call tree.""" node['sampleCount'] += sum( self._fill_sample_count(child) for child in node['children']) return node['sampleCount']
[ "Counts", "and", "fills", "sample", "counts", "inside", "call", "tree", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L75-L79
[ "def", "_fill_sample_count", "(", "self", ",", "node", ")", ":", "node", "[", "'sampleCount'", "]", "+=", "sum", "(", "self", ".", "_fill_sample_count", "(", "child", ")", "for", "child", "in", "node", "[", "'children'", "]", ")", "return", "node", "[", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_StatProfiler._format_tree
Reformats call tree for the UI.
vprof/flame_graph.py
def _format_tree(self, node, total_samples): """Reformats call tree for the UI.""" funcname, filename, _ = node['stack'] sample_percent = self._get_percentage( node['sampleCount'], total_samples) color_hash = base_profiler.hash_name('%s @ %s' % (funcname, filename)) r...
def _format_tree(self, node, total_samples): """Reformats call tree for the UI.""" funcname, filename, _ = node['stack'] sample_percent = self._get_percentage( node['sampleCount'], total_samples) color_hash = base_profiler.hash_name('%s @ %s' % (funcname, filename)) r...
[ "Reformats", "call", "tree", "for", "the", "UI", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L88-L101
[ "def", "_format_tree", "(", "self", ",", "node", ",", "total_samples", ")", ":", "funcname", ",", "filename", ",", "_", "=", "node", "[", "'stack'", "]", "sample_percent", "=", "self", ".", "_get_percentage", "(", "node", "[", "'sampleCount'", "]", ",", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_StatProfiler.call_tree
Returns call tree.
vprof/flame_graph.py
def call_tree(self): """Returns call tree.""" call_tree = {'stack': 'base', 'sampleCount': 0, 'children': []} for stack, sample_count in self._stats.items(): self._insert_stack(reversed(stack), sample_count, call_tree) self._fill_sample_count(call_tree) if not call_tr...
def call_tree(self): """Returns call tree.""" call_tree = {'stack': 'base', 'sampleCount': 0, 'children': []} for stack, sample_count in self._stats.items(): self._insert_stack(reversed(stack), sample_count, call_tree) self._fill_sample_count(call_tree) if not call_tr...
[ "Returns", "call", "tree", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L104-L113
[ "def", "call_tree", "(", "self", ")", ":", "call_tree", "=", "{", "'stack'", ":", "'base'", ",", "'sampleCount'", ":", "0", ",", "'children'", ":", "[", "]", "}", "for", "stack", ",", "sample_count", "in", "self", ".", "_stats", ".", "items", "(", ")...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
FlameGraphProfiler._profile_package
Runs statistical profiler on a package.
vprof/flame_graph.py
def _profile_package(self): """Runs statistical profiler on a package.""" with _StatProfiler() as prof: prof.base_frame = inspect.currentframe() try: runpy.run_path(self._run_object, run_name='__main__') except SystemExit: pass ...
def _profile_package(self): """Runs statistical profiler on a package.""" with _StatProfiler() as prof: prof.base_frame = inspect.currentframe() try: runpy.run_path(self._run_object, run_name='__main__') except SystemExit: pass ...
[ "Runs", "statistical", "profiler", "on", "a", "package", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L122-L139
[ "def", "_profile_package", "(", "self", ")", ":", "with", "_StatProfiler", "(", ")", "as", "prof", ":", "prof", ".", "base_frame", "=", "inspect", ".", "currentframe", "(", ")", "try", ":", "runpy", ".", "run_path", "(", "self", ".", "_run_object", ",", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
FlameGraphProfiler._profile_module
Runs statistical profiler on a module.
vprof/flame_graph.py
def _profile_module(self): """Runs statistical profiler on a module.""" with open(self._run_object, 'rb') as srcfile, _StatProfiler() as prof: code = compile(srcfile.read(), self._run_object, 'exec') prof.base_frame = inspect.currentframe() try: exec(c...
def _profile_module(self): """Runs statistical profiler on a module.""" with open(self._run_object, 'rb') as srcfile, _StatProfiler() as prof: code = compile(srcfile.read(), self._run_object, 'exec') prof.base_frame = inspect.currentframe() try: exec(c...
[ "Runs", "statistical", "profiler", "on", "a", "module", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L145-L163
[ "def", "_profile_module", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_run_object", ",", "'rb'", ")", "as", "srcfile", ",", "_StatProfiler", "(", ")", "as", "prof", ":", "code", "=", "compile", "(", "srcfile", ".", "read", "(", ")", ","...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
FlameGraphProfiler.profile_function
Runs statistical profiler on a function.
vprof/flame_graph.py
def profile_function(self): """Runs statistical profiler on a function.""" with _StatProfiler() as prof: result = self._run_object(*self._run_args, **self._run_kwargs) call_tree = prof.call_tree return { 'objectName': self._object_name, 'sampleInterva...
def profile_function(self): """Runs statistical profiler on a function.""" with _StatProfiler() as prof: result = self._run_object(*self._run_args, **self._run_kwargs) call_tree = prof.call_tree return { 'objectName': self._object_name, 'sampleInterva...
[ "Runs", "statistical", "profiler", "on", "a", "function", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/flame_graph.py#L169-L183
[ "def", "profile_function", "(", "self", ")", ":", "with", "_StatProfiler", "(", ")", "as", "prof", ":", "result", "=", "self", ".", "_run_object", "(", "*", "self", ".", "_run_args", ",", "*", "*", "self", ".", "_run_kwargs", ")", "call_tree", "=", "pr...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
Profiler._transform_stats
Processes collected stats for UI.
vprof/profiler.py
def _transform_stats(prof): """Processes collected stats for UI.""" records = [] for info, params in prof.stats.items(): filename, lineno, funcname = info cum_calls, num_calls, time_per_call, cum_time, _ = params if prof.total_tt == 0: percenta...
def _transform_stats(prof): """Processes collected stats for UI.""" records = [] for info, params in prof.stats.items(): filename, lineno, funcname = info cum_calls, num_calls, time_per_call, cum_time, _ = params if prof.total_tt == 0: percenta...
[ "Processes", "collected", "stats", "for", "UI", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/profiler.py#L18-L34
[ "def", "_transform_stats", "(", "prof", ")", ":", "records", "=", "[", "]", "for", "info", ",", "params", "in", "prof", ".", "stats", ".", "items", "(", ")", ":", "filename", ",", "lineno", ",", "funcname", "=", "info", "cum_calls", ",", "num_calls", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
Profiler._profile_package
Runs cProfile on a package.
vprof/profiler.py
def _profile_package(self): """Runs cProfile on a package.""" prof = cProfile.Profile() prof.enable() try: runpy.run_path(self._run_object, run_name='__main__') except SystemExit: pass prof.disable() prof_stats = pstats.Stats(prof) ...
def _profile_package(self): """Runs cProfile on a package.""" prof = cProfile.Profile() prof.enable() try: runpy.run_path(self._run_object, run_name='__main__') except SystemExit: pass prof.disable() prof_stats = pstats.Stats(prof) ...
[ "Runs", "cProfile", "on", "a", "package", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/profiler.py#L36-L54
[ "def", "_profile_package", "(", "self", ")", ":", "prof", "=", "cProfile", ".", "Profile", "(", ")", "prof", ".", "enable", "(", ")", "try", ":", "runpy", ".", "run_path", "(", "self", ".", "_run_object", ",", "run_name", "=", "'__main__'", ")", "excep...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
Profiler._profile_module
Runs cProfile on a module.
vprof/profiler.py
def _profile_module(self): """Runs cProfile on a module.""" prof = cProfile.Profile() try: with open(self._run_object, 'rb') as srcfile: code = compile(srcfile.read(), self._run_object, 'exec') prof.runctx(code, self._globs, None) except SystemExit...
def _profile_module(self): """Runs cProfile on a module.""" prof = cProfile.Profile() try: with open(self._run_object, 'rb') as srcfile: code = compile(srcfile.read(), self._run_object, 'exec') prof.runctx(code, self._globs, None) except SystemExit...
[ "Runs", "cProfile", "on", "a", "module", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/profiler.py#L60-L78
[ "def", "_profile_module", "(", "self", ")", ":", "prof", "=", "cProfile", ".", "Profile", "(", ")", "try", ":", "with", "open", "(", "self", ".", "_run_object", ",", "'rb'", ")", "as", "srcfile", ":", "code", "=", "compile", "(", "srcfile", ".", "rea...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
Profiler.profile_function
Runs cProfile on a function.
vprof/profiler.py
def profile_function(self): """Runs cProfile on a function.""" prof = cProfile.Profile() prof.enable() result = self._run_object(*self._run_args, **self._run_kwargs) prof.disable() prof_stats = pstats.Stats(prof) prof_stats.calc_callees() return { ...
def profile_function(self): """Runs cProfile on a function.""" prof = cProfile.Profile() prof.enable() result = self._run_object(*self._run_args, **self._run_kwargs) prof.disable() prof_stats = pstats.Stats(prof) prof_stats.calc_callees() return { ...
[ "Runs", "cProfile", "on", "a", "function", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/profiler.py#L84-L100
[ "def", "profile_function", "(", "self", ")", ":", "prof", "=", "cProfile", ".", "Profile", "(", ")", "prof", ".", "enable", "(", ")", "result", "=", "self", ".", "_run_object", "(", "*", "self", ".", "_run_args", ",", "*", "*", "self", ".", "_run_kwa...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
init_db
Initializes DB.
examples/guestbook.py
def init_db(): """Initializes DB.""" with contextlib.closing(connect_to_db()) as db: db.cursor().executescript(DB_SCHEMA) db.commit()
def init_db(): """Initializes DB.""" with contextlib.closing(connect_to_db()) as db: db.cursor().executescript(DB_SCHEMA) db.commit()
[ "Initializes", "DB", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/examples/guestbook.py#L64-L68
[ "def", "init_db", "(", ")", ":", "with", "contextlib", ".", "closing", "(", "connect_to_db", "(", ")", ")", "as", "db", ":", "db", ".", "cursor", "(", ")", ".", "executescript", "(", "DB_SCHEMA", ")", "db", ".", "commit", "(", ")" ]
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
show_guestbook
Returns all existing guestbook records.
examples/guestbook.py
def show_guestbook(): """Returns all existing guestbook records.""" cursor = flask.g.db.execute( 'SELECT name, message FROM entry ORDER BY id DESC;') entries = [{'name': row[0], 'message': row[1]} for row in cursor.fetchall()] return jinja2.Template(LAYOUT).render(entries=entries)
def show_guestbook(): """Returns all existing guestbook records.""" cursor = flask.g.db.execute( 'SELECT name, message FROM entry ORDER BY id DESC;') entries = [{'name': row[0], 'message': row[1]} for row in cursor.fetchall()] return jinja2.Template(LAYOUT).render(entries=entries)
[ "Returns", "all", "existing", "guestbook", "records", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/examples/guestbook.py#L89-L94
[ "def", "show_guestbook", "(", ")", ":", "cursor", "=", "flask", ".", "g", ".", "db", ".", "execute", "(", "'SELECT name, message FROM entry ORDER BY id DESC;'", ")", "entries", "=", "[", "{", "'name'", ":", "row", "[", "0", "]", ",", "'message'", ":", "row...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
add_entry
Adds single guestbook record.
examples/guestbook.py
def add_entry(): """Adds single guestbook record.""" name, msg = flask.request.form['name'], flask.request.form['message'] flask.g.db.execute( 'INSERT INTO entry (name, message) VALUES (?, ?)', (name, msg)) flask.g.db.commit() return flask.redirect('/')
def add_entry(): """Adds single guestbook record.""" name, msg = flask.request.form['name'], flask.request.form['message'] flask.g.db.execute( 'INSERT INTO entry (name, message) VALUES (?, ?)', (name, msg)) flask.g.db.commit() return flask.redirect('/')
[ "Adds", "single", "guestbook", "record", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/examples/guestbook.py#L98-L104
[ "def", "add_entry", "(", ")", ":", "name", ",", "msg", "=", "flask", ".", "request", ".", "form", "[", "'name'", "]", ",", "flask", ".", "request", ".", "form", "[", "'message'", "]", "flask", ".", "g", ".", "db", ".", "execute", "(", "'INSERT INTO...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
profiler_handler
Profiler handler.
examples/guestbook.py
def profiler_handler(uri): """Profiler handler.""" # HTTP method should be GET. if uri == 'main': runner.run(show_guestbook, 'cmhp') # In this case HTTP method should be POST singe add_entry uses POST elif uri == 'add': runner.run(add_entry, 'cmhp') return flask.redirect('/')
def profiler_handler(uri): """Profiler handler.""" # HTTP method should be GET. if uri == 'main': runner.run(show_guestbook, 'cmhp') # In this case HTTP method should be POST singe add_entry uses POST elif uri == 'add': runner.run(add_entry, 'cmhp') return flask.redirect('/')
[ "Profiler", "handler", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/examples/guestbook.py#L108-L116
[ "def", "profiler_handler", "(", "uri", ")", ":", "# HTTP method should be GET.", "if", "uri", "==", "'main'", ":", "runner", ".", "run", "(", "show_guestbook", ",", "'cmhp'", ")", "# In this case HTTP method should be POST singe add_entry uses POST", "elif", "uri", "=="...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
start
Starts HTTP server with specified parameters. Args: host: Server host name. port: Server port. profiler_stats: A dict with collected program stats. dont_start_browser: Whether to open browser after profiling. debug_mode: Whether to redirect stderr to /dev/null.
vprof/stats_server.py
def start(host, port, profiler_stats, dont_start_browser, debug_mode): """Starts HTTP server with specified parameters. Args: host: Server host name. port: Server port. profiler_stats: A dict with collected program stats. dont_start_browser: Whether to open browser after profili...
def start(host, port, profiler_stats, dont_start_browser, debug_mode): """Starts HTTP server with specified parameters. Args: host: Server host name. port: Server port. profiler_stats: A dict with collected program stats. dont_start_browser: Whether to open browser after profili...
[ "Starts", "HTTP", "server", "with", "specified", "parameters", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/stats_server.py#L87-L107
[ "def", "start", "(", "host", ",", "port", ",", "profiler_stats", ",", "dont_start_browser", ",", "debug_mode", ")", ":", "stats_handler", "=", "functools", ".", "partial", "(", "StatsHandler", ",", "profiler_stats", ")", "if", "not", "debug_mode", ":", "sys", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
StatsHandler._handle_root
Handles index.html requests.
vprof/stats_server.py
def _handle_root(): """Handles index.html requests.""" res_filename = os.path.join( os.path.dirname(__file__), _PROFILE_HTML) with io.open(res_filename, 'rb') as res_file: content = res_file.read() return content, 'text/html'
def _handle_root(): """Handles index.html requests.""" res_filename = os.path.join( os.path.dirname(__file__), _PROFILE_HTML) with io.open(res_filename, 'rb') as res_file: content = res_file.read() return content, 'text/html'
[ "Handles", "index", ".", "html", "requests", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/stats_server.py#L36-L42
[ "def", "_handle_root", "(", ")", ":", "res_filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "_PROFILE_HTML", ")", "with", "io", ".", "open", "(", "res_filename", ",", "'rb'", ")", "as"...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
StatsHandler._handle_other
Handles static files requests.
vprof/stats_server.py
def _handle_other(self): """Handles static files requests.""" res_filename = os.path.join( os.path.dirname(__file__), _STATIC_DIR, self.path[1:]) with io.open(res_filename, 'rb') as res_file: content = res_file.read() _, extension = os.path.splitext(self.path) ...
def _handle_other(self): """Handles static files requests.""" res_filename = os.path.join( os.path.dirname(__file__), _STATIC_DIR, self.path[1:]) with io.open(res_filename, 'rb') as res_file: content = res_file.read() _, extension = os.path.splitext(self.path) ...
[ "Handles", "static", "files", "requests", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/stats_server.py#L48-L55
[ "def", "_handle_other", "(", "self", ")", ":", "res_filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "_STATIC_DIR", ",", "self", ".", "path", "[", "1", ":", "]", ")", "with", "io", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
StatsHandler.do_GET
Handles HTTP GET requests.
vprof/stats_server.py
def do_GET(self): """Handles HTTP GET requests.""" handler = self.uri_map.get(self.path) or self._handle_other content, content_type = handler() compressed_content = gzip.compress(content) self._send_response( 200, headers=(('Content-type', '%s; charset=utf-8' % conte...
def do_GET(self): """Handles HTTP GET requests.""" handler = self.uri_map.get(self.path) or self._handle_other content, content_type = handler() compressed_content = gzip.compress(content) self._send_response( 200, headers=(('Content-type', '%s; charset=utf-8' % conte...
[ "Handles", "HTTP", "GET", "requests", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/stats_server.py#L57-L66
[ "def", "do_GET", "(", "self", ")", ":", "handler", "=", "self", ".", "uri_map", ".", "get", "(", "self", ".", "path", ")", "or", "self", ".", "_handle_other", "content", ",", "content_type", "=", "handler", "(", ")", "compressed_content", "=", "gzip", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
StatsHandler.do_POST
Handles HTTP POST requests.
vprof/stats_server.py
def do_POST(self): """Handles HTTP POST requests.""" post_data = self.rfile.read(int(self.headers['Content-Length'])) json_data = gzip.decompress(post_data) self._profile_json.update(json.loads(json_data.decode('utf-8'))) self._send_response( 200, headers=(('Content-t...
def do_POST(self): """Handles HTTP POST requests.""" post_data = self.rfile.read(int(self.headers['Content-Length'])) json_data = gzip.decompress(post_data) self._profile_json.update(json.loads(json_data.decode('utf-8'))) self._send_response( 200, headers=(('Content-t...
[ "Handles", "HTTP", "POST", "requests", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/stats_server.py#L68-L76
[ "def", "do_POST", "(", "self", ")", ":", "post_data", "=", "self", ".", "rfile", ".", "read", "(", "int", "(", "self", ".", "headers", "[", "'Content-Length'", "]", ")", ")", "json_data", "=", "gzip", ".", "decompress", "(", "post_data", ")", "self", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
StatsHandler._send_response
Sends HTTP response code, message and headers.
vprof/stats_server.py
def _send_response(self, http_code, message=None, headers=None): """Sends HTTP response code, message and headers.""" self.send_response(http_code, message) if headers: for header in headers: self.send_header(*header) self.end_headers()
def _send_response(self, http_code, message=None, headers=None): """Sends HTTP response code, message and headers.""" self.send_response(http_code, message) if headers: for header in headers: self.send_header(*header) self.end_headers()
[ "Sends", "HTTP", "response", "code", "message", "and", "headers", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/stats_server.py#L78-L84
[ "def", "_send_response", "(", "self", ",", "http_code", ",", "message", "=", "None", ",", "headers", "=", "None", ")", ":", "self", ".", "send_response", "(", "http_code", ",", "message", ")", "if", "headers", ":", "for", "header", "in", "headers", ":", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
main
Main function of the module.
vprof/__main__.py
def main(): """Main function of the module.""" parser = argparse.ArgumentParser( prog=_PROGRAN_NAME, description=_MODULE_DESC, formatter_class=argparse.RawTextHelpFormatter) launch_modes = parser.add_mutually_exclusive_group(required=True) launch_modes.add_argument('-r', '--remote', dest...
def main(): """Main function of the module.""" parser = argparse.ArgumentParser( prog=_PROGRAN_NAME, description=_MODULE_DESC, formatter_class=argparse.RawTextHelpFormatter) launch_modes = parser.add_mutually_exclusive_group(required=True) launch_modes.add_argument('-r', '--remote', dest...
[ "Main", "function", "of", "the", "module", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/__main__.py#L35-L99
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_PROGRAN_NAME", ",", "description", "=", "_MODULE_DESC", ",", "formatter_class", "=", "argparse", ".", "RawTextHelpFormatter", ")", "launch_modes", "=", "parser", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
check_standard_dir
Checks whether path belongs to standard library or installed modules.
vprof/code_heatmap.py
def check_standard_dir(module_path): """Checks whether path belongs to standard library or installed modules.""" if 'site-packages' in module_path: return True for stdlib_path in _STDLIB_PATHS: if fnmatch.fnmatchcase(module_path, stdlib_path + '*'): return True return False
def check_standard_dir(module_path): """Checks whether path belongs to standard library or installed modules.""" if 'site-packages' in module_path: return True for stdlib_path in _STDLIB_PATHS: if fnmatch.fnmatchcase(module_path, stdlib_path + '*'): return True return False
[ "Checks", "whether", "path", "belongs", "to", "standard", "library", "or", "installed", "modules", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L18-L25
[ "def", "check_standard_dir", "(", "module_path", ")", ":", "if", "'site-packages'", "in", "module_path", ":", "return", "True", "for", "stdlib_path", "in", "_STDLIB_PATHS", ":", "if", "fnmatch", ".", "fnmatchcase", "(", "module_path", ",", "stdlib_path", "+", "'...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeHeatmapCalculator.record_line
Records line execution time.
vprof/code_heatmap.py
def record_line(self, frame, event, arg): # pylint: disable=unused-argument """Records line execution time.""" if event == 'line': if self.prev_timestamp: runtime = time.time() - self.prev_timestamp self.lines.append([self.prev_path, self.prev_lineno, runtime...
def record_line(self, frame, event, arg): # pylint: disable=unused-argument """Records line execution time.""" if event == 'line': if self.prev_timestamp: runtime = time.time() - self.prev_timestamp self.lines.append([self.prev_path, self.prev_lineno, runtime...
[ "Records", "line", "execution", "time", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L56-L65
[ "def", "record_line", "(", "self", ",", "frame", ",", "event", ",", "arg", ")", ":", "# pylint: disable=unused-argument", "if", "event", "==", "'line'", ":", "if", "self", ".", "prev_timestamp", ":", "runtime", "=", "time", ".", "time", "(", ")", "-", "s...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeHeatmapCalculator.lines_without_stdlib
Filters code from standard library from self.lines.
vprof/code_heatmap.py
def lines_without_stdlib(self): """Filters code from standard library from self.lines.""" prev_line = None current_module_path = inspect.getabsfile(inspect.currentframe()) for module_path, lineno, runtime in self.lines: module_abspath = os.path.abspath(module_path) ...
def lines_without_stdlib(self): """Filters code from standard library from self.lines.""" prev_line = None current_module_path = inspect.getabsfile(inspect.currentframe()) for module_path, lineno, runtime in self.lines: module_abspath = os.path.abspath(module_path) ...
[ "Filters", "code", "from", "standard", "library", "from", "self", ".", "lines", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L68-L83
[ "def", "lines_without_stdlib", "(", "self", ")", ":", "prev_line", "=", "None", "current_module_path", "=", "inspect", ".", "getabsfile", "(", "inspect", ".", "currentframe", "(", ")", ")", "for", "module_path", ",", "lineno", ",", "runtime", "in", "self", "...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
_CodeHeatmapCalculator.fill_heatmap
Fills code heatmap and execution count dictionaries.
vprof/code_heatmap.py
def fill_heatmap(self): """Fills code heatmap and execution count dictionaries.""" for module_path, lineno, runtime in self.lines_without_stdlib: self._execution_count[module_path][lineno] += 1 self._heatmap[module_path][lineno] += runtime
def fill_heatmap(self): """Fills code heatmap and execution count dictionaries.""" for module_path, lineno, runtime in self.lines_without_stdlib: self._execution_count[module_path][lineno] += 1 self._heatmap[module_path][lineno] += runtime
[ "Fills", "code", "heatmap", "and", "execution", "count", "dictionaries", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L85-L89
[ "def", "fill_heatmap", "(", "self", ")", ":", "for", "module_path", ",", "lineno", ",", "runtime", "in", "self", ".", "lines_without_stdlib", ":", "self", ".", "_execution_count", "[", "module_path", "]", "[", "lineno", "]", "+=", "1", "self", ".", "_heatm...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
CodeHeatmapProfiler._calc_skips
Calculates skip map for large sources. Skip map is a list of tuples where first element of tuple is line number and second is length of the skip region: [(1, 10), (15, 10)] means skipping 10 lines after line 1 and 10 lines after line 15.
vprof/code_heatmap.py
def _calc_skips(self, heatmap, num_lines): """Calculates skip map for large sources. Skip map is a list of tuples where first element of tuple is line number and second is length of the skip region: [(1, 10), (15, 10)] means skipping 10 lines after line 1 and 10 lines aft...
def _calc_skips(self, heatmap, num_lines): """Calculates skip map for large sources. Skip map is a list of tuples where first element of tuple is line number and second is length of the skip region: [(1, 10), (15, 10)] means skipping 10 lines after line 1 and 10 lines aft...
[ "Calculates", "skip", "map", "for", "large", "sources", ".", "Skip", "map", "is", "a", "list", "of", "tuples", "where", "first", "element", "of", "tuple", "is", "line", "number", "and", "second", "is", "length", "of", "the", "skip", "region", ":", "[", ...
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L112-L129
[ "def", "_calc_skips", "(", "self", ",", "heatmap", ",", "num_lines", ")", ":", "if", "num_lines", "<", "self", ".", "MIN_SKIP_SIZE", ":", "return", "[", "]", "skips", ",", "prev_line", "=", "[", "]", ",", "0", "for", "line", "in", "sorted", "(", "hea...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
CodeHeatmapProfiler._skip_lines
Skips lines in src_code specified by skip map.
vprof/code_heatmap.py
def _skip_lines(src_code, skip_map): """Skips lines in src_code specified by skip map.""" if not skip_map: return [['line', j + 1, l] for j, l in enumerate(src_code)] code_with_skips, i = [], 0 for line, length in skip_map: code_with_skips.extend( ...
def _skip_lines(src_code, skip_map): """Skips lines in src_code specified by skip map.""" if not skip_map: return [['line', j + 1, l] for j, l in enumerate(src_code)] code_with_skips, i = [], 0 for line, length in skip_map: code_with_skips.extend( ...
[ "Skips", "lines", "in", "src_code", "specified", "by", "skip", "map", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L132-L148
[ "def", "_skip_lines", "(", "src_code", ",", "skip_map", ")", ":", "if", "not", "skip_map", ":", "return", "[", "[", "'line'", ",", "j", "+", "1", ",", "l", "]", "for", "j", ",", "l", "in", "enumerate", "(", "src_code", ")", "]", "code_with_skips", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
CodeHeatmapProfiler._profile_package
Calculates heatmap for package.
vprof/code_heatmap.py
def _profile_package(self): """Calculates heatmap for package.""" with _CodeHeatmapCalculator() as prof: try: runpy.run_path(self._run_object, run_name='__main__') except SystemExit: pass heatmaps = [] for filename, heatmap in prof...
def _profile_package(self): """Calculates heatmap for package.""" with _CodeHeatmapCalculator() as prof: try: runpy.run_path(self._run_object, run_name='__main__') except SystemExit: pass heatmaps = [] for filename, heatmap in prof...
[ "Calculates", "heatmap", "for", "package", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L150-L170
[ "def", "_profile_package", "(", "self", ")", ":", "with", "_CodeHeatmapCalculator", "(", ")", "as", "prof", ":", "try", ":", "runpy", ".", "run_path", "(", "self", ".", "_run_object", ",", "run_name", "=", "'__main__'", ")", "except", "SystemExit", ":", "p...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
CodeHeatmapProfiler._format_heatmap
Formats heatmap for UI.
vprof/code_heatmap.py
def _format_heatmap(self, filename, heatmap, execution_count): """Formats heatmap for UI.""" with open(filename) as src_file: file_source = src_file.read().split('\n') skip_map = self._calc_skips(heatmap, len(file_source)) run_time = sum(time for time in heatmap.values())...
def _format_heatmap(self, filename, heatmap, execution_count): """Formats heatmap for UI.""" with open(filename) as src_file: file_source = src_file.read().split('\n') skip_map = self._calc_skips(heatmap, len(file_source)) run_time = sum(time for time in heatmap.values())...
[ "Formats", "heatmap", "for", "UI", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L176-L188
[ "def", "_format_heatmap", "(", "self", ",", "filename", ",", "heatmap", ",", "execution_count", ")", ":", "with", "open", "(", "filename", ")", "as", "src_file", ":", "file_source", "=", "src_file", ".", "read", "(", ")", ".", "split", "(", "'\\n'", ")",...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
CodeHeatmapProfiler._profile_module
Calculates heatmap for module.
vprof/code_heatmap.py
def _profile_module(self): """Calculates heatmap for module.""" with open(self._run_object, 'r') as srcfile: src_code = srcfile.read() code = compile(src_code, self._run_object, 'exec') try: with _CodeHeatmapCalculator() as prof: exec(code, sel...
def _profile_module(self): """Calculates heatmap for module.""" with open(self._run_object, 'r') as srcfile: src_code = srcfile.read() code = compile(src_code, self._run_object, 'exec') try: with _CodeHeatmapCalculator() as prof: exec(code, sel...
[ "Calculates", "heatmap", "for", "module", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L190-L213
[ "def", "_profile_module", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_run_object", ",", "'r'", ")", "as", "srcfile", ":", "src_code", "=", "srcfile", ".", "read", "(", ")", "code", "=", "compile", "(", "src_code", ",", "self", ".", "_r...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
CodeHeatmapProfiler.profile_function
Calculates heatmap for function.
vprof/code_heatmap.py
def profile_function(self): """Calculates heatmap for function.""" with _CodeHeatmapCalculator() as prof: result = self._run_object(*self._run_args, **self._run_kwargs) code_lines, start_line = inspect.getsourcelines(self._run_object) source_lines = [] for line in co...
def profile_function(self): """Calculates heatmap for function.""" with _CodeHeatmapCalculator() as prof: result = self._run_object(*self._run_args, **self._run_kwargs) code_lines, start_line = inspect.getsourcelines(self._run_object) source_lines = [] for line in co...
[ "Calculates", "heatmap", "for", "function", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/code_heatmap.py#L219-L245
[ "def", "profile_function", "(", "self", ")", ":", "with", "_CodeHeatmapCalculator", "(", ")", "as", "prof", ":", "result", "=", "self", ".", "_run_object", "(", "*", "self", ".", "_run_args", ",", "*", "*", "self", ".", "_run_kwargs", ")", "code_lines", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
run_profilers
Runs profilers on run_object. Args: run_object: An object (string or tuple) for profiling. prof_config: A string with profilers configuration. verbose: True if info about running profilers should be shown. Returns: An ordered dictionary with collected stats. Raises: ...
vprof/runner.py
def run_profilers(run_object, prof_config, verbose=False): """Runs profilers on run_object. Args: run_object: An object (string or tuple) for profiling. prof_config: A string with profilers configuration. verbose: True if info about running profilers should be shown. Returns: ...
def run_profilers(run_object, prof_config, verbose=False): """Runs profilers on run_object. Args: run_object: An object (string or tuple) for profiling. prof_config: A string with profilers configuration. verbose: True if info about running profilers should be shown. Returns: ...
[ "Runs", "profilers", "on", "run_object", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/runner.py#L45-L74
[ "def", "run_profilers", "(", "run_object", ",", "prof_config", ",", "verbose", "=", "False", ")", ":", "if", "len", "(", "prof_config", ")", ">", "len", "(", "set", "(", "prof_config", ")", ")", ":", "raise", "AmbiguousConfigurationError", "(", "'Profiler co...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
run
Runs profilers on a function. Args: func: A Python function. options: A string with profilers configuration (i.e. 'cmh'). args: func non-keyword arguments. kwargs: func keyword arguments. host: Host name to send collected data. port: Port number to send collected dat...
vprof/runner.py
def run(func, options, args=(), kwargs={}, host='localhost', port=8000): # pylint: disable=dangerous-default-value """Runs profilers on a function. Args: func: A Python function. options: A string with profilers configuration (i.e. 'cmh'). args: func non-keyword arguments. kwar...
def run(func, options, args=(), kwargs={}, host='localhost', port=8000): # pylint: disable=dangerous-default-value """Runs profilers on a function. Args: func: A Python function. options: A string with profilers configuration (i.e. 'cmh'). args: func non-keyword arguments. kwar...
[ "Runs", "profilers", "on", "a", "function", "." ]
nvdv/vprof
python
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/runner.py#L77-L102
[ "def", "run", "(", "func", ",", "options", ",", "args", "=", "(", ")", ",", "kwargs", "=", "{", "}", ",", "host", "=", "'localhost'", ",", "port", "=", "8000", ")", ":", "# pylint: disable=dangerous-default-value", "run_stats", "=", "run_profilers", "(", ...
4c3ff78f8920ab10cb9c00b14143452aa09ff6bb
test
SparkBaseNB.predict_proba
Return probability estimates for the RDD containing test vector X. Parameters ---------- X : RDD containing array-like items, shape = [m_samples, n_features] Returns ------- C : RDD with array-like items , shape = [n_samples, n_classes] Returns the probabili...
splearn/naive_bayes.py
def predict_proba(self, X): """ Return probability estimates for the RDD containing test vector X. Parameters ---------- X : RDD containing array-like items, shape = [m_samples, n_features] Returns ------- C : RDD with array-like items , shape = [n_sampl...
def predict_proba(self, X): """ Return probability estimates for the RDD containing test vector X. Parameters ---------- X : RDD containing array-like items, shape = [m_samples, n_features] Returns ------- C : RDD with array-like items , shape = [n_sampl...
[ "Return", "probability", "estimates", "for", "the", "RDD", "containing", "test", "vector", "X", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/naive_bayes.py#L40-L57
[ "def", "predict_proba", "(", "self", ",", "X", ")", ":", "check_rdd", "(", "X", ",", "(", "sp", ".", "spmatrix", ",", "np", ".", "ndarray", ")", ")", "return", "X", ".", "map", "(", "lambda", "X", ":", "super", "(", "SparkBaseNB", ",", "self", ")...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkBaseNB.predict_log_proba
Return log-probability estimates for the RDD containing the test vector X. Parameters ---------- X : RDD containing array-like items, shape = [m_samples, n_features] Returns ------- C : RDD with array-like items, shape = [n_samples, n_classes] Return...
splearn/naive_bayes.py
def predict_log_proba(self, X): """ Return log-probability estimates for the RDD containing the test vector X. Parameters ---------- X : RDD containing array-like items, shape = [m_samples, n_features] Returns ------- C : RDD with array-like item...
def predict_log_proba(self, X): """ Return log-probability estimates for the RDD containing the test vector X. Parameters ---------- X : RDD containing array-like items, shape = [m_samples, n_features] Returns ------- C : RDD with array-like item...
[ "Return", "log", "-", "probability", "estimates", "for", "the", "RDD", "containing", "the", "test", "vector", "X", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/naive_bayes.py#L59-L83
[ "def", "predict_log_proba", "(", "self", ",", "X", ")", ":", "# required, scikit call self.predict_log_proba(X) in predict_proba", "# and thus this function is call, it must have the same behavior when", "# not called by sparkit-learn", "if", "not", "isinstance", "(", "X", ",", "Bl...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkGaussianNB.fit
Fit Gaussian Naive Bayes according to X, y Parameters ---------- X : array-like, shape (n_samples, n_features) Training vectors, where n_samples is the number of samples and n_features is the number of features. y : array-like, shape (n_samples,) Tar...
splearn/naive_bayes.py
def fit(self, Z, classes=None): """Fit Gaussian Naive Bayes according to X, y Parameters ---------- X : array-like, shape (n_samples, n_features) Training vectors, where n_samples is the number of samples and n_features is the number of features. y : arr...
def fit(self, Z, classes=None): """Fit Gaussian Naive Bayes according to X, y Parameters ---------- X : array-like, shape (n_samples, n_features) Training vectors, where n_samples is the number of samples and n_features is the number of features. y : arr...
[ "Fit", "Gaussian", "Naive", "Bayes", "according", "to", "X", "y" ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/naive_bayes.py#L120-L142
[ "def", "fit", "(", "self", ",", "Z", ",", "classes", "=", "None", ")", ":", "check_rdd", "(", "Z", ",", "{", "'X'", ":", "(", "sp", ".", "spmatrix", ",", "np", ".", "ndarray", ")", ",", "'y'", ":", "(", "sp", ".", "spmatrix", ",", "np", ".", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkBaseDiscreteNB.fit
TODO fulibacsi fix docstring Fit Multinomial Naive Bayes according to (X,y) pair which is zipped into TupleRDD Z. Parameters ---------- Z : TupleRDD containing X [array-like, shape (m_samples, n_features)] and y [array-like, shape (m_samples,)] tuple Trai...
splearn/naive_bayes.py
def fit(self, Z, classes=None): """ TODO fulibacsi fix docstring Fit Multinomial Naive Bayes according to (X,y) pair which is zipped into TupleRDD Z. Parameters ---------- Z : TupleRDD containing X [array-like, shape (m_samples, n_features)] and y [ar...
def fit(self, Z, classes=None): """ TODO fulibacsi fix docstring Fit Multinomial Naive Bayes according to (X,y) pair which is zipped into TupleRDD Z. Parameters ---------- Z : TupleRDD containing X [array-like, shape (m_samples, n_features)] and y [ar...
[ "TODO", "fulibacsi", "fix", "docstring", "Fit", "Multinomial", "Naive", "Bayes", "according", "to", "(", "X", "y", ")", "pair", "which", "is", "zipped", "into", "TupleRDD", "Z", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/naive_bayes.py#L207-L238
[ "def", "fit", "(", "self", ",", "Z", ",", "classes", "=", "None", ")", ":", "check_rdd", "(", "Z", ",", "{", "'X'", ":", "(", "sp", ".", "spmatrix", ",", "np", ".", "ndarray", ")", ",", "'y'", ":", "(", "sp", ".", "spmatrix", ",", "np", ".", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkCountVectorizer._init_vocab
Create vocabulary
splearn/feature_extraction/text.py
def _init_vocab(self, analyzed_docs): """Create vocabulary """ class SetAccum(AccumulatorParam): def zero(self, initialValue): return set(initialValue) def addInPlace(self, v1, v2): v1 |= v2 return v1 if not self....
def _init_vocab(self, analyzed_docs): """Create vocabulary """ class SetAccum(AccumulatorParam): def zero(self, initialValue): return set(initialValue) def addInPlace(self, v1, v2): v1 |= v2 return v1 if not self....
[ "Create", "vocabulary" ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L144-L167
[ "def", "_init_vocab", "(", "self", ",", "analyzed_docs", ")", ":", "class", "SetAccum", "(", "AccumulatorParam", ")", ":", "def", "zero", "(", "self", ",", "initialValue", ")", ":", "return", "set", "(", "initialValue", ")", "def", "addInPlace", "(", "self...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkCountVectorizer._count_vocab
Create sparse feature matrix, and vocabulary where fixed_vocab=False
splearn/feature_extraction/text.py
def _count_vocab(self, analyzed_docs): """Create sparse feature matrix, and vocabulary where fixed_vocab=False """ vocabulary = self.vocabulary_ j_indices = _make_int_array() indptr = _make_int_array() indptr.append(0) for doc in analyzed_docs: for fea...
def _count_vocab(self, analyzed_docs): """Create sparse feature matrix, and vocabulary where fixed_vocab=False """ vocabulary = self.vocabulary_ j_indices = _make_int_array() indptr = _make_int_array() indptr.append(0) for doc in analyzed_docs: for fea...
[ "Create", "sparse", "feature", "matrix", "and", "vocabulary", "where", "fixed_vocab", "=", "False" ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L169-L197
[ "def", "_count_vocab", "(", "self", ",", "analyzed_docs", ")", ":", "vocabulary", "=", "self", ".", "vocabulary_", "j_indices", "=", "_make_int_array", "(", ")", "indptr", "=", "_make_int_array", "(", ")", "indptr", ".", "append", "(", "0", ")", "for", "do...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkCountVectorizer._sort_features
Sort features by name Returns a reordered matrix and modifies the vocabulary in place
splearn/feature_extraction/text.py
def _sort_features(self, vocabulary): """Sort features by name Returns a reordered matrix and modifies the vocabulary in place """ sorted_features = sorted(six.iteritems(vocabulary)) map_index = np.empty(len(sorted_features), dtype=np.int32) for new_val, (term, old_val) ...
def _sort_features(self, vocabulary): """Sort features by name Returns a reordered matrix and modifies the vocabulary in place """ sorted_features = sorted(six.iteritems(vocabulary)) map_index = np.empty(len(sorted_features), dtype=np.int32) for new_val, (term, old_val) ...
[ "Sort", "features", "by", "name" ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L199-L210
[ "def", "_sort_features", "(", "self", ",", "vocabulary", ")", ":", "sorted_features", "=", "sorted", "(", "six", ".", "iteritems", "(", "vocabulary", ")", ")", "map_index", "=", "np", ".", "empty", "(", "len", "(", "sorted_features", ")", ",", "dtype", "...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkCountVectorizer._limit_features
Remove too rare or too common features. Prune features that are non zero in more samples than high or less documents than low, modifying the vocabulary, and restricting it to at most the limit most frequent. This does not prune samples with zero features.
splearn/feature_extraction/text.py
def _limit_features(self, X, vocabulary, high=None, low=None, limit=None): """Remove too rare or too common features. Prune features that are non zero in more samples than high or less documents than low, modifying the vocabulary, and restricting it to at most th...
def _limit_features(self, X, vocabulary, high=None, low=None, limit=None): """Remove too rare or too common features. Prune features that are non zero in more samples than high or less documents than low, modifying the vocabulary, and restricting it to at most th...
[ "Remove", "too", "rare", "or", "too", "common", "features", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L212-L253
[ "def", "_limit_features", "(", "self", ",", "X", ",", "vocabulary", ",", "high", "=", "None", ",", "low", "=", "None", ",", "limit", "=", "None", ")", ":", "if", "high", "is", "None", "and", "low", "is", "None", "and", "limit", "is", "None", ":", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkCountVectorizer.fit_transform
Learn the vocabulary dictionary and return term-document matrix. This is equivalent to fit followed by transform, but more efficiently implemented. Parameters ---------- Z : iterable or DictRDD with column 'X' An iterable of raw_documents which yields either str, un...
splearn/feature_extraction/text.py
def fit_transform(self, Z): """Learn the vocabulary dictionary and return term-document matrix. This is equivalent to fit followed by transform, but more efficiently implemented. Parameters ---------- Z : iterable or DictRDD with column 'X' An iterable of ra...
def fit_transform(self, Z): """Learn the vocabulary dictionary and return term-document matrix. This is equivalent to fit followed by transform, but more efficiently implemented. Parameters ---------- Z : iterable or DictRDD with column 'X' An iterable of ra...
[ "Learn", "the", "vocabulary", "dictionary", "and", "return", "term", "-", "document", "matrix", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L272-L334
[ "def", "fit_transform", "(", "self", ",", "Z", ")", ":", "self", ".", "_validate_vocabulary", "(", ")", "# map analyzer and cache result", "analyze", "=", "self", ".", "build_analyzer", "(", ")", "A", "=", "Z", ".", "transform", "(", "lambda", "X", ":", "l...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkCountVectorizer.transform
Transform documents to document-term matrix. Extract token counts out of raw text documents using the vocabulary fitted with fit or the one provided to the constructor. Parameters ---------- raw_documents : iterable An iterable which yields either str, unicode or fi...
splearn/feature_extraction/text.py
def transform(self, Z): """Transform documents to document-term matrix. Extract token counts out of raw text documents using the vocabulary fitted with fit or the one provided to the constructor. Parameters ---------- raw_documents : iterable An iterable whi...
def transform(self, Z): """Transform documents to document-term matrix. Extract token counts out of raw text documents using the vocabulary fitted with fit or the one provided to the constructor. Parameters ---------- raw_documents : iterable An iterable whi...
[ "Transform", "documents", "to", "document", "-", "term", "matrix", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L336-L363
[ "def", "transform", "(", "self", ",", "Z", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'vocabulary_'", ")", ":", "self", ".", "_validate_vocabulary", "(", ")", "self", ".", "_check_vocabulary", "(", ")", "analyze", "=", "self", ".", "build_analy...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkHashingVectorizer.transform
Transform an ArrayRDD (or DictRDD with column 'X') containing sequence of documents to a document-term matrix. Parameters ---------- Z : ArrayRDD or DictRDD with raw text documents Samples. Each sample must be a text document (either bytes or unicode strings) whi...
splearn/feature_extraction/text.py
def transform(self, Z): """Transform an ArrayRDD (or DictRDD with column 'X') containing sequence of documents to a document-term matrix. Parameters ---------- Z : ArrayRDD or DictRDD with raw text documents Samples. Each sample must be a text document (either bytes ...
def transform(self, Z): """Transform an ArrayRDD (or DictRDD with column 'X') containing sequence of documents to a document-term matrix. Parameters ---------- Z : ArrayRDD or DictRDD with raw text documents Samples. Each sample must be a text document (either bytes ...
[ "Transform", "an", "ArrayRDD", "(", "or", "DictRDD", "with", "column", "X", ")", "containing", "sequence", "of", "documents", "to", "a", "document", "-", "term", "matrix", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L474-L490
[ "def", "transform", "(", "self", ",", "Z", ")", ":", "mapper", "=", "super", "(", "SparkHashingVectorizer", ",", "self", ")", ".", "transform", "return", "Z", ".", "transform", "(", "mapper", ",", "column", "=", "'X'", ",", "dtype", "=", "sp", ".", "...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkTfidfTransformer.fit
Learn the idf vector (global term weights) Parameters ---------- Z : ArrayRDD or DictRDD containing (sparse matrices|ndarray) a matrix of term/token counts Returns ------- self : TfidfVectorizer
splearn/feature_extraction/text.py
def fit(self, Z): """Learn the idf vector (global term weights) Parameters ---------- Z : ArrayRDD or DictRDD containing (sparse matrices|ndarray) a matrix of term/token counts Returns ------- self : TfidfVectorizer """ X = Z[:, 'X']...
def fit(self, Z): """Learn the idf vector (global term weights) Parameters ---------- Z : ArrayRDD or DictRDD containing (sparse matrices|ndarray) a matrix of term/token counts Returns ------- self : TfidfVectorizer """ X = Z[:, 'X']...
[ "Learn", "the", "idf", "vector", "(", "global", "term", "weights", ")" ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L550-L585
[ "def", "fit", "(", "self", ",", "Z", ")", ":", "X", "=", "Z", "[", ":", ",", "'X'", "]", "if", "isinstance", "(", "Z", ",", "DictRDD", ")", "else", "Z", "check_rdd", "(", "X", ",", "(", "sp", ".", "spmatrix", ",", "np", ".", "ndarray", ")", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkStandardScaler.fit
Compute the mean and std to be used for later scaling. Parameters ---------- Z : DictRDD containing (X, y) pairs X - Training vector. {array-like, sparse matrix}, shape [n_samples, n_features] The data used to compute the mean and standard deviation ...
splearn/preprocessing/data.py
def fit(self, Z): """Compute the mean and std to be used for later scaling. Parameters ---------- Z : DictRDD containing (X, y) pairs X - Training vector. {array-like, sparse matrix}, shape [n_samples, n_features] The data used to compute the m...
def fit(self, Z): """Compute the mean and std to be used for later scaling. Parameters ---------- Z : DictRDD containing (X, y) pairs X - Training vector. {array-like, sparse matrix}, shape [n_samples, n_features] The data used to compute the m...
[ "Compute", "the", "mean", "and", "std", "to", "be", "used", "for", "later", "scaling", ".", "Parameters", "----------", "Z", ":", "DictRDD", "containing", "(", "X", "y", ")", "pairs", "X", "-", "Training", "vector", ".", "{", "array", "-", "like", "spa...
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/preprocessing/data.py#L76-L125
[ "def", "fit", "(", "self", ",", "Z", ")", ":", "# Reset internal state before fitting", "self", ".", "_reset", "(", ")", "X", "=", "Z", "[", ":", ",", "'X'", "]", "if", "isinstance", "(", "Z", ",", "DictRDD", ")", "else", "Z", "check_rdd", "(", "X", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkStandardScaler.transform
Perform standardization by centering and scaling Parameters ---------- Z : DictRDD containing (X, y) pairs X - Training vector y - Target labels Returns ------- C : DictRDD containing (X, y) pairs X - Training vector standardized ...
splearn/preprocessing/data.py
def transform(self, Z): """Perform standardization by centering and scaling Parameters ---------- Z : DictRDD containing (X, y) pairs X - Training vector y - Target labels Returns ------- C : DictRDD containing (X, y) pairs X - ...
def transform(self, Z): """Perform standardization by centering and scaling Parameters ---------- Z : DictRDD containing (X, y) pairs X - Training vector y - Target labels Returns ------- C : DictRDD containing (X, y) pairs X - ...
[ "Perform", "standardization", "by", "centering", "and", "scaling", "Parameters", "----------", "Z", ":", "DictRDD", "containing", "(", "X", "y", ")", "pairs", "X", "-", "Training", "vector", "y", "-", "Target", "labels", "Returns", "-------", "C", ":", "Dict...
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/preprocessing/data.py#L127-L170
[ "def", "transform", "(", "self", ",", "Z", ")", ":", "X", "=", "Z", "[", ":", ",", "'X'", "]", "if", "isinstance", "(", "Z", ",", "DictRDD", ")", "else", "Z", "check_rdd", "(", "X", ",", "(", "np", ".", "ndarray", ",", "sp", ".", "spmatrix", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkStandardScaler.to_scikit
Convert to equivalent StandardScaler
splearn/preprocessing/data.py
def to_scikit(self): """ Convert to equivalent StandardScaler """ scaler = StandardScaler(with_mean=self.with_mean, with_std=self.with_std, copy=self.copy) scaler.__dict__ = self.__dict__ return scaler
def to_scikit(self): """ Convert to equivalent StandardScaler """ scaler = StandardScaler(with_mean=self.with_mean, with_std=self.with_std, copy=self.copy) scaler.__dict__ = self.__dict__ return scaler
[ "Convert", "to", "equivalent", "StandardScaler" ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/preprocessing/data.py#L172-L180
[ "def", "to_scikit", "(", "self", ")", ":", "scaler", "=", "StandardScaler", "(", "with_mean", "=", "self", ".", "with_mean", ",", "with_std", "=", "self", ".", "with_std", ",", "copy", "=", "self", ".", "copy", ")", "scaler", ".", "__dict__", "=", "sel...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkLinearModelMixin._spark_fit
Wraps a Scikit-learn Linear model's fit method to use with RDD input. Parameters ---------- cls : class object The sklearn linear model's class to wrap. Z : TupleRDD or DictRDD The distributed train data in a DictRDD. Returns ------- ...
splearn/linear_model/base.py
def _spark_fit(self, cls, Z, *args, **kwargs): """Wraps a Scikit-learn Linear model's fit method to use with RDD input. Parameters ---------- cls : class object The sklearn linear model's class to wrap. Z : TupleRDD or DictRDD The distributed trai...
def _spark_fit(self, cls, Z, *args, **kwargs): """Wraps a Scikit-learn Linear model's fit method to use with RDD input. Parameters ---------- cls : class object The sklearn linear model's class to wrap. Z : TupleRDD or DictRDD The distributed trai...
[ "Wraps", "a", "Scikit", "-", "learn", "Linear", "model", "s", "fit", "method", "to", "use", "with", "RDD", "input", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/linear_model/base.py#L67-L88
[ "def", "_spark_fit", "(", "self", ",", "cls", ",", "Z", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "mapper", "=", "lambda", "X_y", ":", "super", "(", "cls", ",", "self", ")", ".", "fit", "(", "X_y", "[", "0", "]", ",", "X_y", "[", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkLinearModelMixin._spark_predict
Wraps a Scikit-learn Linear model's predict method to use with RDD input. Parameters ---------- cls : class object The sklearn linear model's class to wrap. Z : ArrayRDD The distributed data to predict in a DictRDD. Returns ------- ...
splearn/linear_model/base.py
def _spark_predict(self, cls, X, *args, **kwargs): """Wraps a Scikit-learn Linear model's predict method to use with RDD input. Parameters ---------- cls : class object The sklearn linear model's class to wrap. Z : ArrayRDD The distributed data to...
def _spark_predict(self, cls, X, *args, **kwargs): """Wraps a Scikit-learn Linear model's predict method to use with RDD input. Parameters ---------- cls : class object The sklearn linear model's class to wrap. Z : ArrayRDD The distributed data to...
[ "Wraps", "a", "Scikit", "-", "learn", "Linear", "model", "s", "predict", "method", "to", "use", "with", "RDD", "input", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/linear_model/base.py#L90-L105
[ "def", "_spark_predict", "(", "self", ",", "cls", ",", "X", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "X", ".", "map", "(", "lambda", "X", ":", "super", "(", "cls", ",", "self", ")", ".", "predict", "(", "X", ",", "*", "a...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkLinearRegression.fit
Fit linear model. Parameters ---------- Z : DictRDD with (X, y) values X containing numpy array or sparse matrix - The training data y containing the target values Returns ------- self : returns an instance of self.
splearn/linear_model/base.py
def fit(self, Z): """ Fit linear model. Parameters ---------- Z : DictRDD with (X, y) values X containing numpy array or sparse matrix - The training data y containing the target values Returns ------- self : returns an instance o...
def fit(self, Z): """ Fit linear model. Parameters ---------- Z : DictRDD with (X, y) values X containing numpy array or sparse matrix - The training data y containing the target values Returns ------- self : returns an instance o...
[ "Fit", "linear", "model", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/linear_model/base.py#L143-L158
[ "def", "fit", "(", "self", ",", "Z", ")", ":", "check_rdd", "(", "Z", ",", "{", "'X'", ":", "(", "sp", ".", "spmatrix", ",", "np", ".", "ndarray", ")", "}", ")", "return", "self", ".", "_spark_fit", "(", "SparkLinearRegression", ",", "Z", ")" ]
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkPipeline.fit
Fit all the transforms one after the other and transform the data, then fit the transformed data using the final estimator. Parameters ---------- Z : ArrayRDD, TupleRDD or DictRDD Input data in blocked distributed format. Returns ------- self : Spark...
splearn/pipeline.py
def fit(self, Z, **fit_params): """Fit all the transforms one after the other and transform the data, then fit the transformed data using the final estimator. Parameters ---------- Z : ArrayRDD, TupleRDD or DictRDD Input data in blocked distributed format. R...
def fit(self, Z, **fit_params): """Fit all the transforms one after the other and transform the data, then fit the transformed data using the final estimator. Parameters ---------- Z : ArrayRDD, TupleRDD or DictRDD Input data in blocked distributed format. R...
[ "Fit", "all", "the", "transforms", "one", "after", "the", "other", "and", "transform", "the", "data", "then", "fit", "the", "transformed", "data", "using", "the", "final", "estimator", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/pipeline.py#L97-L113
[ "def", "fit", "(", "self", ",", "Z", ",", "*", "*", "fit_params", ")", ":", "Zt", ",", "fit_params", "=", "self", ".", "_pre_transform", "(", "Z", ",", "*", "*", "fit_params", ")", "self", ".", "steps", "[", "-", "1", "]", "[", "-", "1", "]", ...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkPipeline.fit_transform
Fit all the transforms one after the other and transform the data, then use fit_transform on transformed data using the final estimator.
splearn/pipeline.py
def fit_transform(self, Z, **fit_params): """Fit all the transforms one after the other and transform the data, then use fit_transform on transformed data using the final estimator.""" Zt, fit_params = self._pre_transform(Z, **fit_params) if hasattr(self.steps[-1][-1], 'fit_trans...
def fit_transform(self, Z, **fit_params): """Fit all the transforms one after the other and transform the data, then use fit_transform on transformed data using the final estimator.""" Zt, fit_params = self._pre_transform(Z, **fit_params) if hasattr(self.steps[-1][-1], 'fit_trans...
[ "Fit", "all", "the", "transforms", "one", "after", "the", "other", "and", "transform", "the", "data", "then", "use", "fit_transform", "on", "transformed", "data", "using", "the", "final", "estimator", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/pipeline.py#L115-L123
[ "def", "fit_transform", "(", "self", ",", "Z", ",", "*", "*", "fit_params", ")", ":", "Zt", ",", "fit_params", "=", "self", ".", "_pre_transform", "(", "Z", ",", "*", "*", "fit_params", ")", "if", "hasattr", "(", "self", ".", "steps", "[", "-", "1"...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkPipeline.score
Applies transforms to the data, and the score method of the final estimator. Valid only if the final estimator implements score.
splearn/pipeline.py
def score(self, Z): """Applies transforms to the data, and the score method of the final estimator. Valid only if the final estimator implements score.""" Zt = Z for name, transform in self.steps[:-1]: Zt = transform.transform(Zt) return self.steps[-1][-1].sco...
def score(self, Z): """Applies transforms to the data, and the score method of the final estimator. Valid only if the final estimator implements score.""" Zt = Z for name, transform in self.steps[:-1]: Zt = transform.transform(Zt) return self.steps[-1][-1].sco...
[ "Applies", "transforms", "to", "the", "data", "and", "the", "score", "method", "of", "the", "final", "estimator", ".", "Valid", "only", "if", "the", "final", "estimator", "implements", "score", "." ]
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/pipeline.py#L125-L132
[ "def", "score", "(", "self", ",", "Z", ")", ":", "Zt", "=", "Z", "for", "name", ",", "transform", "in", "self", ".", "steps", "[", ":", "-", "1", "]", ":", "Zt", "=", "transform", ".", "transform", "(", "Zt", ")", "return", "self", ".", "steps"...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
test
SparkFeatureUnion.fit
TODO: rewrite docstring Fit all transformers using X. Parameters ---------- X : array-like or sparse matrix, shape (n_samples, n_features) Input data, used to fit transformers.
splearn/pipeline.py
def fit(self, Z, **fit_params): """TODO: rewrite docstring Fit all transformers using X. Parameters ---------- X : array-like or sparse matrix, shape (n_samples, n_features) Input data, used to fit transformers. """ fit_params_steps = dict((step, {}) ...
def fit(self, Z, **fit_params): """TODO: rewrite docstring Fit all transformers using X. Parameters ---------- X : array-like or sparse matrix, shape (n_samples, n_features) Input data, used to fit transformers. """ fit_params_steps = dict((step, {}) ...
[ "TODO", ":", "rewrite", "docstring", "Fit", "all", "transformers", "using", "X", ".", "Parameters", "----------", "X", ":", "array", "-", "like", "or", "sparse", "matrix", "shape", "(", "n_samples", "n_features", ")", "Input", "data", "used", "to", "fit", ...
lensacom/sparkit-learn
python
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/pipeline.py#L227-L246
[ "def", "fit", "(", "self", ",", "Z", ",", "*", "*", "fit_params", ")", ":", "fit_params_steps", "=", "dict", "(", "(", "step", ",", "{", "}", ")", "for", "step", ",", "_", "in", "self", ".", "transformer_list", ")", "for", "pname", ",", "pval", "...
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7