API Reference

introduction.zohTool.cli

introduction.zohTool.cli.build_parser()[source]

Build the command-line parser.

Return type:

ArgumentParser

introduction.zohTool.cli.main(argv=None)[source]

Run the zohTool command-line interface.

Parameters:

argv (list[str] | None)

Return type:

int

introduction.zohTool.apis

class introduction.zohTool.apis.IntervalEvent(k: 'int', t0: 'float', t1: 'float', u_in: 'float', y0: 'float', y1: 'float')[source]

Bases: object

Parameters:
  • k (int)

  • t0 (float)

  • t1 (float)

  • u_in (float)

  • y0 (float)

  • y1 (float)

as_dict()[source]
Return type:

Dict[str, Any]

k: int
t0: float
t1: float
u_in: float
y0: float
y1: float
class introduction.zohTool.apis.RunRequest(csv=None, json_spec=None, Ts=0.001, delay=0.0, droop_tau=inf, offset=0.0, units='V', scale=1000000.0, idx_bits=None, in_dir='in', out_dir='out', out_csv=None, out_vcd=None)[source]

Bases: object

Typed input for running a ZOH simulation.

Parameters:
  • csv (str | None)

  • json_spec (str | None)

  • Ts (float)

  • delay (float)

  • droop_tau (float)

  • offset (float)

  • units (str)

  • scale (float)

  • idx_bits (int | None)

  • in_dir (str)

  • out_dir (str)

  • out_csv (str | None)

  • out_vcd (str | None)

Ts: float = 0.001
csv: str | None = None
delay: float = 0.0
droop_tau: float = inf
idx_bits: int | None = None
in_dir: str = 'in'
json_spec: str | None = None
offset: float = 0.0
out_csv: str | None = None
out_dir: str = 'out'
out_vcd: str | None = None
scale: float = 1000000.0
units: str = 'V'
class introduction.zohTool.apis.RunResult(events: 'List[IntervalEvent]' = <factory>, messages: 'List[str]' = <factory>, wrote_csv: 'Optional[str]' = None, wrote_vcd: 'Optional[str]' = None)[source]

Bases: object

Parameters:
  • events (List[IntervalEvent])

  • messages (List[str])

  • wrote_csv (str | None)

  • wrote_vcd (str | None)

events: List[IntervalEvent]
messages: List[str]
wrote_csv: str | None = None
wrote_vcd: str | None = None

introduction.zohTool.app

class introduction.zohTool.app.ZOHApp[source]

Bases: object

Thin orchestrator to run ZOH end-to-end in a testable way.

run(req)[source]
Parameters:

req (RunRequest)

Return type:

RunResult

introduction.zohTool.core

class introduction.zohTool.core.ZOHModel(Ts, delay=0.0, droop_tau=inf, offset=0.0)[source]

Bases: object

Parameter container for ZOH behavior.

Parameters:
  • Ts (float)

  • delay (float)

  • droop_tau (float)

  • offset (float)

class introduction.zohTool.core.ZOHSimulator(model)[source]

Bases: object

Build interval-wise events for ZOH output.

Parameters:

model (ZOHModel)

expand(u)[source]
Parameters:

u (List[float])

Return type:

List[IntervalEvent]

introduction.zohTool.design

class introduction.zohTool.design.CSVExporter[source]

Bases: object

write_results_csv(path, events, units)[source]
Parameters:
Return type:

None

class introduction.zohTool.design.VCDWriter[source]

Bases: object

write_vcd_zoh(path, events, scale=1000000.0, idx_bits=None)[source]
Parameters:
  • path (str)

  • events (List[IntervalEvent])

  • scale (float)

  • idx_bits (int | None)

Return type:

None

introduction.zohTool.io

introduction.zohTool.io.load_u_from_csv(path)[source]
CSV formats accepted:
  1. ‘u’ column (values in order, k = row index)

  2. ‘k’,’u’ columns (k can be nonconsecutive; rows are sorted by k)

Parameters:

path (str)

Return type:

List[float]

introduction.zohTool.io.load_u_from_json(path_or_inline)[source]
JSON formats accepted:
  • [u0, u1, u2, …]

  • [{“u”: 1.23}, {“u”: 0.8}, …]

  • {“vectors”:[{“u”:…}, …]}

Parameters:

path_or_inline (str)

Return type:

List[float]

introduction.zohTool.utils

introduction.zohTool.utils.ensure_dir(path)[source]
Parameters:

path (str)

Return type:

None

introduction.zohTool.utils.log_call(logger_func=None)[source]

A tiny decorator to log function calls (name + kwargs). Pass a logger function that accepts a single string (e.g., print).

Parameters:

logger_func (Callable[[str], Any] | None)

introduction.zohTool.utils.looks_inline_json(s)[source]
Parameters:

s (str)

Return type:

bool

introduction.zohTool.utils.resolve_input_path(p, in_dir)[source]

Resolve an input path: if inline JSON, return as-is; else search under in_dir.

Parameters:
  • p (str | None)

  • in_dir (str)

Return type:

str | None

introduction.zohTool.utils.resolve_output_path(p, out_dir)[source]

Resolve an output path: relative -> out_dir/relative; absolute -> as-is.

Parameters:
  • p (str | None)

  • out_dir (str)

Return type:

str | None