Developer modules#

bsb.services#

Provides several services for optional dependencies.

bsb.services.MPI = <bsb.services.mpi.MPIService object>#

MPI service

bsb.services.MPILock = <bsb.services.mpilock.MPILockModule object>#

MPILock service

Service module. Register or access interfaces that may be provided, mocked or missing, but should always behave neatly on import.

class bsb.services.JobPool(scaffold, listeners=None)[source]#

Bases: object

execute(master_event_loop=None)[source]#

Execute the jobs in the queue

In serial execution this runs all of the jobs in the queue in First In First Out order. In parallel execution this enqueues all jobs into the MPIPool unless they have dependencies that need to complete first.

Parameters:

master_event_loop (Callable) – A function that is continuously called while waiting for the jobs to finish in parallel execution

classmethod get_owner(id)[source]#
is_master()[source]#
property owner#
property parallel#
queue(f, args=None, kwargs=None, deps=None)[source]#
queue_chunk(f, chunk, deps=None)[source]#
queue_connectivity(strategy, pre_roi, post_roi, deps=None)[source]#
queue_placement(strategy, chunk, deps=None)[source]#
bsb.services.register_service(attr, provider)[source]#

bsb.topology._layout module#

Internal layout module. Makes sure regions and partitions don’t mutate during layout.

class bsb.topology._layout.Layout(data, owner=None, children=None, frozen=False)[source]#

Bases: object

Container class for all types of partition data. The layout swaps the data of the partition with temporary layout associated data, and tries out experimental changes to the partition data, if the layout process fails, the original partition data is reinstated.

accept()[source]#
property children#
copy()[source]#
property data#
swap()[source]#
class bsb.topology._layout.PartitionData[source]#

Bases: ABC

The partition data is a class that stores the description of a partition for a partition. This allows the Partition interface to define mutating operations such as translate, rotate, scale; for a dry-run we only have to swap out the actual data with temporary data, and the mutation is prevented.

abstract copy()[source]#
class bsb.topology._layout.RhomboidData(ldc, mdc)[source]#

Bases: PartitionData

copy()[source]#

Copy this boundary to a new instance.

property depth#
property dimensions#
property height#
property width#
property x#
property y#
property z#
bsb.topology._layout.box_layout(ldc, mdc)[source]#

bsb._util#

Global internal utility module.

class bsb._util.SortableByAfter[source]#

Bases: object

add_after(after_item)[source]#
abstract create_after()[source]#
abstract get_after()[source]#
abstract get_ordered(objects)[source]#
abstract has_after()[source]#
is_after_satisfied(objects)[source]#

Determine whether the after specification of this object is met. Any objects appearing in self.after need to occur in objects before the object.

Parameters:

objects (list) – Proposed order for which the after condition is checked.

classmethod resolve_order(objects)[source]#

Orders a given dictionary of objects by the class’s default mechanism and then apply the after attribute for further restrictions.

satisfy_after(objects)[source]#

Given an array of objects, place this object after all of the objects specified in the after condition. If objects in the after condition are missing from the given array this object is placed at the end of the array. Modifies the objects array in place.

bsb._util.assert_samelen(*args)[source]#
bsb._util.get_qualified_class_name(x)[source]#
bsb._util.ichain(iterable, /)#

Alternative chain() constructor taking a single iterable argument that evaluates lazily.

bsb._util.immutable()[source]#
bsb._util.listify_input(value)[source]#

Turn any non-list values into a list containing the value. Sequences will be converted to a list using list(), None will be replaced by an empty list.

bsb._util.merge_dicts(a, b)[source]#
bsb._util.obj_str_insert(__str__)[source]#
bsb._util.rotation_matrix_from_vectors(vec1, vec2)[source]#

Find the rotation matrix that aligns vec1 to vec2

Parameters:
  • vec1 – A 3d “source” vector

  • vec2 – A 3d “destination” vector

Return mat:

A transform matrix (3x3) which when applied to vec1, aligns it with vec2.

bsb._util.sanitize_ndarray(arr_input, shape, dtype=None)[source]#
bsb._util.suppress_stdout()[source]#
bsb._util.unique(iter_: Iterable[Any])[source]#