Skip to content

Commit

Permalink
refactor(cli.py): cosmetic format
Browse files Browse the repository at this point in the history
  • Loading branch information
Taoning Wang committed Aug 30, 2023
1 parent 6fdb86b commit 4d16fce
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions frads/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ def parse_mrad_config(cfg_path: Path) -> Dict[str, dict]:
config_dict["settings"]["separate_direct"] = config["SimControl"].getboolean(
"separate_direct"
)
config_dict["settings"]["overwrite"] = config["SimControl"].getboolean("overwrite", False)
config_dict["settings"]["save_matrices"] = config["SimControl"].getboolean("save_matrices", True)
config_dict["settings"]["overwrite"] = config["SimControl"].getboolean(
"overwrite", False
)
config_dict["settings"]["save_matrices"] = config["SimControl"].getboolean(
"save_matrices", True
)
config_dict["model"] = {
"scene": {},
"materials": {},
Expand Down Expand Up @@ -484,7 +488,7 @@ def genmtx_pts_sky(args) -> None:
del args.pts, args.basis, args.sys, args.verbose, args.func
mat = Matrix(sender, [receiver], octree=None, surfaces=sys_paths)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args) if v is not None}
sparams_dict = {k: v for k, v in vars(args) if v is not None}
sparams.update_from_dict(sparams_dict)
mat.generate(params=sparams.args(), to_file=True)

Expand All @@ -505,7 +509,7 @@ def genmtx_vu_sky(args) -> None:
del args.vu, args.basis, args.sys, args.resolu, args.verbose, args.func
mat = Matrix(sender, [receiver], octree=None, surfaces=sys_paths)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args) if v is not None}
sparams_dict = {k: v for k, v in vars(args) if v is not None}
sparams.update_from_dict(sparams_dict)
mat.generate(params=sparams.args(), to_file=True)

Expand All @@ -523,7 +527,7 @@ def genmtx_srf_sky(args) -> None:
del args.srf, args.basis, args.sys, args.offset, args.verbose, args.func
mat = Matrix(sender, [receiver], octree=None, surfaces=sys_paths)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
mat.generate(params=sparams.args(), to_file=True)

Expand Down Expand Up @@ -558,7 +562,7 @@ def genmtx_pts_srf(args) -> None:
del args.pts, args.srf, args.sys, args.basis, args.offset, args.verbose, args.func
mat = Matrix(sender, receivers, octree=None, surfaces=sys_paths)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
mat.generate(params=sparams.args(), to_file=True)

Expand Down Expand Up @@ -595,10 +599,19 @@ def genmtx_vu_srf(args) -> None:
out=outpath / "%04d.hdr",
)
)
del args.vu, args.srf, args.sys, args.basis, args.offset, args.resolu, args.verbose, args.func
del (
args.vu,
args.srf,
args.sys,
args.basis,
args.offset,
args.resolu,
args.verbose,
args.func,
)
mat = Matrix(sender, receivers, octree=None, surfaces=sys_paths)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
mat.generate(params=sparams.args(), to_file=True)

Expand Down Expand Up @@ -635,7 +648,7 @@ def genmtx_srf_srf(args) -> None:
del args.ssrf, args.rsrf, args.sys, args.basis, args.offset, args.verbose, args.func
mat = Matrix(sender, receivers, octree=None, surfaces=sys_paths)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
mat.generate(params=sparams.args(), to_file=True)

Expand Down Expand Up @@ -663,9 +676,9 @@ def genmtx_pts_sun(args) -> None:
surfaces=sys_paths,
)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
with open(out, 'wb') as f:
with open(out, "wb") as f:
f.write(mat.generate(parameters=sparams.args(), radmtx=True))


Expand Down Expand Up @@ -701,7 +714,7 @@ def genmtx_vu_sun(args) -> None:
args.resolu,
args.smx_path,
args.verbose,
args.func
args.func,
)
mtx = SunMatrix(
sender,
Expand All @@ -710,7 +723,7 @@ def genmtx_vu_sun(args) -> None:
surfaces=sys_paths,
)
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
mtx.generate(parameters=sparams.args())
write_hdrs(mtx.array, xres=xres, yres=yres, outdir=str(outpath))
Expand All @@ -728,7 +741,7 @@ def genmtx_ncp(args: argparse.Namespace) -> None:
out = Path(f"{args.window.stem}_{args.ncp.stem}.mtx")
del args.window, args.ncp, args.basis, args.sys, args.verbose, args.wrap
sparams = SamplingParameters()
sparams_dict = {k:v for k,v in vars(args).items() if v is not None}
sparams_dict = {k: v for k, v in vars(args).items() if v is not None}
sparams.update_from_dict(sparams_dict)
ncp.gen_ncp_mtx(nmodel, out, sparams.args(), wrap=wrap)

Expand Down

0 comments on commit 4d16fce

Please sign in to comment.