Skip to content

Commit

Permalink
feat: add @mathpad_constructor to elec module where valid
Browse files Browse the repository at this point in the history
  • Loading branch information
CallumJHays committed Oct 26, 2022
1 parent 04990da commit 806a4d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mathpad/elec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List
from mathpad import *

@mathpad_constructor
def resistance_resistivity(
*,
R: X[Impedance], # resistance
Expand All @@ -12,6 +13,7 @@ def resistance_resistivity(
return R == rho * l * A


@mathpad_constructor
def ohms_law(
*,
R: X[Impedance], # resistance
Expand All @@ -25,6 +27,8 @@ def ohms_law(
"""
return V == I * R

# TODO: support List[X[Voltage]] in @mathpad_constructor
# @mathpad_constructor
def kerchoffs_voltage_law(
*,
producers: List[X[Voltage]], # voltage sources
Expand All @@ -44,6 +48,8 @@ def kerchoffs_voltage_law(
return sum(producers) == sum(consumers) # type: ignore - assert should prevent both being 0 length lists


# TODO: support List[X[Voltage]] in @mathpad_constructor
# @mathpad_constructor
def kerchoffs_current_law(
*,
into: List[X[Current]], # current into node
Expand Down

0 comments on commit 806a4d6

Please sign in to comment.