Skip to content

Commit

Permalink
Minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
wboxx1 committed Oct 10, 2022
1 parent 8b78fb8 commit 9c33ffd
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/antenna_intensity_modeler/parabolic.py
Expand Up @@ -16,7 +16,7 @@
# from .helpers import Either, Left, Right
from pymonad.tools import curry
from pymonad.operators.either import Either, Left, Right
from pymonad.operators.maybe import Nothing, Just
from pymonad.operators.maybe import Nothing, Just, Maybe
from pymonad.operators.list import ListMonad

# Basic units
Expand Down Expand Up @@ -188,14 +188,24 @@ def _run_near_field_corrections(

@curry(2)
def final_reduction(x, y):
return (1.0 + np.cos(theta)) / d * abs(x - 1.0j * y)
if d == 0:
return Left("divide by zero encounted in reduction")
# raise Exception("d cannot be zero.")
else:
return (1.0 + np.cos(theta)) / d * abs(x - 1.0j * y)

# return (1 + np.cos(theta)) / d * abs(Ep1_1 - 1j * Ep2_1)
# return Either.apply(final_reduction).to_arguments(Ep1, Ep2).then(_square)
return (final_reduction << Ep1 & Ep2).then(_square)


def _square(x):
return Just(x ** 2)
return x ** 2


@curry(2)
def _power(x, y):
return y ** x


def _squared(x):
Expand All @@ -215,6 +225,14 @@ def _normalize(y, x):
return x / y


def _normalize_test(x, y):
if y == 0:
# return Nothing
raise Exception("Divide by zero encountered in _normalize.")
else:
return x / y


def _unpack(x):
return x.value

Expand Down

0 comments on commit 9c33ffd

Please sign in to comment.