prompt_id int64 0 941 | project stringclasses 24
values | module stringlengths 7 49 | class stringlengths 0 32 | method stringlengths 2 37 | focal_method_txt stringlengths 43 41.5k | focal_method_lines listlengths 2 2 | in_stack bool 2
classes | globals listlengths 0 16 | type_context stringlengths 79 41.9k | has_branch bool 2
classes | total_branches int64 0 3 |
|---|---|---|---|---|---|---|---|---|---|---|---|
345 | pypara | pypara.monetary | Money | as_boolean | @abstractmethod
def as_boolean(self) -> bool:
"""
Returns the logical representation of the money object.
In particular:
1. ``False`` if money is *undefined* **or** money quantity is ``zero``.
2. ``True`` otherwise.
"""
raise NotImplementedError | [
100,
109
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
346 | pypara | pypara.monetary | Money | as_float | @abstractmethod
def as_float(self) -> float:
"""
Returns the quantity as a ``float`` if *defined*, raises class:`MonetaryOperationException` otherwise.
"""
raise NotImplementedError | [
112,
116
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
347 | pypara | pypara.monetary | Money | as_integer | @abstractmethod
def as_integer(self) -> int:
"""
Returns the quantity as an ``int`` if *defined*, raises class:`MonetaryOperationException` otherwise.
"""
raise NotImplementedError | [
119,
123
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
348 | pypara | pypara.monetary | Money | abs | @abstractmethod
def abs(self) -> "Money":
"""
Returns the absolute money if *defined*, itself otherwise.
"""
raise NotImplementedError | [
126,
130
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
349 | pypara | pypara.monetary | Money | negative | @abstractmethod
def negative(self) -> "Money":
"""
Negates the quantity of the monetary value if *defined*, itself otherwise.
"""
raise NotImplementedError | [
133,
137
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
350 | pypara | pypara.monetary | Money | positive | @abstractmethod
def positive(self) -> "Money":
"""
Returns same monetary value if *defined*, itself otherwise.
"""
raise NotImplementedError | [
140,
144
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
351 | pypara | pypara.monetary | Money | round | @abstractmethod
def round(self, ndigits: int = 0) -> "Money":
"""
Rounds the quantity of the monetary value to ``ndigits`` by using ``HALF_EVEN`` method if *defined*, itself
otherwise.
"""
raise NotImplementedError | [
147,
152
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
352 | pypara | pypara.monetary | Money | add | @abstractmethod
def add(self, other: "Money") -> "Money":
"""
Performs monetary addition on the money object and the given ``other`` money object.
Note that::
1. Raises :class:`IncompatibleCurrencyError` if currencies do not match.
2. If any of the operands are undefine... | [
155,
165
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
353 | pypara | pypara.monetary | Money | scalar_add | @abstractmethod
def scalar_add(self, other: Numeric) -> "Money":
"""
Performs scalar addition on the quantity of the money.
Note that undefined money object is returned as is.
"""
raise NotImplementedError | [
168,
174
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
354 | pypara | pypara.monetary | Money | subtract | @abstractmethod
def subtract(self, other: "Money") -> "Money":
"""
Performs monetary subtraction on the money object and the given ``other`` money object.
Note that::
1. Raises :class:`IncompatibleCurrencyError` if currencies do not match.
2. If any of the operands are ... | [
177,
187
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
355 | pypara | pypara.monetary | Money | scalar_subtract | @abstractmethod
def scalar_subtract(self, other: Numeric) -> "Money":
"""
Performs scalar subtraction on the quantity of the money.
Note that undefined money object is returned as is.
"""
raise NotImplementedError | [
190,
196
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
356 | pypara | pypara.monetary | Money | multiply | @abstractmethod
def multiply(self, other: Numeric) -> "Money":
"""
Performs scalar multiplication.
Note that undefined money object is returned as is.
"""
raise NotImplementedError | [
199,
205
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
357 | pypara | pypara.monetary | Money | divide | @abstractmethod
def divide(self, other: Numeric) -> "Money":
"""
Performs ordinary division on the money object if *defined*, itself otherwise.
Note that division by zero yields an undefined money object.
"""
raise NotImplementedError | [
208,
214
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
358 | pypara | pypara.monetary | Money | floor_divide | @abstractmethod
def floor_divide(self, other: Numeric) -> "Money":
"""
Performs floor division on the money object if *defined*, itself otherwise.
Note that division by zero yields an undefined money object.
"""
raise NotImplementedError | [
217,
224
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
359 | pypara | pypara.monetary | Money | lt | @abstractmethod
def lt(self, other: "Money") -> bool:
"""
Applies "less than" comparison against ``other`` money.
Note that::
1. Undefined money objects are always less than ``other`` if ``other`` is not undefined, and
2. :class:`IncompatibleCurrencyError` is raised whe... | [
227,
237
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
360 | pypara | pypara.monetary | Money | lte | @abstractmethod
def lte(self, other: "Money") -> bool:
"""
Applies "less than or equal to" comparison against ``other`` money.
Note that::
1. Undefined money objects are always less than or equal to ``other``, and
2. :class:`IncompatibleCurrencyError` is raised when com... | [
240,
250
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
361 | pypara | pypara.monetary | Money | gt | @abstractmethod
def gt(self, other: "Money") -> bool:
"""
Applies "greater than" comparison against ``other`` money.
Note that::
1. Undefined money objects are never greater than ``other``,
2. Defined money objects are always greater than ``other`` if other is undefined... | [
253,
264
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
362 | pypara | pypara.monetary | Money | gte | @abstractmethod
def gte(self, other: "Money") -> bool:
"""
Applies "greater than or equal to" comparison against ``other`` money.
Note that::
1. Undefined money objects are never greater than or equal to ``other`` if ``other`` is defined,
2. Undefined money objects are ... | [
267,
278
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
363 | pypara | pypara.monetary | Money | with_ccy | @abstractmethod
def with_ccy(self, ccy: Currency) -> "Money":
"""
Creates a new money object with the given currency if money is *defined*, returns itself otherwise.
"""
pass | [
281,
285
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
364 | pypara | pypara.monetary | Money | with_qty | @abstractmethod
def with_qty(self, qty: Decimal) -> "Money":
"""
Creates a new money object with the given quantity if money is *defined*, returns itself otherwise.
"""
pass | [
288,
292
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
365 | pypara | pypara.monetary | Money | with_dov | @abstractmethod
def with_dov(self, dov: Date) -> "Money":
"""
Creates a new money object with the given value date if money is *defined*, returns itself otherwise.
"""
pass | [
295,
299
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
366 | pypara | pypara.monetary | Money | convert | @abstractmethod
def convert(self, to: Currency, asof: Optional[Date] = None, strict: bool = False) -> "Money":
"""
Converts the monetary value from one currency to another.
Raises :class:`FXRateLookupError` if no foreign exchange rate can be found for conversion.
Note that we w... | [
302,
310
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
367 | pypara | pypara.monetary | Money | __bool__ | @abstractmethod
def __bool__(self) -> bool:
pass | [
330,
331
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
368 | pypara | pypara.monetary | Money | __eq__ | @abstractmethod
def __eq__(self, other: Any) -> bool:
pass | [
334,
335
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
369 | pypara | pypara.monetary | Money | __abs__ | @abstractmethod
def __abs__(self) -> "Money":
pass | [
338,
339
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
370 | pypara | pypara.monetary | Money | __float__ | @abstractmethod
def __float__(self) -> float:
pass | [
342,
343
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
371 | pypara | pypara.monetary | Money | __int__ | @abstractmethod
def __int__(self) -> int:
pass | [
346,
347
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
372 | pypara | pypara.monetary | Money | __neg__ | @abstractmethod
def __neg__(self) -> "Money":
pass | [
365,
366
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
373 | pypara | pypara.monetary | Money | __pos__ | @abstractmethod
def __pos__(self) -> "Money":
pass | [
369,
370
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
374 | pypara | pypara.monetary | Money | __add__ | @abstractmethod
def __add__(self, other: "Money") -> "Money":
pass | [
373,
374
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
375 | pypara | pypara.monetary | Money | __sub__ | @abstractmethod
def __sub__(self, other: "Money") -> "Money":
pass | [
377,
378
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
376 | pypara | pypara.monetary | Money | __mul__ | @abstractmethod
def __mul__(self, other: Numeric) -> "Money":
pass | [
381,
382
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
377 | pypara | pypara.monetary | Money | __truediv__ | @abstractmethod
def __truediv__(self, other: Numeric) -> "Money":
pass | [
385,
386
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
378 | pypara | pypara.monetary | Money | __floordiv__ | @abstractmethod
def __floordiv__(self, other: Numeric) -> "Money":
pass | [
389,
390
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
379 | pypara | pypara.monetary | Money | __lt__ | @abstractmethod
def __lt__(self, other: "Money") -> bool:
pass | [
393,
394
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
380 | pypara | pypara.monetary | Money | __le__ | @abstractmethod
def __le__(self, other: "Money") -> bool:
pass | [
397,
398
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
381 | pypara | pypara.monetary | Money | __gt__ | @abstractmethod
def __gt__(self, other: "Money") -> bool:
pass | [
401,
402
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
382 | pypara | pypara.monetary | Money | __ge__ | @abstractmethod
def __ge__(self, other: "Money") -> bool:
pass | [
405,
406
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
383 | pypara | pypara.monetary | SomeMoney | round | def round(self, ndigits: int = 0) -> "Money":
c, q, d = self
dec = c.decimals
return SomeMoney(c, q.__round__(ndigits if ndigits < dec else dec), d) | [
444,
447
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
384 | pypara | pypara.monetary | SomeMoney | with_dov | def with_dov(self, dov: Date) -> "Money":
return SomeMoney(self[0], self[1], dov) | [
551,
552
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
385 | pypara | pypara.monetary | SomeMoney | convert | def convert(self, to: Currency, asof: Optional[Date] = None, strict: bool = False) -> "Money":
## Get slots:
ccy, qty, dov = self
## Get date of conversion:
asof = asof or dov
## Attempt to get the FX rate:
try:
rate = FXRateService.default.query(ccy, to... | [
554,
581
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | true | 2 |
386 | pypara | pypara.monetary | Price | is_equal | @abstractmethod
def is_equal(self, other: Any) -> bool:
"""
Checks the equality of two price objects.
In particular:
1. ``True`` if ``other`` is a price object **and** all slots are same.
2. ``False`` otherwise.
"""
raise NotImplementedError | [
771,
780
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
387 | pypara | pypara.monetary | Price | as_boolean | @abstractmethod
def as_boolean(self) -> bool:
"""
Returns the logical representation of the price object.
In particular:
1. ``False`` if price is *undefined* **or** price quantity is ``zero``.
2. ``True`` otherwise.
"""
raise NotImplementedError | [
783,
792
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
388 | pypara | pypara.monetary | Price | as_float | @abstractmethod
def as_float(self) -> float:
"""
Returns the quantity as a ``float`` if *defined*, raises class:`MonetaryOperationException` otherwise.
"""
raise NotImplementedError | [
795,
799
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
389 | pypara | pypara.monetary | Price | as_integer | @abstractmethod
def as_integer(self) -> int:
"""
Returns the quantity as an ``int`` if *defined*, raises class:`MonetaryOperationException` otherwise.
"""
raise NotImplementedError | [
802,
806
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
390 | pypara | pypara.monetary | Price | abs | @abstractmethod
def abs(self) -> "Price":
"""
Returns the absolute price if *defined*, itself otherwise.
"""
raise NotImplementedError | [
809,
813
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
391 | pypara | pypara.monetary | Price | negative | @abstractmethod
def negative(self) -> "Price":
"""
Negates the quantity of the monetary value if *defined*, itself otherwise.
"""
raise NotImplementedError | [
816,
820
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
392 | pypara | pypara.monetary | Price | positive | @abstractmethod
def positive(self) -> "Price":
"""
Returns same monetary value if *defined*, itself otherwise.
"""
raise NotImplementedError | [
823,
827
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
393 | pypara | pypara.monetary | Price | round | @abstractmethod
def round(self, ndigits: int = 0) -> "Price":
"""
Rounds the quantity of the monetary value to ``ndigits`` by using ``HALF_EVEN`` method if *defined*, itself
otherwise.
"""
raise NotImplementedError | [
830,
835
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
394 | pypara | pypara.monetary | Price | add | @abstractmethod
def add(self, other: "Price") -> "Price":
"""
Performs monetary addition on the price object and the given ``other`` price object.
Note that::
1. Raises :class:`IncompatibleCurrencyError` if currencies do not match.
2. If any of the operands are undefine... | [
838,
848
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
395 | pypara | pypara.monetary | Price | scalar_add | @abstractmethod
def scalar_add(self, other: Numeric) -> "Price":
"""
Performs scalar addition on the quantity of the price.
Note that undefined price object is returned as is.
"""
raise NotImplementedError | [
851,
857
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
396 | pypara | pypara.monetary | Price | subtract | @abstractmethod
def subtract(self, other: "Price") -> "Price":
"""
Performs monetary subtraction on the price object and the given ``other`` price object.
Note that::
1. Raises :class:`IncompatibleCurrencyError` if currencies do not match.
2. If any of the operands are ... | [
860,
870
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
397 | pypara | pypara.monetary | Price | scalar_subtract | @abstractmethod
def scalar_subtract(self, other: Numeric) -> "Price":
"""
Performs scalar subtraction on the quantity of the price.
Note that undefined price object is returned as is.
"""
raise NotImplementedError | [
873,
879
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
398 | pypara | pypara.monetary | Price | multiply | @abstractmethod
def multiply(self, other: Numeric) -> "Price":
"""
Performs scalar multiplication.
Note that undefined price object is returned as is.
"""
raise NotImplementedError | [
882,
888
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
399 | pypara | pypara.monetary | Price | times | @abstractmethod
def times(self, other: Numeric) -> "Money":
"""
Performs monetary multiplication operation.
Note that undefined price object is returned as is.
"""
raise NotImplementedError | [
891,
897
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
400 | pypara | pypara.monetary | Price | divide | @abstractmethod
def divide(self, other: Numeric) -> "Price":
"""
Performs ordinary division on the price object if *defined*, itself otherwise.
Note that division by zero yields an undefined price object.
"""
raise NotImplementedError | [
900,
906
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
401 | pypara | pypara.monetary | Price | floor_divide | @abstractmethod
def floor_divide(self, other: Numeric) -> "Price":
"""
Performs floor division on the price object if *defined*, itself otherwise.
Note that division by zero yields an undefined price object.
"""
raise NotImplementedError | [
909,
916
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
402 | pypara | pypara.monetary | Price | lt | @abstractmethod
def lt(self, other: "Price") -> bool:
"""
Applies "less than" comparison against ``other`` price.
Note that::
1. Undefined price objects are always less than ``other`` if ``other`` is not undefined, and
2. :class:`IncompatibleCurrencyError` is raised whe... | [
919,
929
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
403 | pypara | pypara.monetary | Price | lte | @abstractmethod
def lte(self, other: "Price") -> bool:
"""
Applies "less than or equal to" comparison against ``other`` price.
Note that::
1. Undefined price objects are always less than or equal to ``other``, and
2. :class:`IncompatibleCurrencyError` is raised when com... | [
932,
942
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
404 | pypara | pypara.monetary | Price | gt | @abstractmethod
def gt(self, other: "Price") -> bool:
"""
Applies "greater than" comparison against ``other`` price.
Note that::
1. Undefined price objects are never greater than ``other``,
2. Defined price objects are always greater than ``other`` if other is undefined... | [
945,
956
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
405 | pypara | pypara.monetary | Price | gte | @abstractmethod
def gte(self, other: "Price") -> bool:
"""
Applies "greater than or equal to" comparison against ``other`` price.
Note that::
1. Undefined price objects are never greater than or equal to ``other`` if ``other`` is defined,
2. Undefined price objects are ... | [
959,
970
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
406 | pypara | pypara.monetary | Price | with_ccy | @abstractmethod
def with_ccy(self, ccy: Currency) -> "Price":
"""
Creates a new price object with the given currency if price is *defined*, returns itself otherwise.
"""
pass | [
973,
977
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
407 | pypara | pypara.monetary | Price | with_qty | @abstractmethod
def with_qty(self, qty: Decimal) -> "Price":
"""
Creates a new price object with the given quantity if price is *defined*, returns itself otherwise.
"""
pass | [
980,
984
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
408 | pypara | pypara.monetary | Price | with_dov | @abstractmethod
def with_dov(self, dov: Date) -> "Price":
"""
Creates a new price object with the given value date if price is *defined*, returns itself otherwise.
"""
pass | [
987,
991
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
409 | pypara | pypara.monetary | Price | convert | @abstractmethod
def convert(self, to: Currency, asof: Optional[Date] = None, strict: bool = False) -> "Price":
"""
Converts the monetary value from one currency to another.
Raises :class:`FXRateLookupError` if no foreign exchange rate can be found for conversion.
Note that we w... | [
994,
1002
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
410 | pypara | pypara.monetary | Price | __bool__ | @abstractmethod
def __bool__(self) -> bool:
pass | [
1022,
1023
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
411 | pypara | pypara.monetary | Price | __eq__ | @abstractmethod
def __eq__(self, other: Any) -> bool:
pass | [
1026,
1027
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
412 | pypara | pypara.monetary | Price | __abs__ | @abstractmethod
def __abs__(self) -> "Price":
pass | [
1030,
1031
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
413 | pypara | pypara.monetary | Price | __float__ | @abstractmethod
def __float__(self) -> float:
pass | [
1034,
1035
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
414 | pypara | pypara.monetary | Price | __int__ | @abstractmethod
def __int__(self) -> int:
pass | [
1038,
1039
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
415 | pypara | pypara.monetary | Price | __neg__ | @abstractmethod
def __neg__(self) -> "Price":
pass | [
1057,
1058
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
416 | pypara | pypara.monetary | Price | __pos__ | @abstractmethod
def __pos__(self) -> "Price":
pass | [
1061,
1062
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
417 | pypara | pypara.monetary | Price | __add__ | @abstractmethod
def __add__(self, other: "Price") -> "Price":
pass | [
1065,
1066
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
418 | pypara | pypara.monetary | Price | __sub__ | @abstractmethod
def __sub__(self, other: "Price") -> "Price":
pass | [
1069,
1070
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
419 | pypara | pypara.monetary | Price | __mul__ | @abstractmethod
def __mul__(self, other: Numeric) -> "Price":
pass | [
1073,
1074
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
420 | pypara | pypara.monetary | Price | __truediv__ | @abstractmethod
def __truediv__(self, other: Numeric) -> "Price":
pass | [
1077,
1078
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
421 | pypara | pypara.monetary | Price | __floordiv__ | @abstractmethod
def __floordiv__(self, other: Numeric) -> "Price":
pass | [
1081,
1082
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
422 | pypara | pypara.monetary | Price | __lt__ | @abstractmethod
def __lt__(self, other: "Price") -> bool:
pass | [
1085,
1086
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
423 | pypara | pypara.monetary | Price | __le__ | @abstractmethod
def __le__(self, other: "Price") -> bool:
pass | [
1089,
1090
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
424 | pypara | pypara.monetary | Price | __gt__ | @abstractmethod
def __gt__(self, other: "Price") -> bool:
pass | [
1093,
1094
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
425 | pypara | pypara.monetary | Price | __ge__ | @abstractmethod
def __ge__(self, other: "Price") -> bool:
pass | [
1097,
1098
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
426 | pypara | pypara.monetary | SomePrice | with_dov | def with_dov(self, dov: Date) -> "Price":
return SomePrice(self[0], self[1], dov) | [
1245,
1246
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
427 | pypara | pypara.monetary | SomePrice | convert | def convert(self, to: Currency, asof: Optional[Date] = None, strict: bool = False) -> "Price":
## Get slots:
ccy, qty, dov = self
## Get date of conversion:
asof = asof or dov
## Attempt to get the FX rate:
try:
rate = FXRateService.default.query(ccy, to... | [
1248,
1275
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | true | 2 |
428 | pypara | pypara.monetary | NonePrice | with_dov | def with_dov(self, dov: Date) -> "Price":
return self | [
1389,
1390
] | false | [
"__all__",
"Money",
"NA",
"Price"
] | from abc import abstractmethod
from decimal import Decimal, DivisionByZero, InvalidOperation
from typing import Any, NamedTuple, Optional, Union, overload
from .commons.errors import ProgrammingError
from .commons.numbers import Numeric
from .commons.zeitgeist import Date
from .currencies import Currency
from .exchange... | false | 0 |
429 | pysnooper | pysnooper.pycompat | timedelta_format | def timedelta_format(timedelta):
time = (datetime_module.datetime.min + timedelta).time()
return time_isoformat(time, timespec='microseconds') | [
85,
87
] | false | [
"PY3",
"PY2"
] | import abc
import os
import inspect
import sys
import datetime as datetime_module
PY3 = (sys.version_info[0] == 3)
PY2 = not PY3
def timedelta_format(timedelta):
time = (datetime_module.datetime.min + timedelta).time()
return time_isoformat(time, timespec='microseconds') | false | 0 | |
430 | pysnooper | pysnooper.pycompat | timedelta_parse | def timedelta_parse(s):
hours, minutes, seconds, microseconds = map(
int,
s.replace('.', ':').split(':')
)
return datetime_module.timedelta(hours=hours, minutes=minutes,
seconds=seconds,
microseconds=microseconds) | [
89,
94
] | false | [
"PY3",
"PY2"
] | import abc
import os
import inspect
import sys
import datetime as datetime_module
PY3 = (sys.version_info[0] == 3)
PY2 = not PY3
def timedelta_parse(s):
hours, minutes, seconds, microseconds = map(
int,
s.replace('.', ':').split(':')
)
return datetime_module.timedelta(hours=hours, minutes=... | false | 0 | |
431 | pysnooper | pysnooper.tracer | get_local_reprs | def get_local_reprs(frame, watch=(), custom_repr=(), max_length=None, normalize=False):
code = frame.f_code
vars_order = (code.co_varnames + code.co_cellvars + code.co_freevars +
tuple(frame.f_locals.keys()))
result_items = [(key, utils.get_shortish_repr(value, custom_repr,
... | [
24,
37
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 | |
432 | pysnooper | pysnooper.tracer | get_path_and_source_from_frame | def get_path_and_source_from_frame(frame):
globs = frame.f_globals or {}
module_name = globs.get('__name__')
file_name = frame.f_code.co_filename
cache_key = (module_name, file_name)
try:
return source_and_path_cache[cache_key]
except KeyError:
pass
loader = globs.get('__load... | [
48,
107
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 | |
433 | pysnooper | pysnooper.tracer | get_write_function | def get_write_function(output, overwrite):
is_path = isinstance(output, (pycompat.PathLike, str))
if overwrite and not is_path:
raise Exception('`overwrite=True` can only be used when writing '
'content to file.')
if output is None:
def write(s):
stderr = ... | [
110,
132
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 | |
434 | pysnooper | pysnooper.tracer | FileWriter | write | def write(self, s):
with open(self.path, 'w' if self.overwrite else 'a',
encoding='utf-8') as output_file:
output_file.write(s)
self.overwrite = False | [
140,
144
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | false | 0 |
435 | pysnooper | pysnooper.tracer | Tracer | __init__ | def __init__(self, output=None, watch=(), watch_explode=(), depth=1,
prefix='', overwrite=False, thread_info=False, custom_repr=(),
max_variable_length=100, normalize=False, relative_time=False):
self._write = get_write_function(output, overwrite)
self.watch = [
... | [
205,
234
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 |
436 | pysnooper | pysnooper.tracer | Tracer | __call__ | def __call__(self, function_or_class):
if DISABLED:
return function_or_class
if inspect.isclass(function_or_class):
return self._wrap_class(function_or_class)
else:
return self._wrap_function(function_or_class) | [
236,
243
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 |
437 | pysnooper | pysnooper.tracer | Tracer | __enter__ | def __enter__(self):
if DISABLED:
return
thread_global.__dict__.setdefault('depth', -1)
calling_frame = inspect.currentframe().f_back
if not self._is_internal_frame(calling_frame):
calling_frame.f_trace = self.trace
self.target_frames.add(calling_f... | [
292,
306
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 |
438 | pysnooper | pysnooper.tracer | Tracer | __exit__ | def __exit__(self, exc_type, exc_value, exc_traceback):
if DISABLED:
return
stack = self.thread_local.original_trace_functions
sys.settrace(stack.pop())
calling_frame = inspect.currentframe().f_back
self.target_frames.discard(calling_frame)
self.frame_to_l... | [
308,
323
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 |
439 | pysnooper | pysnooper.tracer | Tracer | trace | def trace(self, frame, event, arg):
### Checking whether we should trace this line: #######################
# #
# We should trace this line either if it's in the decorated function,
# or the user asked to go a few l... | [
338,
497
] | false | [
"ipython_filename_pattern",
"source_and_path_cache",
"thread_global",
"DISABLED"
] | import functools
import inspect
import opcode
import os
import sys
import re
import collections
import datetime as datetime_module
import itertools
import threading
import traceback
from .variables import CommonVariable, Exploding, BaseVariable
from . import utils, pycompat
ipython_filename_pattern = re.compile('^<ipy... | true | 2 |
440 | pysnooper | pysnooper.utils | shitcode | def shitcode(s):
return ''.join(
(c if (0 < ord(c) < 256) else '?') for c in s
) | [
43,
44
] | false | [
"file_reading_errors",
"DEFAULT_REPR_RE"
] | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
file_reading_errors = (
IOError,
OSError,
ValueError # IronPython weirdness.
)
DEFAULT_REPR_RE = re.compile(r' at 0x[a-f0-9A-F]{4,}')
def shitcode(s):
return ''.join(
(c if (0 < ord(c) < 256) else '?') for... | false | 0 | |
441 | pysnooper | pysnooper.utils | get_repr_function | def get_repr_function(item, custom_repr):
for condition, action in custom_repr:
if isinstance(condition, type):
condition = lambda x, y=condition: isinstance(x, y)
if condition(item):
return action
return repr | [
49,
55
] | false | [
"file_reading_errors",
"DEFAULT_REPR_RE"
] | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
file_reading_errors = (
IOError,
OSError,
ValueError # IronPython weirdness.
)
DEFAULT_REPR_RE = re.compile(r' at 0x[a-f0-9A-F]{4,}')
def get_repr_function(item, custom_repr):
for condition, action in custom_repr:... | true | 2 | |
442 | pysnooper | pysnooper.utils | get_shortish_repr | def get_shortish_repr(item, custom_repr=(), max_length=None, normalize=False):
repr_function = get_repr_function(item, custom_repr)
try:
r = repr_function(item)
except Exception:
r = 'REPR FAILED'
r = r.replace('\r', '').replace('\n', '')
if normalize:
r = normalize_repr(r)
... | [
66,
77
] | false | [
"file_reading_errors",
"DEFAULT_REPR_RE"
] | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
file_reading_errors = (
IOError,
OSError,
ValueError # IronPython weirdness.
)
DEFAULT_REPR_RE = re.compile(r' at 0x[a-f0-9A-F]{4,}')
def get_shortish_repr(item, custom_repr=(), max_length=None, normalize=False):
... | true | 2 | |
443 | pysnooper | pysnooper.utils | truncate | def truncate(string, max_length):
if (max_length is None) or (len(string) <= max_length):
return string
else:
left = (max_length - 3) // 2
right = max_length - 3 - left
return u'{}...{}'.format(string[:left], string[-right:]) | [
80,
86
] | false | [
"file_reading_errors",
"DEFAULT_REPR_RE"
] | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
file_reading_errors = (
IOError,
OSError,
ValueError # IronPython weirdness.
)
DEFAULT_REPR_RE = re.compile(r' at 0x[a-f0-9A-F]{4,}')
def truncate(string, max_length):
if (max_length is None) or (len(string) <= ma... | true | 2 | |
444 | pysnooper | pysnooper.utils | WritableStream | write | @abc.abstractmethod
def write(self, s):
pass | [
24,
25
] | false | [
"file_reading_errors",
"DEFAULT_REPR_RE"
] | import abc
import re
import sys
from .pycompat import ABC, string_types, collections_abc
file_reading_errors = (
IOError,
OSError,
ValueError # IronPython weirdness.
)
DEFAULT_REPR_RE = re.compile(r' at 0x[a-f0-9A-F]{4,}')
class WritableStream(ABC):
@abc.abstractmethod
def write(self, s):
... | false | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.