pyhs3 installs a command-line tool of the same name, wired to
pyhs3.cli:app. Run pyhs3--help or python-mpyhs3--help for the
tool’s own summary of the commands below.
Every command accepts the workspace as a positional argument, a path to an
HS3 JSON file. Passing -, or omitting the argument entirely when standard
input is not a terminal, reads the workspace from stdin instead, so catworkspace.json|pyhs3validate- and pyhs3validateworkspace.json are
equivalent.
pyhs3Usage: pyhs3 [OPTIONS] COMMAND [ARGS]...Command-line tools for HS3 workspaces: validate, inspect, and evaluate. ╭─ Options ─────────────────────────────────────────────────────╮│--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯╭─ Commands ────────────────────────────────────────────────────╮│graph Render a distribution's computation graph to an ││image file. ││validateLoad and validate an HS3 workspace, reporting ││success or the errors found. ││inspect Summarize a workspace: distributions, domains, ││data, likelihoods, analyses. ││nll Compute the negative log-likelihood at a point in ││parameter space. ││plot Render one named data entry from a workspace as a ││matplotlib figure. ││convert Convert between pyhf (HistFactory JSON) and HS3 ││workspaces. │╰───────────────────────────────────────────────────────────────╯
graphUsage: pyhs3 graph [OPTIONS] [WORKSPACE]Render a distribution's computation graph to an image file. Builds the model the same way nll does (--analysis selects whichanalysis or likelihood to build from, --parameter-setreplaces theanalysis init) and delegates toModel.visualize_graph. Prints the path of therendered file to stdout. Requires the graph optional dependency(pip install 'pyhs3[graph]', which installs pydot) and thesystem Graphviz dot executable, which pydot cannot install on its own(apt install graphviz, brew install graphviz, orconda install graphviz). If either is missing, or the nameddistribution doesn't exist in the model, this reports the problemthrough a clean error and exits non-zero, never a raw traceback.╭─ Arguments ───────────────────────────────────────────────────╮│WORKSPACE<str>Path to an HS3 workspace JSON file. ││Use '-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│*--name<str>Name of the distribution to ││visualize. ││[required] ││--analysis<str>Name of the analysis (or ││likelihood) to build the ││model from. Defaults to the ││sole one. ││--parameter-set<str>Parameter set whose values ││and const flags to use, ││instead of the analysis ││init. ││--fmt<str>Output format: svg, png, or ││pdf. ││[default: svg] ││--outfile<str>Output file path. Defaults ││to '{name}_graph.{fmt}'. ││--path<str>Directory to write the ││output file in. Ignored if ││--outfile is set. ││--show-idAppend each op's toposort ││index to its label. ││--show-dtypeKeep dtype annotations in ││node labels. ││--show-shapeKeep shape annotations in ││node labels. ││--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯
validateUsage: pyhs3 validate [OPTIONS] [WORKSPACE]Load and validate an HS3 workspace, reporting success or the errors found. On success, prints <source> is a valid HS3 workspace. and exits0. Onfailure, exits 1: a schema error (a field missing or the wrong type) isreported through Workspace.format_validation_error, and without--verbose only the first 20 are shown, with the rest summarized bycount; an unresolved cross-reference (a likelihood naming a distributionthat doesn't exist, for example) is reported throughpyhs3.exceptions.WorkspaceValidationError.╭─ Arguments ───────────────────────────────────────────────────╮│WORKSPACE<str>Path to an HS3 workspace JSON file. ││Use '-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│--verbose-vShow all validation errors, not just the││first 20. ││--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯
inspectUsage: pyhs3 inspect [OPTIONS] [WORKSPACE]Summarize a workspace: distributions, domains, data, likelihoods, analyses. Prints a Rich table when attached to an interactive terminal and machinereadable JSON when piped. Override the autodetection with --json or--no-json.Table output caps each section at _MAX_ROWS_DEFAULT rows by default;pass --verbose/-v to show every row. JSON output is alwayscomplete and is never truncated by --verbose/-v — it is meant formachine/script consumption, so it must never silentlydrop entries.╭─ Arguments ───────────────────────────────────────────────────╮│WORKSPACE<str>Path to an HS3 workspace JSON file. ││Use '-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│--json--no-jsonForce JSON (--json) or table ││(--no-json) output. Default: ││autodetect from the terminal. ││--verbose-vShow every row in table output,││without the 10-row-per-section ││cap. Has no effect on --json ││output, which is always ││complete. ││--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯
nllUsage: pyhs3 nll [OPTIONS] [WORKSPACE]Compute the negative log-likelihood at a point in parameter space. The printed value is -2 * log_prob -- twice the negated jointlog-probability -- not the plain -log_prob some other tools(including RooFit's own createNLL()) report under the same name.Compare against a RooFit/combine-side number with that factor of two inmind.Parameter values are layered, later layers winning: the workspace's ownparameter_points (so an analysis without an init set is stillevaluable), then the model's free (non-const)parameter values, then--params-file, then repeated --param name=value (a name givenboth in the file and on the command line takes the command-line value).A --param naming an observable, or naming something that is neitheran observable nor a free parameter of the model (a typo, for example),is rejected with a warning and ignored -- it can never override theworkspace's actual observed data -- and the command still exits 0. Afree parameter with no value available anywhere in this layering raisesa fatal error naming it, exiting non-zero.--analysis accepts either an analysis name or a likelihood namedirectly. With neither given, the workspace's sole analysis is used, or,absent any analyses, its sole likelihood; having morethan one of eitherwithout --analysis is a fatal error.--parameter-set builds the model with the named parameter set in placeof the analysis init: its values seed the free parameters and itsconst flags hold parameters constant. HS3 requires every likelihoodparameter of an analysis to be in oneof its domains or const in that set;ROOT exports, which give their analyses no init, usually need thisoption, and the errorfor a violating analysis names the sets that work.╭─ Arguments ───────────────────────────────────────────────────╮│WORKSPACE<str>Path to an HS3 workspace JSON file. ││Use '-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│--param-pNAME=VALUEOverride a parameter ││value. Repeatable. ││--params-file<file>JSON file mapping ││parameter names to ││values. ││--analysis<str>Name of the analysis (or││likelihood) to evaluate.││Defaults to the sole ││one. ││--parameter-set<str>Parameter set whose ││values and const flags ││to use, instead of the ││analysis init. ││--helpShow this message and ││exit. │╰───────────────────────────────────────────────────────────────╯
plotUsage: pyhs3 plot [OPTIONS] [WORKSPACE]Render one named data entry from a workspace as a matplotlib figure. Requires the plot extra (pip install 'pyhs3[plot]'), whichinstalls hist[plot] -- matplotlib andmplhep, since plotting ahist.Hist needs both; matplotlib alone is not enough. If matplotlibitself is missing, this reports a clean error ratherthan a rawtraceback; if matplotlib is present but mplhepspecifically ismissing (an unusual partial install), plotting can still raise a rawModuleNotFoundError -- installing the plot extra as documentedavoids this case entirely.Only 1D BinnedData/UnbinnedData and 2D BinnedData aresupported; other shapes raise a clear error rather than a misleading plot.╭─ Arguments ───────────────────────────────────────────────────╮│WORKSPACE<str>Path to an HS3 workspace JSON file. ││Use '-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│*--data-name<str>Name of the entry in the ││workspace's data list to plot. ││[required] ││--outfile<path>Output file path. Defaults to ││'{data-name}.{fmt}' in the ││current directory. ││--fmt<str>Output image format: 'png', ││'pdf', or 'svg'. ││[default: png] ││--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯
convertUsage: pyhs3 convert [OPTIONS] COMMAND [ARGS]...Convert between pyhf (HistFactory JSON) and HS3 workspaces. ╭─ Options ─────────────────────────────────────────────────────╮│--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯╭─ Commands ────────────────────────────────────────────────────╮│to-hs3 Convert a pyhf workspace (HistFactory JSON) to an ││HS3 workspace. ││to-pyhfConvert an HS3 workspace of HistFactory channels to ││a pyhf workspace. │╰───────────────────────────────────────────────────────────────╯
to-hs3Usage: pyhs3 convert to-hs3 [OPTIONS] [INPUT]Convert a pyhf workspace (HistFactory JSON) to an HS3 workspace. The input must already have any patches applied. An input that is not avalid pyhf workspace, or that HS3 cannot express, is reported as an error.╭─ Arguments ───────────────────────────────────────────────────╮│INPUT<str>Path to a pyhf workspace JSON file. Use ││'-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│--output-o<file>File to write the converted ││workspace to. Default: ││stdout. ││--interpcodeTYPE=CODEInterpolation code of a ││modifier type, as pyhf's ││modifier_settings give it, ││e.g. normsys=code1. ││Repeatable. Default: ││normsys=code4 and ││histosys=code4p. ││--helpShow this message and exit. │╰───────────────────────────────────────────────────────────────╯
to-pyhfUsage: pyhs3 convert to-pyhf [OPTIONS] [INPUT]Convert an HS3 workspace of HistFactory channels to a pyhf workspace. pyhf's JSON holds no interpolation codes, so the command also gives themodifier_settings to build the pyhf model with,pyhf.Workspace(spec).model(modifier_settings=...): written to--modifier-settings, or printed to stderr so stdout stays theworkspace. Content pyhf cannot express is reported as an error.╭─ Arguments ───────────────────────────────────────────────────╮│INPUT<str>Path to an HS3 workspace JSON file. Use ││'-' or omit to read from stdin. │╰───────────────────────────────────────────────────────────────╯╭─ Options ─────────────────────────────────────────────────────╮│--output-o<file>File to write the ││converted workspace to. ││Default: stdout. ││--likelihood<str>Name of the likelihood ││to convert. Required ││when the likelihoods ││pair the channels with ││different data. ││--poi<str>Parameter of interest, ││for an analysis listing ││several or none. ││--parameter-set<str>Parameter point to take ││initial values and const││flags from, instead of ││each analysis's init. ││--modifier-settings<file>File to write the ││modifier_settings to. ││Default: print them to ││stderr. ││--helpShow this message and ││exit. │╰───────────────────────────────────────────────────────────────╯