Use f-strings where possible#205
Conversation
It's faster.
| if wmask.shape != shape: | ||
| err = "wmask has incorrect shape:" + str(wmask.shape) + \ | ||
| " should be " + str(shape) | ||
| err = f"wmask has incorrect shape: {wmask.shape} should be {shape}" |
There was a problem hiding this comment.
I have added a space after incorrect shape:
|
|
||
| except ValueError: | ||
| warn(str(data.shape) + "cannot be shaped into" + str(shape)) | ||
| warn(f"{data.shape} cannot be shaped into {shape}") |
There was a problem hiding this comment.
I have added a space before and after "cannot be shaped into".
| dic[key] = value | ||
| except: | ||
| warn("Unable to correctly parse line:" + line) | ||
| warn(f"Unable to correctly parse line: {line}") |
There was a problem hiding this comment.
I have added a space after line:.
| warn(f"Unable to correctly parse line: {line}") | ||
| else: | ||
| warn("Extraneous line:" + line) | ||
| warn(f"Extraneous line: {line}") |
There was a problem hiding this comment.
I have added a space after line:.
| value = "".join(currentvaluestrings) # collapse | ||
| if not value.strip(): | ||
| warn("JCAMP-DX key without value:" + key) | ||
| warn(f"JCAMP-DX key without value: {key}") |
There was a problem hiding this comment.
I have added a space after value:.
| valuestr = keysplit[1] | ||
| if not keystr: | ||
| warn("Empty key in JCAMP-DX line:" + line) | ||
| warn(f"Empty key in JCAMP-DX line: {line}") |
There was a problem hiding this comment.
I have added a space after line:.
| data = data.reshape(shape) | ||
| except ValueError: | ||
| warn(str(data.shape) + "cannot be shaped into" + str(shape)) | ||
| warn(f"{data.shape} cannot be shaped into {shape}") |
There was a problem hiding this comment.
I have added a space before and after cannot be shaped into.
| warn("data cannot be re-ordered, returning raw 2D data\n" + | ||
| "Provided shape: " + str(shape) + " torder: " + str(torder)) | ||
| warn(f"data cannot be re-ordered, returning raw 2D data\n" + | ||
| f"Provided shape: {shape} torder: {torder}") |
There was a problem hiding this comment.
I have added a space before torder:.
| data = data.reshape(shape) | ||
| except ValueError: | ||
| warn(str(data.shape) + "cannot be shaped into" + str(shape)) | ||
| warn(f"{data.shape} cannot be shaped into {shape}") |
There was a problem hiding this comment.
I have added a space before and after cannot be shaped into.
| data = data.reshape(shape) | ||
| except ValueError: | ||
| warn(str(data.shape) + "cannot be shaped into" + str(shape)) | ||
| warn(f"{data.shape} cannot be shaped into {shape}") |
There was a problem hiding this comment.
I have added a space before and after cannot be shaped into.
|
|
||
| if dry: | ||
| MSG("The following command will be executed: \n" + " ".join(args)) | ||
| MSG("The following command will be executed:\n" + " ".join(args)) |
There was a problem hiding this comment.
I have removed the spurious space before \n. I am wondering whether the intent was to have \n after " ".join(args).
There was a problem hiding this comment.
I'm not sure on the intent here. Likely just a typo or overlooked extra character.
|
Thanks @DimitriPapadopoulos for the PR. I like how f-string make the message more understandable. |
It's faster.
Also a couple small changes here and there.