Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates DiodePowerMerge to support an arbitrary number of diode-isolated power inputs by converting it from a fixed 2-input Block into a GeneratorBlock driven by a requested Vector of inputs, and adds a unit test to validate behavior and refinements.
Changes:
- Refactor
DiodePowerMergeinto a generator withpwr_ins: Vector[VoltageSink], dynamically instantiating diodes per requested input. - Add deprecated compatibility accessors for legacy
pwr_in1/pwr_in2. - Add a new unit test validating voltage/current propagation and diode footprint refinement.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
edg/parts/PowerConditioning.py |
Replaces the fixed 2-input DiodePowerMerge with a generator-driven multi-input implementation and adds deprecation shims. |
edg/parts/test_diodemerge.py |
Adds a compile-time unit test covering multi-input merge behavior and diode refinement propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pwr_in = self.pwr_ins.append_elt(VoltageSink(current_draw=self.pwr_out.link().current_drawn), name) | ||
| self.diodes[name] = diode = self.Block( | ||
| Diode( | ||
| reverse_voltage=(0, pwr_in.link().voltage.upper() - input_hull.lower()), |
Comment on lines
+83
to
+97
| def __getattr__(self, item: str) -> Any: | ||
| if item == "pwr_in1": | ||
| warnings.warn( | ||
| f"Use pwr_ins.request(...) instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| ) | ||
| self.diode2 = self.Block( | ||
| Diode( | ||
| reverse_voltage=(0, self.pwr_in2.link().voltage.upper() - output_lower), | ||
| current=self.pwr_out.link().current_drawn, | ||
| voltage_drop=voltage_drop, | ||
| reverse_recovery_time=reverse_recovery_time, | ||
| return self.pwr_ins.request("1") | ||
| elif item == "pwr_in2": | ||
| warnings.warn( | ||
| f"Use pwr_ins.request(...) instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| ) | ||
|
|
||
| self.assign(self.pwr_in1.current_draw, self.pwr_out.link().current_drawn) | ||
| self.assign(self.pwr_in2.current_draw, self.pwr_out.link().current_drawn) | ||
|
|
||
| self.connect(self.pwr_in1.net, self.diode1.anode) | ||
| self.connect(self.pwr_in2.net, self.diode2.anode) | ||
| self.connect(self.pwr_out.net, self.diode1.cathode, self.diode2.cathode) | ||
| return self.pwr_ins.request("2") |
Comment on lines
+57
to
+59
| @override | ||
| def generate(self) -> None: | ||
| super().generate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the static 2-input version with a generator.