Skip to content

Commit

Permalink
Merge pull request #52 from giovannihenriksen/decimal-steps-fix
Browse files Browse the repository at this point in the history
Decimal steps fix
  • Loading branch information
giovannihenriksen committed Feb 21, 2021
2 parents 3f70cbb + 1d3dbf9 commit e2d6987
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GiovanniHenriksen: Graph tooltip now shows the day number

### Fixed
- GiovanniHenriksen: Usage of decimals in learning and lapse steps is now allowed
- GiovanniHenriksen: Fixed bug where the average number of cards was not correct if the number of days simulated was larger than the max number of data points

## [1.1] - 2021-01-30
Expand Down
2 changes: 1 addition & 1 deletion src/anki_simulator/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
Version information
"""

__version__ = "1.1"
__version__ = "1.1.1"
13 changes: 10 additions & 3 deletions src/anki_simulator/gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ def num_to_user(n: Union[int, float]):
return " ".join(map(num_to_user, l))


def isFloat(value):
try:
float(value)
return True
except ValueError:
return False

def stepsAreValid(steps: List[str]):
for step in steps:
if not step.isdecimal():
if not isFloat(step):
return False
if len(steps) == 0:
return False
Expand Down Expand Up @@ -471,13 +478,13 @@ def simulate(self):
self.dialog.learningStepsTextfield.setFocus()
return
learningSteps = [
int(i) for i in self.dialog.learningStepsTextfield.text().split()
float(i) for i in self.dialog.learningStepsTextfield.text().split()
]
if not stepsAreValid(self.dialog.lapseStepsTextfield.text().split()):
showInfo("Please correctly enter 'Lapse steps' (e.g. '30 1440')")
self.dialog.lapseStepsTextfield.setFocus()
return
lapseSteps = [int(i) for i in self.dialog.lapseStepsTextfield.text().split()]
lapseSteps = [float(i) for i in self.dialog.lapseStepsTextfield.text().split()]
graduatingInterval = int(self.dialog.graduatingIntervalSpinbox.value())
newLapseInterval = float(self.dialog.newLapseIntervalSpinbox.value()) / 100
maxInterval = int(self.dialog.maximumIntervalSpinbox.value())
Expand Down
8 changes: 4 additions & 4 deletions src/anki_simulator/review_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def __init__(
new_cards_per_day: int,
interval_modifier: int,
max_reviews_per_day: int,
learning_steps: List[int],
lapse_steps: List[int],
learning_steps: List[float],
lapse_steps: List[float],
graduating_interval: int,
new_lapse_interval: int,
max_interval: int,
Expand All @@ -74,8 +74,8 @@ def __init__(
self.newCardsPerDay: int = new_cards_per_day
self.intervalModifier: int = interval_modifier
self.maxReviewsPerDay: int = max_reviews_per_day
self.learningSteps: List[int] = learning_steps
self.lapseSteps: List[int] = lapse_steps
self.learningSteps: List[float] = learning_steps
self.lapseSteps: List[float] = lapse_steps
self.graduatingInterval: int = graduating_interval
self.newLapseInterval: int = new_lapse_interval
self.maxInterval: int = max_interval
Expand Down

0 comments on commit e2d6987

Please sign in to comment.