ideal module#
IdealPassives#
Synthesize a passive at whatever value was asked for, snapped to an E-series. Name it last in a chain, as “ideal” or as IdealPassives(), so a real catalogue is always asked first and a design still elaborates before anyone has approved real parts:
[tool.jitx.parts]
chain = ["csv:parts/approved-parts.csv", "ideal"]
By default the series follows the tolerance of the part it synthesizes: a part is available at the values of every series whose nominal tolerance is at least as loose as its own, so a 1% part snaps to E24 or E96 and a 5% part to E24 only. The synthesized tolerance is the one the query pins, else 1%.
Name a series explicitly as “ideal:E96” (or IdealPassives(series=”E96”)), or join several with +, as in “ideal:E24+E96”, to snap to those regardless of tolerance. Known series are E6, E12, E24, E48, E96 and E192.
Its parts are deliberately not orderable: manufacturer is None, which is the signal that an identity is synthesized rather than purchasable. Drop it from the chain and an unapproved value becomes an error naming what every provider said about it.
It answers only a query whose value constraint pins one value – Exactly, or a Tolerance or Range with an unambiguous typical – and declines anything else per query rather than guessing at a value. Of the other keys it honors case, tolerance and polarized; any key beyond those is ignored, so the part it synthesizes says nothing about it. A case code with no landpattern is declined.
A generator rather than a catalogue, which makes it the smallest example of a provider with no rows to search: nothing to filter, nothing to rank, and distinct left at the default that says it does not enumerate.
- series_for_tolerance(tolerance)[source]#
Mantissas a part of relative tolerance is available in.
The union of every series whose nominal tolerance is at least tolerance; a tolerance looser than any series’ gets E6.
- nearest_e_series(value, series=(1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1))[source]#
The closest E-series value to value, preserving its decade.
- class IdealPart(identity, payload)[source]#
Bases:
objectA synthesized part. Implements ResolvedPart.
- Parameters:
identity (PartIdentity)
- identity: PartIdentity#
- class IdealPassives(series='auto')[source]#
Bases:
CategoryProviderSynthesize an ideal passive at the requested value.
Only serves a query whose value constraint pins one value: Exactly, or a Tolerance/Range whose typical is unambiguous. A query asking for “anything between 1k and 10k” has no single answer to synthesize, so it is declined rather than guessed at.
series is “auto” (the default) to pick values by the synthesized part’s tolerance, or names the E-series values snap to, several joined with + (“E24+E96”). An unknown name raises ValueError.
- Parameters:
series (str)
- name: str = 'ideal'#
How this provider is named in diagnostics and lockfile entries.
Supply it as a dataclass field, a plain class attribute, or an assignment in __init__. A property or a ClassVar is an incompatible override; for a derived name, use field(init=False) and set it in __post_init__.
- discovery_priority: int = -100#
Rank used ONLY when no chain is declared anywhere and one is discovered from entry points; higher is asked first. An explicit PartSource ignores it, because a written chain is already ordered.
Declare it the same way as name.
- config()[source]#
This provider’s configuration as a canonical JSON object.
An object rather than a bare value, so a config is always something with named keys, which is what makes two of them comparable and what keeps a chain digest readable in the file it lands in.
Must cover everything that could change which part gets selected (a file path, a base URL, a series name) and nothing that could not, such as an open connection or a warmed cache.
- resolve_one(query)[source]#
Answer one query. config and rehydrate are still yours to write.
- Return type:
Resolved|NoMatch|Unsupported|Deny- Parameters:
query (CanonicalQuery)
- rehydrate(identity, payload)[source]#
Reconstruct a part from a lockfile entry this provider wrote.
Required of any provider used with a lockfile: only the provider knows what payload means. May raise StalePayload if the payload predates a change it cannot honor.
- Return type:
- Parameters:
identity (PartIdentity)