Skip to content

Commit

Permalink
fixes fmilthaler#74. The sum() method returns an instance of numpy.in…
Browse files Browse the repository at this point in the history
…t64 if the allocation only contains integers.

An instance of numpy.int64 is not recognized as instance of int, as they are two different classes.

This causes the error message since the total investment is not recognized as integer.

Courious: trying with allocations equal to 20^(200), the returned number is an instance of "int" instead of "numpy.int64".
  • Loading branch information
PietropaoloFrisoni committed Jul 6, 2023
1 parent dcca535 commit 7fb3446
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion finquant/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def totalinvestment(self):
def totalinvestment(self, val):
if val is not None:
# treat "None" as initialisation
if not isinstance(val, (float, int)):
if not isinstance(val, (float, int, np.int64)):
raise ValueError("Total investment must be a float or integer.")
elif val <= 0:
raise ValueError(
Expand Down

0 comments on commit 7fb3446

Please sign in to comment.