Contrast¶
- class passengersim.contrast.Contrast[source]¶
Bases:
dictA named collection of SimulationTables for side-by-side comparison.
Contrastis adictsubclass that maps string labels toSimulationTablesinstances. It provides methods for aggregating, visualizing, and reporting results across multiple PassengerSim simulation runs.Module-level functions whose names begin with
fig_are automatically accessible as instance methods, with the firstsummariesargument pre-filled with this object.Methods
__init__(*args, **kwargs)apply(func[, axis, warn_if_missing])Apply a callable to each non-None entry and concatenate the results.
clear()copy()fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
items()keys()pop(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem()Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
subset([keys, regex])Subset the contrast to only include the specified keys.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()write_report(filename, **kwargs)Write an HTML report summarizing this contrast to a file.
-
apply(func: Callable, axis: int | 'index' | 'columns' | 'rows' =
0, warn_if_missing: bool =False) DataFrame | Series[source]¶ Apply a callable to each non-None entry and concatenate the results.
- Parameters:
- func : callable¶
A function that accepts a
SimulationTablesinstance and returns a pandas Series or DataFrame.- axis : int or {'index', 'columns', 'rows'}, default 0¶
The axis along which to concatenate the results. Passed directly to
pandas.concat().- warn_if_missing : bool, default False¶
If True, emit a warning for any key whose value is
None.
- Returns:
pd.DataFrame or pd.Series – Concatenated results with a
"source"level prepended to the index.
- write_report(filename: str | bytes | PathLike, **kwargs) Path[source]¶
Write an HTML report summarizing this contrast to a file.
-
subset(keys=
None, *, regex: str | None =None) Self[source]¶ Subset the contrast to only include the specified keys.
- clear() None. Remove all items from D.¶
- copy() a shallow copy of D¶
-
classmethod fromkeys(iterable, value=
None, /)¶ Create a new dictionary with keys from iterable and values set to value.
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
-
setdefault(key, default=
None, /)¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values¶
-
apply(func: Callable, axis: int | 'index' | 'columns' | 'rows' =