site
Stable type · Differentiate a model
Tier: stable · Kind: type · Topic: Differentiate a model
| Julia | Python | Rust |
|---|---|---|
Site | Site | Site |
Julia
struct Site
Site(expr::EarthSciAST.ASTExpr, key::String, name::String, rank::Int64)
Site(expr, key, name, rank)
Site(e::EarthSciAST.ASTExpr)
Site(expr)
The thing a scalar derivative is taken with respect to: a bare VarExpr
(scalar variable) or an index(v, i…) node (one symbolic cell of an array
variable). Two nodes denote the same site iff their canonical JSON agrees —
d/d(u[i+1,j]) treats index(u, +(i,1), j) and index(u, +(1,i), j) as the
same site because canonicalization sorts commutative arguments.
name/rank are a PREFILTER cached off expr, not extra identity: the site
reads variable name at rank subscripts (rank == -1 for a bare
VarExpr, -2 for a shape this fast path does not describe, which then
falls back to the plain key compare). See is_site for why.
Python
class Site
Site(expr: Expr, key: str)
@staticmethod Site.of(e: Expr) -> 'Site'
A bare variable reference or one symbolic index(v, i…) cell.