Skip to content

Instantly share code, notes, and snippets.

@estshorter
Created December 31, 2019 05:05
Show Gist options
  • Save estshorter/4feb5f3806cc83eba7fb06bd7ceea733 to your computer and use it in GitHub Desktop.
Save estshorter/4feb5f3806cc83eba7fb06bd7ceea733 to your computer and use it in GitHub Desktop.
script for testing toml
import toml
import logging
# なんとなくloggingで出力する
logging.basicConfig(level=logging.DEBUG, format="{message}", style="{")
# 文字列としてパスを与えると読み込める
# pathlib.Pathクラスでも可
params = toml.load("./parameter/nominal.toml")
# dictクラスとしてロードされる
pglo = params["global"]
logging.info(pglo["max_timestep"])
logging.info(pglo["param"])
# dumps()で文字列に戻せる
logging.info("----Parameters----")
# ログにパラメータを書いておくと、シミュレータへの入出力が確認しやすい
logging.info(toml.dumps(params))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment