components module#

Category components#

Resistor, Capacitor, PolarizedCapacitor and Inductor: ordinary jitx.Component subclasses that resolve themselves from the active PartSource. Their ports exist as soon as they are constructed – p1/p2, or a/c for PolarizedCapacitor – so one can be wired up immediately:

self.top = Resistor(resistance=10 * kohm, tolerance=AtMost(1 * pct))
self.nets = [self.top.p2 + self.bottom.p1]

Each takes its category’s query keywords, or a query object, or both; a query set as a context in an enclosing class body supplies the defaults, and a keyword the category does not name is passed through to the providers.

Constructing one enqueues a query rather than resolving it. The batch resolves when something reads resolved state – part, value, mpn, manufacturer, landpattern, symbol, or any field a provider attached – when the object is introspected, or at the end of elaboration, whichever comes first. Reading early is allowed and costs only the batching.

Two rules the whole module follows. Ports are declared eagerly, because arity is a property of the category and not of the part. And the component does not build geometry: it delegates to the provider’s materialize and validates the result on its own terms.

class Deferred[T][source]#

Bases: Generic[T]

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
ensure_resolved(obj)[source]#

Flush the batch this component belongs to, unless it is already resolved.

Reentrant-safe: _bind writes fields and provider code reads them back while the part is not yet marked resolved, so without the binding guard any such read would re-enter the flush.

Return type:

None

Parameters:

obj (DeferredPart)

class DeferredPart[source]#

Bases: object

Defer part resolution until something reads resolved state.

Resolution happens once and is never invalidated.

apply_metadata(component, identity)[source]#

Write the identity and its attributes onto the component.

Every attribute becomes a field, so r.tolerance and a provider’s own r.aisle read the same way. materialize runs afterwards and may override any of them, and surfaces the payload’s own fields the same way.

mpn and manufacturer come from the identity proper; the rest goes through apply_fields, which skips the names the core and the design own.

Return type:

None

Parameters:
class Resistor(query=None, **kwargs)[source]#

Bases: _Passive

Resistor resolved from the active PartSource.

A bare number for resistance is taken as ohms.

Parameters:
query_type#

alias of ResistorQuery

part: Deferred[ResolvedPart]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
value: Deferred[PlainQuantity]#

Value label string for this component.

landpattern: Deferred[Landpattern]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
symbol: Deferred[Symbol]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
mpn: Deferred[str]#

Manufacturer part number for this component.

manufacturer: Deferred[str | None]#

Manufacturer for this component.

reference_designator_prefix: str | None = 'R'#

Reference designator prefix for this component. This will be used to generate a unique reference designator for each component of the same type.

Note

This field is a required data point for matching components between builds. If this value changes (including changing from unset to set), it will be treated as a new component, even if nothing else changes.

p1: Port#
p2: Port#
class Capacitor(query=None, **kwargs)[source]#

Bases: _Passive

Capacitor resolved from the active PartSource.

A bare number for capacitance is taken as farads.

Leaves polarized unset in the query, and refuses a part marked polarized at bind time instead. A filter cannot express what this category wants: a missing key never matches, so polarized=Exactly(False) would return nothing from every catalogue that does not carry the attribute, and “unpolarized or unmarked” has no spelling in the predicate vocabulary.

Parameters:
query_type#

alias of CapacitorQuery

part: Deferred[ResolvedPart]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
value: Deferred[PlainQuantity]#

Value label string for this component.

landpattern: Deferred[Landpattern]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
symbol: Deferred[Symbol]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
mpn: Deferred[str]#

Manufacturer part number for this component.

manufacturer: Deferred[str | None]#

Manufacturer for this component.

reference_designator_prefix: str | None = 'C'#

Reference designator prefix for this component. This will be used to generate a unique reference designator for each component of the same type.

Note

This field is a required data point for matching components between builds. If this value changes (including changing from unset to set), it will be treated as a new component, even if nothing else changes.

p1: Port#
p2: Port#
class PolarizedCapacitor(query=None, **kwargs)[source]#

Bases: _Passive

Capacitor with a defined polarity.

Restricts the search to polarized parts and exposes anode/cathode rather than interchangeable pins. A sibling of Capacitor, not a subclass: the port names differ, so nothing is inherited usefully and an isinstance relationship between them would be a lie.

A bare number for capacitance is taken as farads.

Parameters:
query_type#

alias of CapacitorQuery

part: Deferred[ResolvedPart]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
value: Deferred[PlainQuantity]#

Value label string for this component.

landpattern: Deferred[Landpattern]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
symbol: Deferred[Symbol]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
mpn: Deferred[str]#

Manufacturer part number for this component.

manufacturer: Deferred[str | None]#

Manufacturer for this component.

a: Port#
c: Port#
class Inductor(query=None, **kwargs)[source]#

Bases: _Passive

Inductor resolved from the active PartSource.

A bare number for inductance is taken as henries.

Parameters:
query_type#

alias of InductorQuery

part: Deferred[ResolvedPart]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
value: Deferred[PlainQuantity]#

Value label string for this component.

landpattern: Deferred[Landpattern]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
symbol: Deferred[Symbol]#

Descriptor for a component field that only exists once a part is resolved.

Reading one resolves the batch and hands back what was bound; a field resolution never set raises AttributeError naming the part that was chosen, rather than returning None. Declare one per field a category promises, annotated with the descriptor type so a checker sees the resolved type:

value: Deferred[jitx.units.PlainQuantity] = Deferred()
mpn: Deferred[str]#

Manufacturer part number for this component.

manufacturer: Deferred[str | None]#

Manufacturer for this component.

reference_designator_prefix: str | None = 'L'#

Reference designator prefix for this component. This will be used to generate a unique reference designator for each component of the same type.

Note

This field is a required data point for matching components between builds. If this value changes (including changing from unset to set), it will be treated as a new component, even if nothing else changes.

p1: Port#
p2: Port#