MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _euler_step

Function _euler_step

lib/matplotlib/streamplot.py:665–684  ·  view source on GitHub ↗

Simple Euler integration step that extends streamline to boundary.

(xyf_traj, dmap, f)

Source from the content-addressed store, hash-verified

663
664
665def _euler_step(xyf_traj, dmap, f):
666 """Simple Euler integration step that extends streamline to boundary."""
667 ny, nx = dmap.grid.shape
668 xi, yi = xyf_traj[-1]
669 cx, cy = f(xi, yi)
670 if cx == 0:
671 dsx = np.inf
672 elif cx < 0:
673 dsx = xi / -cx
674 else:
675 dsx = (nx - 1 - xi) / cx
676 if cy == 0:
677 dsy = np.inf
678 elif cy < 0:
679 dsy = yi / -cy
680 else:
681 dsy = (ny - 1 - yi) / cy
682 ds = min(dsx, dsy)
683 xyf_traj.append((xi + cx * ds, yi + cy * ds))
684 return ds, xyf_traj
685
686
687# Utility functions

Callers 1

_integrate_rk12Function · 0.85

Calls 1

fFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…