# core.Running

``` python
core.Running(
    params,
    ctx=static(),
    likelihood=static(),
    pass_=static(),
    index=static(),
    checked=False,
    done=(),
    *,
    _seed=_Seed.draw(),
)
```

One pass of a fit in progress.

Pure: `finish` returns the next step. `start()` on a fit builds the first one.

## Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| params | Params | The params the curvature is taken at. | *required* |
| ctx | FitContext | The fit’s context. Its likelihood is the unit one. | `static()` |
| likelihood | Likelihood | The real likelihood, for the data-fit term. | `static()` |
| pass\_ | Pass\[R\] | The current pass. | `static()` |
| index | int | The pass number, which seeds each batch’s generator with the fit’s seed. | `static()` |
| checked | bool | Whether to check each pass’s requirements against the capabilities and each batch. | `False` |
| done | tuple\[FitStat\[Any\], …\] | Statistics of the finished passes. | `()` |

## Methods

| Name | Description |
|----|----|
| [finish](#laplacekit.core.Running.finish) | End the pass and move to the next step. |
| [init](#laplacekit.core.Running.init) | The empty statistic of this pass. |
| [update](#laplacekit.core.Running.update) | Fold one batch into the statistic. |

### finish

``` python
core.Running.finish(stat, /)
```

End the pass and move to the next step.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| stat | FitStat\[Any\] | The pass’s statistic over all the data, after `all_reduce`. | *required* |

#### Returns

| Name | Type | Description |
|----|----|----|
|  | Running\[R\] \| Finished\[R\] | The next pass as a new `Running`, or `Finished` after the last pass. Either keeps `stat` with the statistics of the earlier passes. |

#### Raises

| Name | Type | Description |
|----|----|----|
|  | ValueError | The curvature’s `finalize` refuses `stat`, e.g. a zero total weight. |

### init

``` python
core.Running.init()
```

The empty statistic of this pass.

#### Returns

| Name | Type | Description |
|----|----|----|
|  | FitStat\[Any\] | The identity of `+`: the curvature’s `init`, no data-fit term and a zero count. |

#### Raises

| Name | Type | Description |
|----|----|----|
|  | CapabilityError | The likelihood lacks something the pass needs (checked always). With `checked`: the capabilities lack something the pass needs. |
|  | StructureError | The pass’s curvature refuses the params or layout. |
|  | ValueError | The pass’s curvature refuses its settings for these params (e.g. `LowRankGGN` with `rank + oversample` above the parameter count). |

### update

``` python
core.Running.update(stat, batch, /)
```

Fold one batch into the statistic.

A `HasTargetCheck` likelihood checks the batch’s targets first.

#### Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| stat | FitStat\[Any\] | The statistic so far. | *required* |
| batch | Batch | The next batch. Its generator comes from the fit’s seed, `index` and the examples seen in this pass before it. | *required* |

#### Returns

| Name | Type           | Description                  |
|------|----------------|------------------------------|
|      | FitStat\[Any\] | `stat` with the batch added. |

#### Raises

| Name | Type | Description |
|----|----|----|
|  | CapabilityError | With `checked`, the batch fails the pass’s requirements (`Requirements.check_batch`). With or without it, the curvature needs targets the batch lacks. |
|  | ValueError | The likelihood’s `check_targets` finds a bad target value. |
|  | StructureError | The likelihood’s `check_targets` finds badly shaped targets, or a `LateLikelihood` has an active mask, which `fit_stat` can’t apply. |
