argsloader.units.mathop

abs_

argsloader.units.mathop.abs_(v1=<SingletonMark 'math_op_self'>) → _UnaryOpUnit
Overview:s

Get the abs unary operation unit.

Parameters

v1 – First value, default means the argsloader.units.utils.keep() will be used.

Returns

Abs operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import abs_
>>> u = abs_()
>>> u(10)
10
>>> u(0)
0
  • Inner nested usage

>>> u = abs_(lambda x: x + 2)
>>> u(8)
10
>>> u(-2)
0
  • Prefix usage

>>> u = (lambda x: x + 2) >> abs_()
>>> u(8)
10
>>> u(-2)
0

inv

argsloader.units.mathop.inv(v1=<SingletonMark 'math_op_self'>) → _UnaryOpUnit
Overview:s

Get the invert unary operation unit.

Parameters

v1 – First value, default means the argsloader.units.utils.keep() will be used.

Returns

Invert operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import invert
>>> u = invert()
>>> u(10)
-11
>>> u(0)
-1
  • Inner nested usage

>>> u = invert(lambda x: x + 2)
>>> u(8)
-11
>>> u(-2)
-1
  • Prefix usage

>>> u = (lambda x: x + 2) >> invert()
>>> u(8)
-11
>>> u(-2)
-1

invert

argsloader.units.mathop.invert(v1=<SingletonMark 'math_op_self'>) → _UnaryOpUnit
Overview:s

Get the invert unary operation unit.

Parameters

v1 – First value, default means the argsloader.units.utils.keep() will be used.

Returns

Invert operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import invert
>>> u = invert()
>>> u(10)
-11
>>> u(0)
-1
  • Inner nested usage

>>> u = invert(lambda x: x + 2)
>>> u(8)
-11
>>> u(-2)
-1
  • Prefix usage

>>> u = (lambda x: x + 2) >> invert()
>>> u(8)
-11
>>> u(-2)
-1

pos

argsloader.units.mathop.pos(v1=<SingletonMark 'math_op_self'>) → _UnaryOpUnit
Overview:s

Get the pos unary operation unit.

Parameters

v1 – First value, default means the argsloader.units.utils.keep() will be used.

Returns

Pos operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import pos
>>> u = pos()
>>> u(10)
10
>>> u(0)
0
  • Inner nested usage

>>> u = pos(lambda x: x + 2)
>>> u(8)
10
>>> u(-2)
0
  • Prefix usage

>>> u = (lambda x: x + 2) >> pos()
>>> u(8)
10
>>> u(-2)
0

neg

argsloader.units.mathop.neg(v1=<SingletonMark 'math_op_self'>) → _UnaryOpUnit
Overview:s

Get the neg unary operation unit.

Parameters

v1 – First value, default means the argsloader.units.utils.keep() will be used.

Returns

Neg operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import neg
>>> u = neg()
>>> u(10)
-10
>>> u(0)
0
  • Inner nested usage

>>> u = neg(lambda x: x + 2)
>>> u(8)
-10
>>> u(-2)
0
  • Prefix usage

>>> u = (lambda x: x + 2) >> neg()
>>> u(8)
-10
>>> u(-2)
0

not_

argsloader.units.mathop.not_(v1=<SingletonMark 'math_op_self'>) → _UnaryOpUnit
Overview:s

Get the not unary operation unit.

Parameters

v1 – First value, default means the argsloader.units.utils.keep() will be used.

Returns

Not operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import not_
>>> u = not_()
>>> u(10)
False
>>> u(0)
True
  • Inner nested usage

>>> u = not_(lambda x: x + 2)
>>> u(8)
False
>>> u(-2)
True
  • Prefix usage

>>> u = (lambda x: x + 2) >> not_()
>>> u(8)
False
>>> u(-2)
True

add

argsloader.units.mathop.add(v1, *vs) → _BinaryOpUnit
Overview:

Get the add binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Add operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import add, keep
>>> u = add(keep(), 3)
>>> u(23)  # 23 + 3
26
  • Multiple usage

>>> u = add(keep(), 3, lambda x: x * 2)  # 23 + 3 + (23 * 2)
72
  • Suffix from usage

>>> u = keep() >> add.from_(3)
>>> u(23)  # 3 + 23
26
  • Suffix by usage

>>> u = keep() >> add.by(3)
>>> u(23)  # 23 + 3
26

plus

argsloader.units.mathop.plus(v1, *vs) → _BinaryOpUnit
Overview:

Get the add binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Add operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import add, keep
>>> u = add(keep(), 3)
>>> u(23)  # 23 + 3
26
  • Multiple usage

>>> u = add(keep(), 3, lambda x: x * 2)  # 23 + 3 + (23 * 2)
72
  • Suffix from usage

>>> u = keep() >> add.from_(3)
>>> u(23)  # 3 + 23
26
  • Suffix by usage

>>> u = keep() >> add.by(3)
>>> u(23)  # 23 + 3
26

sub

argsloader.units.mathop.sub(v1, v2) → _BinaryOpUnit
Overview:

Get the sub binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Sub operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import sub, keep
>>> u = sub(keep(), 3)
>>> u(23)  # 23 - 3
20
  • Suffix from usage

>>> u = keep() >> sub.from_(3)
>>> u(23)  # 3 - 23
-20
  • Suffix by usage

>>> u = keep() >> sub.by(3)
>>> u(23)  # 23 - 3
20

minus

argsloader.units.mathop.minus(v1, v2) → _BinaryOpUnit
Overview:

Get the sub binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Sub operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import sub, keep
>>> u = sub(keep(), 3)
>>> u(23)  # 23 - 3
20
  • Suffix from usage

>>> u = keep() >> sub.from_(3)
>>> u(23)  # 3 - 23
-20
  • Suffix by usage

>>> u = keep() >> sub.by(3)
>>> u(23)  # 23 - 3
20

mul

argsloader.units.mathop.mul(v1, *vs) → _BinaryOpUnit
Overview:

Get the mul binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Mul operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import mul, keep
>>> u = mul(keep(), 3)
>>> u(23)  # 23 * 3
69
  • Multiple usage

>>> u = mul(keep(), 3, lambda x: x * 2)  # 23 * 3 * (23 * 2)
3174
  • Suffix from usage

>>> u = keep() >> mul.from_(3)
>>> u(23)  # 3 * 23
69
  • Suffix by usage

>>> u = keep() >> mul.by(3)
>>> u(23)  # 23 * 3
69

matmul

argsloader.units.mathop.matmul(v1, *vs) → _BinaryOpUnit

Similar to mul(), it can be used when matrices are multiplied together.

truediv

argsloader.units.mathop.truediv(v1, v2) → _BinaryOpUnit
Overview:

Get the truediv binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Truediv operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import truediv, keep
>>> u = truediv(keep(), 3)
>>> u(23)  # 23 / 3
7.666666666666667
  • Suffix from usage

>>> u = keep() >> truediv.from_(3)
>>> u(23)  # 3 / 23
0.13043478260869565
  • Suffix by usage

>>> u = keep() >> truediv.by(3)
>>> u(23)  # 23 / 3
7.666666666666667

floordiv

argsloader.units.mathop.floordiv(v1, v2) → _BinaryOpUnit
Overview:

Get the floordiv binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Floordiv operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import floordiv, keep
>>> u = floordiv(keep(), 3)
>>> u(23)  # 23 // 3
7
  • Suffix from usage

>>> u = keep() >> floordiv.from_(3)
>>> u(23)  # 3 // 23
0
  • Suffix by usage

>>> u = keep() >> floordiv.by(3)
>>> u(23)  # 23 // 3
7

mod

argsloader.units.mathop.mod(v1, v2) → _BinaryOpUnit
Overview:

Get the mod binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Mod operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import mod, keep
>>> u = mod(keep(), 3)
>>> u(23)  # 23 % 3
2
  • Suffix from usage

>>> u = keep() >> mod.from_(3)
>>> u(23)  # 3 % 23
3
  • Suffix by usage

>>> u = keep() >> mod.by(3)
>>> u(23)  # 23 % 3
2

pow_

argsloader.units.mathop.pow_(v1, v2) → _BinaryOpUnit
Overview:

Get the pow binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Pow operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import pow_, keep
>>> u = pow_(keep(), 3)
>>> u(23)  # 23 ** 3
12167
  • Suffix from usage

>>> u = keep() >> pow_.from_(3)
>>> u(23)  # 3 ** 23
94143178827
  • Suffix by usage

>>> u = keep() >> pow_.by(3)
>>> u(23)  # 23 ** 3
12167

lshift

argsloader.units.mathop.lshift(v1, v2) → _BinaryOpUnit
Overview:

Get the lshift binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Lshift operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import lshift, keep
>>> u = lshift(keep(), 3)
>>> u(23)  # 23 << 3
184
  • Suffix from usage

>>> u = keep() >> lshift.from_(3)
>>> u(23)  # 3 << 23
25165824
  • Suffix by usage

>>> u = keep() >> lshift.by(3)
>>> u(23)  # 23 << 3
184

rshift

argsloader.units.mathop.rshift(v1, v2) → _BinaryOpUnit
Overview:

Get the rshift binary operation unit.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Rshift operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import rshift, keep
>>> u = rshift(keep(), 3)
>>> u(23)  # 23 >> 3
2
  • Suffix from usage

>>> u = keep() >> rshift.from_(3)
>>> u(23)  # 3 >> 23
0
  • Suffix by usage

>>> u = keep() >> rshift.by(3)
>>> u(23)  # 23 >> 3
2

and_

argsloader.units.mathop.and_(v1, *vs) → _BinaryOpUnit
Overview:

Get the and binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

And operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import and_, keep
>>> u = and_(keep(), 3)
>>> u(23)  # 23 and 3
3
  • Multiple usage

>>> u = and_(keep(), 3, lambda x: x * 2)  # 23 and 3 and (23 * 2)
46
  • Suffix from usage

>>> u = keep() >> and_.from_(3)
>>> u(23)  # 3 and 23
23
  • Suffix by usage

>>> u = keep() >> and_.by(3)
>>> u(23)  # 23 and 3
3

or_

argsloader.units.mathop.or_(v1, *vs) → _BinaryOpUnit
Overview:

Get the or binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Or operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import or_, keep
>>> u = or_(keep(), 3)
>>> u(23)  # 23 or 3
23
  • Multiple usage

>>> u = or_(keep(), 3, lambda x: x * 2)  # 23 or 3 or (23 * 2)
23
  • Suffix from usage

>>> u = keep() >> or_.from_(3)
>>> u(23)  # 3 or 23
3
  • Suffix by usage

>>> u = keep() >> or_.by(3)
>>> u(23)  # 23 or 3
23

band

argsloader.units.mathop.band(v1, *vs) → _BinaryOpUnit
Overview:

Get the band binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Band operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import band, keep
>>> u = band(keep(), 3)
>>> u(23)  # 23 & 3
3
  • Multiple usage

>>> u = band(keep(), 3, lambda x: x * 2)  # 23 & 3 & (23 * 2)
2
  • Suffix from usage

>>> u = keep() >> band.from_(3)
>>> u(23)  # 3 & 23
3
  • Suffix by usage

>>> u = keep() >> band.by(3)
>>> u(23)  # 23 & 3
3

bor

argsloader.units.mathop.bor(v1, *vs) → _BinaryOpUnit
Overview:

Get the bor binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Bor operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import bor, keep
>>> u = bor(keep(), 3)
>>> u(23)  # 23 | 3
23
  • Multiple usage

>>> u = bor(keep(), 3, lambda x: x * 2)  # 23 | 3 | (23 * 2)
63
  • Suffix from usage

>>> u = keep() >> bor.from_(3)
>>> u(23)  # 3 | 23
23
  • Suffix by usage

>>> u = keep() >> bor.by(3)
>>> u(23)  # 23 | 3
23

bxor

argsloader.units.mathop.bxor(v1, *vs) → _BinaryOpUnit
Overview:

Get the bxor binary operation unit.

Parameters
  • v1 – First unit.

  • vs – Other units, multiple units are supported.

Returns

Bxor operation unit.

Examples::
  • Simple usage

>>> from argsloader.units import bxor, keep
>>> u = bxor(keep(), 3)
>>> u(23)  # 23 ^ 3
20
  • Multiple usage

>>> u = bxor(keep(), 3, lambda x: x * 2)  # 23 ^ 3 ^ (23 * 2)
58
  • Suffix from usage

>>> u = keep() >> bxor.from_(3)
>>> u(23)  # 3 ^ 23
20
  • Suffix by usage

>>> u = keep() >> bxor.by(3)
>>> u(23)  # 23 ^ 3
20

eq

argsloader.units.mathop.eq(v1, v2) → _BinaryCheckUnit
Overview:

Get the eq binary comparison check unit.

If v1 == v2 is satisfied, the inputted value will be returned without any change, or ValueError will be raised.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Eq comparison unit.

Raises

ValueError – When comparison failed, ValueError will be raised.

Examples::
  • Simple comparison check

>>> from argsloader.units import eq, keep
>>> u = eq(keep(), 2)
>>> u(1)  # 1 == 2
ValueParseError: Expected v1 == v2, but 1 != 2 is found.
>>> u(2)  # 2 == 2
2
>>> u(3)  # 3 == 2
ValueParseError: Expected v1 == v2, but 3 != 2 is found.
  • Suffix check

>>> u = (lambda x: x * 2) >> eq.to_(2)
>>> u(0)  # (0 * 2) == 2
ValueParseError: Expected v1 == v2, but 0 != 2 is found.
>>> u(1)  # (1 * 2) == 2
2
>>> u(2)  # (2 * 2) == 2
ValueParseError: Expected v1 == v2, but 4 != 2 is found.

ne

argsloader.units.mathop.ne(v1, v2) → _BinaryCheckUnit
Overview:

Get the ne binary comparison check unit.

If v1 != v2 is satisfied, the inputted value will be returned without any change, or ValueError will be raised.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Ne comparison unit.

Raises

ValueError – When comparison failed, ValueError will be raised.

Examples::
  • Simple comparison check

>>> from argsloader.units import ne, keep
>>> u = ne(keep(), 2)
>>> u(1)  # 1 != 2
1
>>> u(2)  # 2 != 2
ValueParseError: Expected v1 != v2, but 2 == 2 is found.
>>> u(3)  # 3 != 2
3
  • Suffix check

>>> u = (lambda x: x * 2) >> ne.to_(2)
>>> u(0)  # (0 * 2) != 2
0
>>> u(1)  # (1 * 2) != 2
ValueParseError: Expected v1 != v2, but 2 == 2 is found.
>>> u(2)  # (2 * 2) != 2
4

ge

argsloader.units.mathop.ge(v1, v2) → _BinaryCheckUnit
Overview:

Get the ge binary comparison check unit.

If v1 >= v2 is satisfied, the inputted value will be returned without any change, or ValueError will be raised.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Ge comparison unit.

Raises

ValueError – When comparison failed, ValueError will be raised.

Examples::
  • Simple comparison check

>>> from argsloader.units import ge, keep
>>> u = ge(keep(), 2)
>>> u(1)  # 1 >= 2
ValueParseError: Expected v1 >= v2, but 1 < 2 is found.
>>> u(2)  # 2 >= 2
2
>>> u(3)  # 3 >= 2
3
  • Suffix check

>>> u = (lambda x: x * 2) >> ge.than(2)
>>> u(0)  # (0 * 2) >= 2
ValueParseError: Expected v1 >= v2, but 0 < 2 is found.
>>> u(1)  # (1 * 2) >= 2
2
>>> u(2)  # (2 * 2) >= 2
4

gt

argsloader.units.mathop.gt(v1, v2) → _BinaryCheckUnit
Overview:

Get the gt binary comparison check unit.

If v1 > v2 is satisfied, the inputted value will be returned without any change, or ValueError will be raised.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Gt comparison unit.

Raises

ValueError – When comparison failed, ValueError will be raised.

Examples::
  • Simple comparison check

>>> from argsloader.units import gt, keep
>>> u = gt(keep(), 2)
>>> u(1)  # 1 > 2
ValueParseError: Expected v1 > v2, but 1 <= 2 is found.
>>> u(2)  # 2 > 2
ValueParseError: Expected v1 > v2, but 2 <= 2 is found.
>>> u(3)  # 3 > 2
3
  • Suffix check

>>> u = (lambda x: x * 2) >> gt.than(2)
>>> u(0)  # (0 * 2) > 2
ValueParseError: Expected v1 > v2, but 0 <= 2 is found.
>>> u(1)  # (1 * 2) > 2
ValueParseError: Expected v1 > v2, but 2 <= 2 is found.
>>> u(2)  # (2 * 2) > 2
4

le

argsloader.units.mathop.le(v1, v2) → _BinaryCheckUnit
Overview:

Get the le binary comparison check unit.

If v1 <= v2 is satisfied, the inputted value will be returned without any change, or ValueError will be raised.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Le comparison unit.

Raises

ValueError – When comparison failed, ValueError will be raised.

Examples::
  • Simple comparison check

>>> from argsloader.units import le, keep
>>> u = le(keep(), 2)
>>> u(1)  # 1 <= 2
1
>>> u(2)  # 2 <= 2
2
>>> u(3)  # 3 <= 2
ValueParseError: Expected v1 <= v2, but 3 > 2 is found.
  • Suffix check

>>> u = (lambda x: x * 2) >> le.than(2)
>>> u(0)  # (0 * 2) <= 2
0
>>> u(1)  # (1 * 2) <= 2
2
>>> u(2)  # (2 * 2) <= 2
ValueParseError: Expected v1 <= v2, but 4 > 2 is found.

lt

argsloader.units.mathop.lt(v1, v2) → _BinaryCheckUnit
Overview:

Get the lt binary comparison check unit.

If v1 < v2 is satisfied, the inputted value will be returned without any change, or ValueError will be raised.

Parameters
  • v1 – First unit.

  • v2 – Second unit.

Returns

Lt comparison unit.

Raises

ValueError – When comparison failed, ValueError will be raised.

Examples::
  • Simple comparison check

>>> from argsloader.units import lt, keep
>>> u = lt(keep(), 2)
>>> u(1)  # 1 < 2
1
>>> u(2)  # 2 < 2
ValueParseError: Expected v1 < v2, but 2 >= 2 is found.
>>> u(3)  # 3 < 2
ValueParseError: Expected v1 < v2, but 3 >= 2 is found.
  • Suffix check

>>> u = (lambda x: x * 2) >> lt.than(2)
>>> u(0)  # (0 * 2) < 2
0
>>> u(1)  # (1 * 2) < 2
ValueParseError: Expected v1 < v2, but 2 >= 2 is found.
>>> u(2)  # (2 * 2) < 2
ValueParseError: Expected v1 < v2, but 4 >= 2 is found.