---
file_format: mystnb
kernelspec:
  name: python3
  display_name: Python 3
  language: python
---

# Migrating from v0.2 to v0.3

v0.3 is mostly additive. The one change that needs action is that
`pcf.walk_local_flow` is deprecated (from v0.3.1; removed in v0.4) in favour of
`pcf.order` with a `LocalFlowOrderer`. Everything else below is opt-in or a dependency floor.

```{note}
Moving on to v0.4? Its `pcf.order(positions, velocities)` no longer runs the walk by
default — see [Migrating from v0.3 to v0.4](v0.3-to-v0.4). The examples on this
page name their orderer explicitly, so they behave the same in both.
```

## `walk_local_flow` is deprecated (v0.3.1)

In v0.2, `pcf.order(positions, velocities, orderer)` required the orderer. From
v0.3.1 the orderer is optional and defaults to
{class}`~phasecurvefit.orderers.LocalFlowOrderer`, so `pcf.order(positions,
velocities)` ran the same walk as `walk_local_flow(positions, velocities)`. The
function itself still works — unchanged signature and `WalkLocalFlowResult` return —
but calling it emits a `DeprecationWarning`.

<!-- skip: next -->

```python
# Before (deprecated; warns):
result = pcf.walk_local_flow(pos, vel, start_idx=0, metric_scale=1.0)
```

```{code-cell} python
import jax.numpy as jnp
import phasecurvefit as pcf

pos = {"x": jnp.array([0.0, 1.0, 2.0, 3.0, 4.0])}
vel = {"x": jnp.ones(5)}

# After: the same walk, named explicitly (works in v0.3.1 and later):
result = pcf.order(
    pos, vel, pcf.orderers.LocalFlowOrderer(start_idx=0, metric_scale=1.0)
)
assert result.ordering.shape == (5,)
```

`start_idx`, `metric_scale`, `max_dist`, `direction`, `config`, and the other walk
knobs move from `walk_local_flow(...)` keyword arguments onto
`LocalFlowOrderer(...)`; a `usys` argument for Quantity inputs moves to
`order(..., metadata=pcf.StateMetadata(usys=...))`. `combine_results`, `order_w`,
the metrics, the query strategies and `WalkLocalFlowResult` are unchanged.

## New in v0.3.0

- **Outlier rejection for the MST.** {class}`~phasecurvefit.orderers.MSTOrderer`
  gains `edge_clip_sigma` (and `edge_clip_max_iters`): robust sigma-clipping of the
  backbone's edge lengths. Interlopers the MST threads in along one long edge are
  left unvisited (`indices == -1`). It is off by default.

  ```python
  import jax.numpy as jnp
  import phasecurvefit as pcf

  xs = jnp.concatenate([jnp.linspace(0.0, 9.0, 40), jnp.array([30.0])])
  ys = jnp.concatenate([jnp.zeros(40), jnp.array([30.0])])
  pos = {"x": xs, "y": ys}
  vel = {"x": jnp.ones(41), "y": jnp.zeros(41)}

  clipper = pcf.orderers.MSTOrderer(k=10, jump_cap=50.0, edge_clip_sigma=3.0)
  assert int(pcf.order(pos, vel, clipper).n_skipped) == 1
  ```

- **Mixture-model membership** for outlier rejection in the autoencoder, after
  Hogg, Bovy & Lang (2010): new `pcf.nn` names `MixtureMembershipConfig`,
  `WidthNet`, `posterior_membership`, `membership_responsibility`,
  `mixture_membership_loss`, `membership_rampup`, `sigma_ceiling` and
  `uniform_background_density`. It is opt-in; see the
  [Outlier rejection guide](../../how-to/outliers).

## Dependency floors

v0.3 moved the autoencoder's training internals onto `jaxmore.nn`, and raised two
minimum versions: `jaxmore>=0.4.0` (was `>=0.2.0`) and, by v0.3.2, `quax>=0.4`
(was `>=0.2.1`). If you pin either, relax the pin.

## Fixed

- `KDTree` neighbour queries no longer drop points relative to `BruteForce`
  (v0.3.1).

## Compatibility summary

| Symbol                                                  | Status                                                      |
| ------------------------------------------------------- | ----------------------------------------------------------- |
| `pcf.order(pos, vel, orderer)`                          | Unchanged; the orderer became optional in v0.3.1            |
| `pcf.walk_local_flow`                                   | **Deprecated** (warns); **removed in v0.4**. Use `order` with `LocalFlowOrderer` |
| `pcf.combine_results`, `pcf.order_w`                    | Unchanged                                                   |
| `pcf.WalkLocalFlowResult`                               | Unchanged; subclasses `OrderingResult`                      |
| `pcf.WalkConfig`, `pcf.metrics`, `pcf.strats`           | Unchanged                                                   |
| `pcf.nn`                                                | Additive: membership names; `jaxmore>=0.4.0`                |
| `pcf.orderers.MSTOrderer`                               | Additive: `edge_clip_sigma`, `edge_clip_max_iters`          |
