fibomat.sample module#

Provides the Sample class.

class fibomat.sample.Sample(*, description: str | None = None)[source]#

Bases: Describable

This class is the glueing between all subcomponents of the library. All shapes and their milling settings are added to this class and can be exported with the help of registered backends .

__init__(*, description: str | None = None)[source]#
Args:

description (str, optional): Optional description of the project, default to None

create_site(dim_position: DimVector | Quantity, dim_fov: DimVector | Quantity | None = None, description: str | None = None) Site[source]#

Creates and Site in-place (hence, the Site is automatically added to the sample). Patterns can be added to the returned object.

See fibomat.site.Site.__init__ for argument description.

Returns:

Site

add_site(site_like: Site) None[source]#

Adds a Site to the project. Alternatively, the ‘+=’ operator can be used.

Args:

site_like (Site): new site

Returns:

None

property number_of_sites: int#

int: number of added sites

property bounding_box: DimBoundingBox | None#
plot(show: bool = True, filename: str | Path | None = None, descr_pattern: Set[str] | None = None, **kwargs) BokehBackend[source]#

Plots and save the project using the BokehBackend.

Args:

show (bool): if true, the plot is opened in a browser automatically filename (PathLike, optional): if filename is given, the plot is saved in this file. The file suffix should

be *.htm or *.html, default to None

**kwargs: parameters for the bokeh backend. These are directly passed to the __init__ method of the

BokehBackend class. The title parameter is automatically set to the Sample.description

Returns:

None

export(exp_backend: str | Type[BackendBase], **kwargs) BackendBase[source]#

Exports the project. Note that the method returns the backend object so you will be able to save a file or show a plot. See backends example nd docs for details.

Note

The export method does not save any files on its one. This must be done by the user manually. See docs of the used backend for details.

Args:
exp_backend (str or Type[backend.BackendBase]):

name of the backend or class. The backend must be registered before.

**kwargs: optional arguments are passed to the backend’s __init__ method

Returns:

BackendBase

export_multi(exp_backend: str | Type[BackendBase], **kwargs) List[BackendBase][source]#

Similar to Project.export() but for each fibomat.site.Site an individual backend instance is returned.

This can be usefull if multiple sites are used within fibomat but the pattern system only supports one site at a time.

Returns:

List[BackendBase]

export_with_description(exp_backend: str | Type[BackendBase], descr_pattern: Set[str], **kwargs) BackendBase[source]#

Exports the project. Note that the method returns the backend object so you will be able to save a file or show a plot. See backends example nd docs for details.

Only sites with a description given in descriptions will be exported. An exception is raised, if no site is found with a given description.

Note

The export method does not save any files on its one. This must be done by the user manually. See docs of the used backend for details.

Args:
exp_backend (str or Type[backend.BackendBase]):

name of the backend or class. The backend must be registered before.

descr_pattern (Set[str]): a set of descriptions of the sites which should be exported. **kwargs: optional arguments are passed to the backend’s __init__ method

Returns:

BackendBase

add_annotation(dim_shape: DimShape, filled: bool = False, color: str | None = None, description: str | None = None) None[source]#

Add dim_shape to a annotation layer. This layer is only used to visualize extra shapes and is ignored by the exporting backend.

Args:

dim_shape (DimShape): shape filled (bool): If True, shape is plotted filled (only possible if shape is closed) color (str, Optional): a color bokeh can understand, default to None description (str, optional): description, default to None

Returns:

None

clone() T#

Create a deepcopy of the object.

Returns:

Describable

property description: str | None#

Description str.

Access:

get

Returns:

Optional[str]

with_changed_description(new_descr: str) T#

Clones the object and set the description to new_descr.

Args:

new_descr: new description

Returns:

Describable