_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q225600
LogEvent.to_json
train
def to_json(self, labels=None): """Convert LogEvent object to valid JSON.""" output = self.to_dict(labels) return json.dumps(output, cls=DateTimeEncoder, ensure_ascii=False)
python
{ "resource": "" }
q225601
MLogFilterTool.addFilter
train
def addFilter(self, filterclass): """Add a filter class to the parser.""" if filterclass not in self.filters: self.filters.append(filterclass)
python
{ "resource": "" }
q225602
MLogFilterTool._outputLine
train
def _outputLine(self, logevent, length=None, human=False): """ Print the final line. Provides various options (length, human, datetime changes, ...). """ # adapt timezone output if necessary if self.args['timestamp_format'] != 'none': logevent._reformat_times...
python
{ "resource": "" }
q225603
MLogFilterTool._msToString
train
def _msToString(self, ms): """Change milliseconds to hours min sec ms format.""" hr, ms = divmod(ms, 3600000) mins, ms = divmod(ms, 60000) secs, mill = divmod(ms, 1000) return "%ihr %imin %isecs %ims" % (hr, mins, secs, mill)
python
{ "resource": "" }
q225604
MLogFilterTool._changeMs
train
def _changeMs(self, line): """Change the ms part in the string if needed.""" # use the position of the last space instead try: last_space_pos = line.rindex(' ') except ValueError: return line else: end_str = line[last_space_pos:] ne...
python
{ "resource": "" }
q225605
MLogFilterTool._formatNumbers
train
def _formatNumbers(self, line): """ Format the numbers so that there are commas inserted. For example: 1200300 becomes 1,200,300. """ # below thousands separator syntax only works for # python 2.7, skip for 2.6 if sys.version_info < (2, 7): return lin...
python
{ "resource": "" }
q225606
MLogFilterTool._datetime_key_for_merge
train
def _datetime_key_for_merge(self, logevent): """Helper method for ordering log lines correctly during merge.""" if not logevent: # if logfile end is reached, return max datetime to never # pick this line return datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999, tzutc()) ...
python
{ "resource": "" }
q225607
MLogFilterTool._merge_logfiles
train
def _merge_logfiles(self): """Helper method to merge several files together by datetime.""" # open files, read first lines, extract first dates lines = [next(iter(logfile), None) for logfile in self.args['logfile']] # adjust lines by timezone for i in range(len(lines)): ...
python
{ "resource": "" }
q225608
MLogFilterTool.logfile_generator
train
def logfile_generator(self): """Yield each line of the file, or the next line if several files.""" if not self.args['exclude']: # ask all filters for a start_limit and fast-forward to the maximum start_limits = [f.start_limit for f in self.filters if h...
python
{ "resource": "" }
q225609
MaskFilter.setup
train
def setup(self): """ Create mask list. Consists of all tuples between which this filter accepts lines. """ # get start and end of the mask and set a start_limit if not self.mask_source.start: raise SystemExit("Can't parse format of %s. Is this a log file or "...
python
{ "resource": "" }
q225610
source_files
train
def source_files(mongodb_path): """Find source files.""" for root, dirs, files in os.walk(mongodb_path): for filename in files: # skip files in dbtests folder if 'dbtests' in root: continue if filename.endswith(('.cpp', '.c', '.h')): yi...
python
{ "resource": "" }
q225611
index
train
def index(): """ This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with result.show_result directly and are instead dynamically generated through javas...
python
{ "resource": "" }
q225612
content_sha1
train
def content_sha1(context): """ Used by the FileContent model to automatically compute the sha1 hash of content before storing it to the database. """ try: content = context.current_parameters['content'] except AttributeError: content = context return hashlib.sha1(encodeutils....
python
{ "resource": "" }
q225613
main
train
def main(): """ Returns the about page """ files = models.File.query hosts = models.Host.query facts = models.HostFacts.query playbooks = models.Playbook.query records = models.Data.query tasks = models.Task.query results = models.TaskResult.query if current_app.config['ARA_PLAYBOOK...
python
{ "resource": "" }
q225614
index
train
def index(): """ This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with host.show_host directly and are instead dynamically generated through javascrip...
python
{ "resource": "" }
q225615
WebAppConfig.config
train
def config(self): """ Returns a dictionary for the loaded configuration """ return { key: self.__dict__[key] for key in dir(self) if key.isupper() }
python
{ "resource": "" }
q225616
index
train
def index(): """ This is not served anywhere in the web application. It is used explicitly in the context of generating static files since flask-frozen requires url_for's to crawl content. url_for's are not used with file.show_file directly and are instead dynamically generated through javascrip...
python
{ "resource": "" }
q225617
show_file
train
def show_file(file_): """ Returns details of a file """ file_ = (models.File.query.get(file_)) if file_ is None: abort(404) return render_template('file.html', file_=file_)
python
{ "resource": "" }
q225618
configure_db
train
def configure_db(app): """ 0.10 is the first version of ARA that ships with a stable database schema. We can identify a database that originates from before this by checking if there is an alembic revision available. If there is no alembic revision available, assume we are running the first revi...
python
{ "resource": "" }
q225619
configure_cache
train
def configure_cache(app): """ Sets up an attribute to cache data in the app context """ log = logging.getLogger('ara.webapp.configure_cache') log.debug('Configuring cache') if not getattr(app, '_cache', None): app._cache = {}
python
{ "resource": "" }
q225620
bspline_to_nurbs
train
def bspline_to_nurbs(obj): """ Converts non-rational parametric shapes to rational ones. :param obj: B-Spline shape :type obj: BSpline.Curve, BSpline.Surface or BSpline.Volume :return: NURBS shape :rtype: NURBS.Curve, NURBS.Surface or NURBS.Volume :raises: TypeError """ # B-Spline -> NU...
python
{ "resource": "" }
q225621
nurbs_to_bspline
train
def nurbs_to_bspline(obj, **kwargs): """ Extracts the non-rational components from rational parametric shapes, if possible. The possibility of converting a rational shape to a non-rational one depends on the weights vector. :param obj: NURBS shape :type obj: NURBS.Curve, NURBS.Surface or NURBS.Volume ...
python
{ "resource": "" }
q225622
doolittle
train
def doolittle(matrix_a): """ Doolittle's Method for LU-factorization. :param matrix_a: Input matrix (must be a square matrix) :type matrix_a: list, tuple :return: a tuple containing matrices (L,U) :rtype: tuple """ # Initialize L and U matrices matrix_u = [[0.0 for _ in range(len(matrix...
python
{ "resource": "" }
q225623
read_files
train
def read_files(project, ext): """ Reads files inside the input project directory. """ project_path = os.path.join(os.path.dirname(__file__), project) file_list = os.listdir(project_path) flist = [] flist_path = [] for f in file_list: f_path = os.path.join(project_path, f) if os.p...
python
{ "resource": "" }
q225624
copy_files
train
def copy_files(src, ext, dst): """ Copies files with extensions "ext" from "src" to "dst" directory. """ src_path = os.path.join(os.path.dirname(__file__), src) dst_path = os.path.join(os.path.dirname(__file__), dst) file_list = os.listdir(src_path) for f in file_list: if f == '__init__.py'...
python
{ "resource": "" }
q225625
make_dir
train
def make_dir(project): """ Creates the project directory for compiled modules. """ project_path = os.path.join(os.path.dirname(__file__), project) # Delete the directory and the files inside it if os.path.exists(project_path): shutil.rmtree(project_path) # Create the directory os.mkdir(p...
python
{ "resource": "" }
q225626
in_argv
train
def in_argv(arg_list): """ Checks if any of the elements of the input list is in sys.argv array. """ for arg in sys.argv: for parg in arg_list: if parg == arg or arg.startswith(parg): return True return False
python
{ "resource": "" }
q225627
generate
train
def generate(degree, num_ctrlpts, **kwargs): """ Generates an equally spaced knot vector. It uses the following equality to generate knot vector: :math:`m = n + p + 1` where; * :math:`p`, degree * :math:`n + 1`, number of control points * :math:`m + 1`, number of knots Keyword Arguments:...
python
{ "resource": "" }
q225628
check
train
def check(degree, knot_vector, num_ctrlpts): """ Checks the validity of the input knot vector. Please refer to The NURBS Book (2nd Edition), p.50 for details. :param degree: degree of the curve or the surface :type degree: int :param knot_vector: knot vector to be checked :type knot_vector: li...
python
{ "resource": "" }
q225629
interpolate_curve
train
def interpolate_curve(points, degree, **kwargs): """ Curve interpolation through the data points. Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369-370 for details. Keyword Arguments: * ``centripetal``: activates centripetal parametrization method. *Default: False* :param...
python
{ "resource": "" }
q225630
interpolate_surface
train
def interpolate_surface(points, size_u, size_v, degree_u, degree_v, **kwargs): """ Surface interpolation through the data points. Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details. Keyword Arguments: * ``centripetal``: activates centripetal parametrization meth...
python
{ "resource": "" }
q225631
compute_knot_vector
train
def compute_knot_vector(degree, num_points, params): """ Computes a knot vector from the parameter list using averaging method. Please refer to the Equation 9.8 on The NURBS Book (2nd Edition), pp.365 for details. :param degree: degree :type degree: int :param num_points: number of data points ...
python
{ "resource": "" }
q225632
ginterp
train
def ginterp(coeff_matrix, points): """ Applies global interpolation to the set of data points to find control points. :param coeff_matrix: coefficient matrix :type coeff_matrix: list, tuple :param points: data points :type points: list, tuple :return: control points :rtype: list """ ...
python
{ "resource": "" }
q225633
_build_coeff_matrix
train
def _build_coeff_matrix(degree, knotvector, params, points): """ Builds the coefficient matrix for global interpolation. This function only uses data points to build the coefficient matrix. Please refer to The NURBS Book (2nd Edition), pp364-370 for details. :param degree: degree :type degree: int...
python
{ "resource": "" }
q225634
create_render_window
train
def create_render_window(actors, callbacks, **kwargs): """ Creates VTK render window with an interactor. :param actors: list of VTK actors :type actors: list, tuple :param callbacks: callback functions for registering custom events :type callbacks: dict """ # Get keyword arguments figur...
python
{ "resource": "" }
q225635
create_color
train
def create_color(color): """ Creates VTK-compatible RGB color from a color string. :param color: color :type color: str :return: RGB color values :rtype: list """ if color[0] == "#": # Convert hex string to RGB return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)] ...
python
{ "resource": "" }
q225636
create_actor_pts
train
def create_actor_pts(pts, color, **kwargs): """ Creates a VTK actor for rendering scatter plots. :param pts: points :type pts: vtkFloatArray :param color: actor color :type color: list :return: a VTK actor :rtype: vtkActor """ # Keyword arguments array_name = kwargs.get('name', ...
python
{ "resource": "" }
q225637
create_actor_polygon
train
def create_actor_polygon(pts, color, **kwargs): """ Creates a VTK actor for rendering polygons. :param pts: points :type pts: vtkFloatArray :param color: actor color :type color: list :return: a VTK actor :rtype: vtkActor """ # Keyword arguments array_name = kwargs.get('name', "...
python
{ "resource": "" }
q225638
create_actor_mesh
train
def create_actor_mesh(pts, lines, color, **kwargs): """ Creates a VTK actor for rendering quadrilateral plots. :param pts: points :type pts: vtkFloatArray :param lines: point connectivity information :type lines: vtkIntArray :param color: actor color :type color: list :return: a VTK act...
python
{ "resource": "" }
q225639
create_actor_tri
train
def create_actor_tri(pts, tris, color, **kwargs): """ Creates a VTK actor for rendering triangulated surface plots. :param pts: points :type pts: vtkFloatArray :param tris: list of triangle indices :type tris: ndarray :param color: actor color :type color: list :return: a VTK actor ...
python
{ "resource": "" }
q225640
create_actor_hexahedron
train
def create_actor_hexahedron(grid, color, **kwargs): """ Creates a VTK actor for rendering voxels using hexahedron elements. :param grid: grid :type grid: ndarray :param color: actor color :type color: list :return: a VTK actor :rtype: vtkActor """ # Keyword arguments array_name ...
python
{ "resource": "" }
q225641
create_actor_delaunay
train
def create_actor_delaunay(pts, color, **kwargs): """ Creates a VTK actor for rendering triangulated plots using Delaunay triangulation. Keyword Arguments: * ``d3d``: flag to choose between Delaunay2D (``False``) and Delaunay3D (``True``). *Default: False* :param pts: points :type pts: vtkFloat...
python
{ "resource": "" }
q225642
flip_ctrlpts_u
train
def flip_ctrlpts_u(ctrlpts, size_u, size_v): """ Flips a list of 1-dimensional control points from u-row order to v-row order. **u-row order**: each row corresponds to a list of u values **v-row order**: each row corresponds to a list of v values :param ctrlpts: control points in u-row order :typ...
python
{ "resource": "" }
q225643
generate_ctrlptsw
train
def generate_ctrlptsw(ctrlpts): """ Generates weighted control points from unweighted ones in 1-D. This function #. Takes in a 1-D control points list whose coordinates are organized in (x, y, z, w) format #. converts into (x*w, y*w, z*w, w) format #. Returns the result :param ctrlpts: 1-D co...
python
{ "resource": "" }
q225644
generate_ctrlpts_weights
train
def generate_ctrlpts_weights(ctrlpts): """ Generates unweighted control points from weighted ones in 1-D. This function #. Takes in 1-D control points list whose coordinates are organized in (x*w, y*w, z*w, w) format #. Converts the input control points list into (x, y, z, w) format #. Returns the...
python
{ "resource": "" }
q225645
combine_ctrlpts_weights
train
def combine_ctrlpts_weights(ctrlpts, weights=None): """ Multiplies control points by the weights to generate weighted control points. This function is dimension agnostic, i.e. control points can be in any dimension but weights should be 1D. The ``weights`` function parameter can be set to None to let the ...
python
{ "resource": "" }
q225646
separate_ctrlpts_weights
train
def separate_ctrlpts_weights(ctrlptsw): """ Divides weighted control points by weights to generate unweighted control points and weights vector. This function is dimension agnostic, i.e. control points can be in any dimension but the last element of the array should indicate the weight. :param ctrlpts...
python
{ "resource": "" }
q225647
flip_ctrlpts2d_file
train
def flip_ctrlpts2d_file(file_in='', file_out='ctrlpts_flip.txt'): """ Flips u and v directions of a 2D control points file and saves flipped coordinates to a file. :param file_in: name of the input file (to be read) :type file_in: str :param file_out: name of the output file (to be saved) :type fil...
python
{ "resource": "" }
q225648
generate_ctrlptsw2d_file
train
def generate_ctrlptsw2d_file(file_in='', file_out='ctrlptsw.txt'): """ Generates weighted control points from unweighted ones in 2-D. This function #. Takes in a 2-D control points file whose coordinates are organized in (x, y, z, w) format #. Converts into (x*w, y*w, z*w, w) format #. Saves the r...
python
{ "resource": "" }
q225649
VisConfig.keypress_callback
train
def keypress_callback(self, obj, ev): """ VTK callback for keypress events. Keypress events: * ``e``: exit the application * ``p``: pick object (hover the mouse and then press to pick) * ``f``: fly to point (click somewhere in the window and press to fly) ...
python
{ "resource": "" }
q225650
generate_voxel_grid
train
def generate_voxel_grid(bbox, szval, use_cubes=False): """ Generates the voxel grid with the desired size. :param bbox: bounding box :type bbox: list, tuple :param szval: size in x-, y-, z-directions :type szval: list, tuple :param use_cubes: use cube voxels instead of cuboid ones :type use...
python
{ "resource": "" }
q225651
process_template
train
def process_template(file_src): """ Process Jinja2 template input :param file_src: file contents :type file_src: str """ def tmpl_sqrt(x): """ Square-root of 'x' """ return math.sqrt(x) def tmpl_cubert(x): """ Cube-root of 'x' """ return x ** (1.0 / 3.0) if x >=...
python
{ "resource": "" }
q225652
import_surf_mesh
train
def import_surf_mesh(file_name): """ Generates a NURBS surface object from a mesh file. :param file_name: input mesh file :type file_name: str :return: a NURBS surface :rtype: NURBS.Surface """ raw_content = read_file(file_name) raw_content = raw_content.split("\n") content = [] ...
python
{ "resource": "" }
q225653
import_vol_mesh
train
def import_vol_mesh(file_name): """ Generates a NURBS volume object from a mesh file. :param file_name: input mesh file :type file_name: str :return: a NURBS volume :rtype: NURBS.Volume """ raw_content = read_file(file_name) raw_content = raw_content.split("\n") content = [] for...
python
{ "resource": "" }
q225654
import_txt
train
def import_txt(file_name, two_dimensional=False, **kwargs): """ Reads control points from a text file and generates a 1-dimensional list of control points. The following code examples illustrate importing different types of text files for curves and surfaces: .. code-block:: python :linenos: ...
python
{ "resource": "" }
q225655
export_txt
train
def export_txt(obj, file_name, two_dimensional=False, **kwargs): """ Exports control points as a text file. For curves the output is always a list of control points. For surfaces, it is possible to generate a 2-dimensional control point output file using ``two_dimensional``. Please see :py:func:`.exch...
python
{ "resource": "" }
q225656
import_csv
train
def import_csv(file_name, **kwargs): """ Reads control points from a CSV file and generates a 1-dimensional list of control points. It is possible to use a different value separator via ``separator`` keyword argument. The following code segment illustrates the usage of ``separator`` keyword argument. ...
python
{ "resource": "" }
q225657
export_csv
train
def export_csv(obj, file_name, point_type='evalpts', **kwargs): """ Exports control points or evaluated points as a CSV file. :param obj: a spline geometry object :type obj: abstract.SplineGeometry :param file_name: output file name :type file_name: str :param point_type: ``ctrlpts`` for contro...
python
{ "resource": "" }
q225658
import_cfg
train
def import_cfg(file_name, **kwargs): """ Imports curves and surfaces from files in libconfig format. .. note:: Requires `libconf <https://pypi.org/project/libconf/>`_ package. Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details. :param fi...
python
{ "resource": "" }
q225659
export_cfg
train
def export_cfg(obj, file_name): """ Exports curves and surfaces in libconfig format. .. note:: Requires `libconf <https://pypi.org/project/libconf/>`_ package. Libconfig format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_ as a way to input sh...
python
{ "resource": "" }
q225660
import_yaml
train
def import_yaml(file_name, **kwargs): """ Imports curves and surfaces from files in YAML format. .. note:: Requires `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_ package. Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details. :para...
python
{ "resource": "" }
q225661
export_yaml
train
def export_yaml(obj, file_name): """ Exports curves and surfaces in YAML format. .. note:: Requires `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_ package. YAML format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_ as a way to input sha...
python
{ "resource": "" }
q225662
import_json
train
def import_json(file_name, **kwargs): """ Imports curves and surfaces from files in JSON format. Use ``jinja2=True`` to activate Jinja2 template processing. Please refer to the documentation for details. :param file_name: name of the input file :type file_name: str :return: a list of rational spli...
python
{ "resource": "" }
q225663
export_json
train
def export_json(obj, file_name): """ Exports curves and surfaces in JSON format. JSON format is also used by the `geomdl command-line application <https://github.com/orbingol/geomdl-cli>`_ as a way to input shape data from the command line. :param obj: input geometry :type obj: abstract.SplineGeom...
python
{ "resource": "" }
q225664
import_obj
train
def import_obj(file_name, **kwargs): """ Reads .obj files and generates faces. Keyword Arguments: * ``callback``: reference to the function that processes the faces for customized output The structure of the callback function is shown below: .. code-block:: python def my_callback_fun...
python
{ "resource": "" }
q225665
select_color
train
def select_color(cpcolor, evalcolor, idx=0): """ Selects item color for plotting. :param cpcolor: color for control points grid item :type cpcolor: str, list, tuple :param evalcolor: color for evaluated points grid item :type evalcolor: str, list, tuple :param idx: index of the current geometry...
python
{ "resource": "" }
q225666
process_tessellate
train
def process_tessellate(elem, update_delta, delta, **kwargs): """ Tessellates surfaces. .. note:: Helper function required for ``multiprocessing`` :param elem: surface :type elem: abstract.Surface :param update_delta: flag to control evaluation delta updates :type update_delta: bool :param ...
python
{ "resource": "" }
q225667
process_elements_surface
train
def process_elements_surface(elem, mconf, colorval, idx, force_tsl, update_delta, delta, reset_names): """ Processes visualization elements for surfaces. .. note:: Helper function required for ``multiprocessing`` :param elem: surface :type elem: abstract.Surface :param mconf: visualization module ...
python
{ "resource": "" }
q225668
find_span_binsearch
train
def find_span_binsearch(degree, knot_vector, num_ctrlpts, knot, **kwargs): """ Finds the span of the knot over the input knot vector using binary search. Implementation of Algorithm A2.1 from The NURBS Book by Piegl & Tiller. The NURBS Book states that the knot span index always starts from zero, i.e. for...
python
{ "resource": "" }
q225669
find_span_linear
train
def find_span_linear(degree, knot_vector, num_ctrlpts, knot, **kwargs): """ Finds the span of a single knot over the knot vector using linear search. Alternative implementation for the Algorithm A2.1 from The NURBS Book by Piegl & Tiller. :param degree: degree, :math:`p` :type degree: int :param k...
python
{ "resource": "" }
q225670
find_spans
train
def find_spans(degree, knot_vector, num_ctrlpts, knots, func=find_span_linear): """ Finds spans of a list of knots over the knot vector. :param degree: degree, :math:`p` :type degree: int :param knot_vector: knot vector, :math:`U` :type knot_vector: list, tuple :param num_ctrlpts: number of con...
python
{ "resource": "" }
q225671
find_multiplicity
train
def find_multiplicity(knot, knot_vector, **kwargs): """ Finds knot multiplicity over the knot vector. Keyword Arguments: * ``tol``: tolerance (delta) value for equality checking :param knot: knot or parameter, :math:`u` :type knot: float :param knot_vector: knot vector, :math:`U` :type...
python
{ "resource": "" }
q225672
basis_function
train
def basis_function(degree, knot_vector, span, knot): """ Computes the non-vanishing basis functions for a single parameter. Implementation of Algorithm A2.2 from The NURBS Book by Piegl & Tiller. :param degree: degree, :math:`p` :type degree: int :param knot_vector: knot vector, :math:`U` :typ...
python
{ "resource": "" }
q225673
basis_functions
train
def basis_functions(degree, knot_vector, spans, knots): """ Computes the non-vanishing basis functions for a list of parameters. :param degree: degree, :math:`p` :type degree: int :param knot_vector: knot vector, :math:`U` :type knot_vector: list, tuple :param spans: list of knot spans :typ...
python
{ "resource": "" }
q225674
basis_function_all
train
def basis_function_all(degree, knot_vector, span, knot): """ Computes all non-zero basis functions of all degrees from 0 up to the input degree for a single parameter. A slightly modified version of Algorithm A2.2 from The NURBS Book by Piegl & Tiller. :param degree: degree, :math:`p` :type degree: in...
python
{ "resource": "" }
q225675
basis_functions_ders
train
def basis_functions_ders(degree, knot_vector, spans, knots, order): """ Computes derivatives of the basis functions for a list of parameters. :param degree: degree, :math:`p` :type degree: int :param knot_vector: knot vector, :math:`U` :type knot_vector: list, tuple :param spans: list of knot s...
python
{ "resource": "" }
q225676
basis_function_one
train
def basis_function_one(degree, knot_vector, span, knot): """ Computes the value of a basis function for a single parameter. Implementation of Algorithm 2.4 from The NURBS Book by Piegl & Tiller. :param degree: degree, :math:`p` :type degree: int :param knot_vector: knot vector :type knot_vecto...
python
{ "resource": "" }
q225677
VisConfig.set_axes_equal
train
def set_axes_equal(ax): """ Sets equal aspect ratio across the three axes of a 3D plot. Contributed by Xuefeng Zhao. :param ax: a Matplotlib axis, e.g., as output from plt.gca(). """ bounds = [ax.get_xlim3d(), ax.get_ylim3d(), ax.get_zlim3d()] ranges = [abs(bound[1] - b...
python
{ "resource": "" }
q225678
VisSurface.animate
train
def animate(self, **kwargs): """ Animates the surface. This function only animates the triangulated surface. There will be no other elements, such as control points grid or bounding box. Keyword arguments: * ``colormap``: applies colormap to the surface Colormaps a...
python
{ "resource": "" }
q225679
tangent_curve_single_list
train
def tangent_curve_single_list(obj, param_list, normalize): """ Evaluates the curve tangent vectors at the given list of parameter values. :param obj: input curve :type obj: abstract.Curve :param param_list: parameter list :type param_list: list or tuple :param normalize: if True, the returned v...
python
{ "resource": "" }
q225680
normal_curve_single
train
def normal_curve_single(obj, u, normalize): """ Evaluates the curve normal vector at the input parameter, u. Curve normal is calculated from the 2nd derivative of the curve at the input parameter, u. The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself. ...
python
{ "resource": "" }
q225681
normal_curve_single_list
train
def normal_curve_single_list(obj, param_list, normalize): """ Evaluates the curve normal vectors at the given list of parameter values. :param obj: input curve :type obj: abstract.Curve :param param_list: parameter list :type param_list: list or tuple :param normalize: if True, the returned vec...
python
{ "resource": "" }
q225682
binormal_curve_single
train
def binormal_curve_single(obj, u, normalize): """ Evaluates the curve binormal vector at the given u parameter. Curve binormal is the cross product of the normal and the tangent vectors. The output returns a list containing the starting point (i.e. origin) of the vector and the vector itself. :param o...
python
{ "resource": "" }
q225683
binormal_curve_single_list
train
def binormal_curve_single_list(obj, param_list, normalize): """ Evaluates the curve binormal vectors at the given list of parameter values. :param obj: input curve :type obj: abstract.Curve :param param_list: parameter list :type param_list: list or tuple :param normalize: if True, the returned...
python
{ "resource": "" }
q225684
tangent_surface_single_list
train
def tangent_surface_single_list(obj, param_list, normalize): """ Evaluates the surface tangent vectors at the given list of parameter values. :param obj: input surface :type obj: abstract.Surface :param param_list: parameter list :type param_list: list or tuple :param normalize: if True, the re...
python
{ "resource": "" }
q225685
normal_surface_single_list
train
def normal_surface_single_list(obj, param_list, normalize): """ Evaluates the surface normal vectors at the given list of parameter values. :param obj: input surface :type obj: abstract.Surface :param param_list: parameter list :type param_list: list or tuple :param normalize: if True, the retu...
python
{ "resource": "" }
q225686
find_ctrlpts_curve
train
def find_ctrlpts_curve(t, curve, **kwargs): """ Finds the control points involved in the evaluation of the curve point defined by the input parameter. This function uses a modified version of the algorithm *A3.1 CurvePoint* from The NURBS Book by Piegl & Tiller. :param t: parameter :type t: float ...
python
{ "resource": "" }
q225687
find_ctrlpts_surface
train
def find_ctrlpts_surface(t_u, t_v, surf, **kwargs): """ Finds the control points involved in the evaluation of the surface point defined by the input parameter pair. This function uses a modified version of the algorithm *A3.5 SurfacePoint* from The NURBS Book by Piegl & Tiller. :param t_u: parameter on t...
python
{ "resource": "" }
q225688
link_curves
train
def link_curves(*args, **kwargs): """ Links the input curves together. The end control point of the curve k has to be the same with the start control point of the curve k + 1. Keyword Arguments: * ``tol``: tolerance value for checking equality. *Default: 10e-8* * ``validate``: flag to enab...
python
{ "resource": "" }
q225689
add_dimension
train
def add_dimension(obj, **kwargs): """ Elevates the spatial dimension of the spline geometry. If you pass ``inplace=True`` keyword argument, the input will be updated. Otherwise, this function does not change the input but returns a new instance with the updated data. :param obj: spline geometry :t...
python
{ "resource": "" }
q225690
split_curve
train
def split_curve(obj, param, **kwargs): """ Splits the curve at the input parametric coordinate. This method splits the curve into two pieces at the given parametric coordinate, generates two different curve objects and returns them. It does not modify the input curve. Keyword Arguments: * ``fi...
python
{ "resource": "" }
q225691
decompose_curve
train
def decompose_curve(obj, **kwargs): """ Decomposes the curve into Bezier curve segments of the same degree. This operation does not modify the input curve, instead it returns the split curve segments. Keyword Arguments: * ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.find...
python
{ "resource": "" }
q225692
length_curve
train
def length_curve(obj): """ Computes the approximate length of the parametric curve. Uses the following equation to compute the approximate length: .. math:: \\sum_{i=0}^{n-1} \\sqrt{P_{i + 1}^2-P_{i}^2} where :math:`n` is number of evaluated curve points and :math:`P` is the n-dimensional po...
python
{ "resource": "" }
q225693
split_surface_u
train
def split_surface_u(obj, param, **kwargs): """ Splits the surface at the input parametric coordinate on the u-direction. This method splits the surface into two pieces at the given parametric coordinate on the u-direction, generates two different surface objects and returns them. It does not modify the inp...
python
{ "resource": "" }
q225694
decompose_surface
train
def decompose_surface(obj, **kwargs): """ Decomposes the surface into Bezier surface patches of the same degree. This operation does not modify the input surface, instead it returns the surface patches. Keyword Arguments: * ``find_span_func``: FindSpan implementation. *Default:* :func:`.helpers.fi...
python
{ "resource": "" }
q225695
tangent
train
def tangent(obj, params, **kwargs): """ Evaluates the tangent vector of the curves or surfaces at the input parameter values. This function is designed to evaluate tangent vectors of the B-Spline and NURBS shapes at single or multiple parameter positions. :param obj: input shape :type obj: abstrac...
python
{ "resource": "" }
q225696
normal
train
def normal(obj, params, **kwargs): """ Evaluates the normal vector of the curves or surfaces at the input parameter values. This function is designed to evaluate normal vectors of the B-Spline and NURBS shapes at single or multiple parameter positions. :param obj: input geometry :type obj: abstrac...
python
{ "resource": "" }
q225697
binormal
train
def binormal(obj, params, **kwargs): """ Evaluates the binormal vector of the curves or surfaces at the input parameter values. This function is designed to evaluate binormal vectors of the B-Spline and NURBS shapes at single or multiple parameter positions. :param obj: input shape :type obj: abst...
python
{ "resource": "" }
q225698
translate
train
def translate(obj, vec, **kwargs): """ Translates curves, surface or volumes by the input vector. Keyword Arguments: * ``inplace``: if False, operation applied to a copy of the object. *Default: False* :param obj: input geometry :type obj: abstract.SplineGeometry or multi.AbstractContainer ...
python
{ "resource": "" }
q225699
scale
train
def scale(obj, multiplier, **kwargs): """ Scales curves, surfaces or volumes by the input multiplier. Keyword Arguments: * ``inplace``: if False, operation applied to a copy of the object. *Default: False* :param obj: input geometry :type obj: abstract.SplineGeometry, multi.AbstractGeometry ...
python
{ "resource": "" }