Skip to content

Add after method for drop(n).next(); easier for non-Scala folks - #3

Merged
benikm91 merged 1 commit into
dimwit-dev:mainfrom
benikm91:after-trajectory
Sep 7, 2026
Merged

Add after method for drop(n).next(); easier for non-Scala folks#3
benikm91 merged 1 commit into
dimwit-dev:mainfrom
benikm91:after-trajectory

Conversation

@benikm91

@benikm91 benikm91 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

It removes the existing LazyList.tapEvery extension used by tests (breaking compilation) and the top-level README example no longer compiles without importing deepwit.training.after.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces an after(n) helper for training trajectories to replace the more idiomatic-but-less-obvious drop(n).next() pattern, and updates documentation/examples to use the new helper.

Changes:

  • Add Iterator.after(n) extension method in deepwit.training.
  • Update README/mdocs and multiple examples to use .after(...) instead of .drop(...).next().
  • Update imports in examples/mdocs to bring the after extension into scope.
File summaries
File Description
README.md Switches documentation snippet to .after(numIterations) (currently missing the required import).
mdocs/README.md Adds import deepwit.training.after and updates the compiled snippet to use .after(...).
examples/src/main/scala/deepwit/examples/variationalAutoencoder/VariationalAutoencoderTrain.scala Imports after and replaces .drop(...).next() with .after(...).
examples/src/main/scala/deepwit/examples/thinning/MoonsMLPTrain.scala Imports after and replaces .drop(...).next() with .after(...).
examples/src/main/scala/deepwit/examples/regression/Regression.scala Imports after and replaces .drop(...).next() with .after(...).
examples/src/main/scala/deepwit/examples/neuralImage/NeuralImageTrain.scala Imports after and replaces .drop(...).next() with .after(...).
examples/src/main/scala/deepwit/examples/mnistClassification/MNistCNNTrain.scala Imports after and replaces .drop(...).next() with .after(...).
examples/src/main/scala/deepwit/examples/gpt/GPTTrain.scala Imports after and replaces .drop(...).next() with .after(...).
examples/src/main/scala/deepwit/examples/autoencoder/AutoEncoderTrain.scala Imports after and replaces .drop(...).next() with .after(...).
core/src/main/scala/deepwit/training/package.scala Adds Iterator.after(n) but also removes LazyList.tapEvery (breaking existing tests/usages).
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/src/main/scala/deepwit/training/package.scala Outdated
Comment thread core/src/main/scala/deepwit/training/package.scala Outdated
Comment thread README.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

It includes an unadvertised breaking API removal (LazyList.tapEvery) and introduces Iterator.after without corresponding unit tests/docs being consistently copy-pasteable.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

README.md:117

  • This README snippet now uses trainTrajectory.after(...), which requires importing the DeepWit extension method; unlike drop(n).next() it won’t compile for readers as-is. Consider adding the needed import (or a short note) to keep the snippet copy/pasteable.
```scala
val finalState = trainTrajectory.after(numIterations)

core/src/main/scala/deepwit/training/package.scala:16

  • This change removes the LazyList.tapEvery extension (and its tests) from deepwit.training, which is a breaking public API change beyond the PR’s stated goal of adding after. If LazyList support is still intended for library consumers, consider restoring it (or deprecating it first and documenting the removal).
  /** The state after n iterations: Advances the iterator n steps and returns the resulting element */
  def after(n: Int): T =
    require(n >= 0, s"A number of steps must not be negative, but was $n.")
    it.drop(n).next()
  • Files reviewed: 11/11 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread core/src/test/scala/deepwit/training/TapEverySuite.scala

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The README snippet now depends on importing the after extension (making it non-copy/paste-compilable as shown) and the PR also includes an uncalled-out breaking API removal (LazyList.tapEvery).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

README.md:117

  • The README snippet now uses trainTrajectory.after(numIterations), but after is an extension method that requires an import (import deepwit.training.after or import deepwit.training.*). As written, the snippet won’t compile when copied on its own, whereas the previous .drop(...).next() did.
val finalState = trainTrajectory.after(numIterations)

core/src/main/scala/deepwit/training/package.scala:16

  • This change also removes the LazyList.tapEvery extension from deepwit.training, which is a source-compatible breaking API change for downstream code (even if it’s unused within this repo). If this wasn’t intentional, consider keeping it (possibly deprecated) rather than deleting it outright.
  /** The state after n iterations: Advances the iterator n steps and returns the resulting element */
  def after(n: Int): T =
    require(n >= 0, s"A number of steps must not be negative, but was $n.")
    it.drop(n).next()
  • Files reviewed: 11/11 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread core/src/main/scala/deepwit/training/package.scala
Comment thread core/src/main/scala/deepwit/training/package.scala
@benikm91
benikm91 merged commit ed40437 into dimwit-dev:main Sep 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants