Skip to content

Unify .connected(...) with DummyBlocks and TestPoints#511

Merged
ducky64 merged 9 commits into
masterfrom
connected-refactor
Jun 1, 2026
Merged

Unify .connected(...) with DummyBlocks and TestPoints#511
ducky64 merged 9 commits into
masterfrom
connected-refactor

Conversation

@ducky64

@ducky64 ducky64 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Adds connected(...) to DummyBlocks with a base class. Unifies the port name to io, adding a deprecation pathway for the older port names.

Refactors the .connected(...) in TestPoints with a base class.

Refactors use sites.

Resolves #506, resolves #500

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes the “single-port utility block” API across Dummy* blocks and TestPoint blocks by introducing a shared .connected(...) helper and unifying the primary port name to io, while refactoring call sites and updating example netlist references accordingly.

Changes:

  • Introduces a typed BaseDummyBlock[...] with a .connected(...) helper and updates Dummy blocks to use a unified io port (with deprecation accessors for older names like .gnd/.pwr).
  • Refactors typed TestPoint implementations around shared generic base classes and provides a unified .connected(...) helper.
  • Updates tests/examples and reference netlists to match the new connection patterns and net naming behavior.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
examples/TestLed/TestLed.svgpcb.js Updates expected net names after Dummy* connection changes.
examples/TestLed/TestLed.net.ref Updates expected netlist reference names to match new net naming.
examples/test_usb_key.py Migrates DummyPassive usage to .connected(...).
examples/test_multimeter.py Migrates DummyPassive usage to .connected(...).
examples/test_iot_led_driver.py Migrates DummyPassive usage to .connected(...).
examples/test_blinky.py Migrates DummyGround/DummyDigitalSource usage to .connected(...) and new net naming.
edg/vendor_parts/jlc/test_JlcResistor.py Replaces chain(...) with DummyPassive .connected(...).
edg/vendor_parts/jlc/test_JlcCapacitor.py Replaces chain(...) with DummyPassive .connected(...).
edg/vendor_parts/jlc/test_inductor.py Replaces chain(...) with DummyPassive .connected(...).
edg/vendor_parts/generic/test_resistor_generic.py Replaces chain(...) with DummyPassive .connected(...) and simplifies instantiation formatting.
edg/vendor_parts/generic/test_capacitor_generic.py Replaces chain(...) with DummyPassive .connected(...).
edg/parts/microcontroller/test_mcu_wrapper.py Updates implicit connects and dummy IO hookups to use .io / .connected(...).
edg/parts/microcontroller/Rp2040.py Updates DummyGround/DummyVoltageSource port usage to .io and adopts .connected(...) in one spot.
edg/parts/microcontroller/nRF52840.py Updates DummyGround/DummyVoltageSource port usage to .io and adopts .connected(...) in one spot.
edg/parts/microcontroller/Esp32s3.py Updates DummyGround/DummyVoltageSource port usage to .io and adopts .connected(...) in one spot.
edg/parts/microcontroller/Esp32c3.py Updates DummyGround/DummyVoltageSource port usage to .io and adopts .connected(...) in one spot.
edg/parts/microcontroller/Esp32.py Updates DummyGround/DummyVoltageSource port usage to .io and adopts .connected(...) in one spot.
edg/parts/display/oled/test_oled_i2c_spi.py Migrates DummyDigitalSource hookups to .connected(...) and .io.
edg/electronics_interfaces/VoltageDummy.py Renames .pwr to .io and adds runtime deprecation via __getattr__; switches to BaseDummyBlock.
edg/electronics_interfaces/test_voltage_link.py Updates tests to connect via .io instead of .pwr.
edg/electronics_interfaces/GroundDummy.py Renames .gnd to .io and adds runtime deprecation via __getattr__; switches to BaseDummyBlock.
edg/electronics_interfaces/DummyDevices.py Adds BaseDummyBlock[...] with .connected(...) and updates Dummy* implementations to inherit it.
edg/circuits/test_switching_converters.py Replaces chain(...) with .connected(...) for dummy sources/sinks/ground.
edg/circuits/test_power_circuits.py Replaces chain(...) with .connected(...) for dummy sources/sinks/ground.
edg/circuits/test_opamp.py Removes bespoke analog dummy and replaces with DummyAnalogSource; migrates to .connected(...).
edg/circuits/test_diodemerge.py Replaces chain(...) with .connected(...) for dummy sources/sink.
edg/circuits/LevelShifter.py Migrates DummyVoltageSink hookup to .connected(...) (currently with a type ignore).
edg/abstract_parts/TestPoint.py Refactors typed test point hierarchy and introduces a generic .connected(...) helper.
edg/abstract_parts/test_ideal_circuit.py Migrates dummy hookups to .connected(...) and .io ports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +12
DummyLinkType = TypeVar("DummyLinkType", bound=Link)


@non_library
Comment on lines +18 to +33
TestPointLinkType = TypeVar("TestPointLinkType", bound=Link)


@non_library
class BaseTypedTestPoint(TypedTestPoint, Block):
class BaseTypedTestPoint(TypedTestPoint, Block, Generic[TestPointLinkType]):
"""Base class with utility infrastructure for typed test points"""

def __init__(self, tp_name: StringLike = "") -> None:
super().__init__()
self.io: Port
self.io: Port[TestPointLinkType]
self.tp_name = self.ArgParameter(tp_name)
self.tp = self.Block(TestPoint(tp_name=StringExpr()))

def connected(self, io: Port[TestPointLinkType]) -> Self:
builder.block().connect(io, self.io)
return self

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 15 comments.



@non_library
class BaseDummyBlock(DummyDevice, Block, Generic[DummyLinkType]):
Comment on lines +35 to +39
warnings.warn(
f"Use .io instead.",
DeprecationWarning,
stacklevel=2,
)
Comment on lines +73 to +77
warnings.warn(
f"Use .io instead.",
DeprecationWarning,
stacklevel=2,
)
Comment on lines +16 to +20
warnings.warn(
f"Use .io instead.",
DeprecationWarning,
stacklevel=2,
)
Comment thread edg/abstract_parts/TestPoint.py Outdated

class GroundTestPoint(BaseTypedTestPoint, Block):
class GroundTestPoint(BaseSingleTestPoint[GroundLink], Block):
"""Test point with a VoltageSink port."""


@non_library
class BaseDummyBlock(DummyDevice, Block, Generic[DummyLinkType]):
Comment on lines +35 to +39
warnings.warn(
f"Use .io instead.",
DeprecationWarning,
stacklevel=2,
)
Comment on lines +73 to +77
warnings.warn(
f"Use .io instead.",
DeprecationWarning,
stacklevel=2,
)
Comment on lines +16 to +20
warnings.warn(
f"Use .io instead.",
DeprecationWarning,
stacklevel=2,
)
Comment thread edg/abstract_parts/TestPoint.py Outdated

class GroundTestPoint(BaseTypedTestPoint, Block):
class GroundTestPoint(BaseSingleTestPoint[GroundLink], Block):
"""Test point with a VoltageSink port."""
@ducky64 ducky64 merged commit dd97ffe into master Jun 1, 2026
12 checks passed
@ducky64 ducky64 deleted the connected-refactor branch June 1, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DummyPort, TestPoint might inherit a SingleIoBlock[P] class to provide .connected Standardize DummyX blocks and add .connected(...) API

2 participants