Skip to content

Commit d1d9a10

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 87cb994 commit d1d9a10

17 files changed

Lines changed: 145 additions & 93 deletions

mh_utils/csv_parser/classes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def to_dict(self):
218218
da_method=self.da_method,
219219
irm_cal_status=self.irm_cal_status,
220220
filename=self.filename,
221-
results=self.results_list
221+
results=self.results_list,
222222
)
223223

224224

@@ -750,7 +750,7 @@ def filter( # noqa: A003 # pylint: disable=redefined-builtin
750750
sample_names: Iterable[str],
751751
key: str = "sample_name",
752752
exclude: bool = False,
753-
) -> _SL:
753+
) -> _SL:
754754
"""
755755
Filter the list to only contain sample_names whose name is in ``sample_names``.
756756

mh_utils/csv_parser/utils.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,17 @@ def drop_columns(df: pandas.DataFrame, *, axis: int = 1, inplace: bool = True, *
113113

114114
lib_cols = ["Lib/DB", "Score (Lib)"]
115115

116-
new_df = df.drop([
117-
*unknown_cols,
118-
*db_cols,
119-
*mfg_cols,
120-
*lib_cols,
121-
], axis=axis, inplace=inplace, **kwargs)
116+
new_df = df.drop(
117+
[
118+
*unknown_cols,
119+
*db_cols,
120+
*mfg_cols,
121+
*lib_cols,
122+
],
123+
axis=axis,
124+
inplace=inplace,
125+
**kwargs,
126+
)
122127

123128
if inplace:
124129
return df

mh_utils/pcdl.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,25 @@ def compound_list_2_pandas(compound_list: List[PCDLCompound]) -> DataFrame:
160160
data.append(compound.as_list())
161161

162162
df = DataFrame(data, columns=columns)
163-
df = df.reindex([
164-
"Name",
165-
"Formula",
166-
"Mass",
167-
"Retention Time",
168-
"Retention Index",
169-
"Cation",
170-
"Anion",
171-
"CAS",
172-
"ChemSpider",
173-
"PubChem",
174-
"Synonyms",
175-
"IUPAC",
176-
"NumSpectra",
177-
"CCS Count",
178-
],
179-
axis=1)
163+
df = df.reindex(
164+
[
165+
"Name",
166+
"Formula",
167+
"Mass",
168+
"Retention Time",
169+
"Retention Index",
170+
"Cation",
171+
"Anion",
172+
"CAS",
173+
"ChemSpider",
174+
"PubChem",
175+
"Synonyms",
176+
"IUPAC",
177+
"NumSpectra",
178+
"CCS Count",
179+
],
180+
axis=1,
181+
)
180182

181183
names = df["IUPAC"]
182184
sort_order = get_IUPAC_sort_order(names)

mh_utils/worklist_parser/classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def from_xml(cls, element: lxml.objectify.ObjectifiedElement) -> "Checksum":
273273
return cls(
274274
SchemaVersion=element.attrib["SchemaVersion"],
275275
ALGO_VERSION=element.attrib["ALGO_VERSION"],
276-
HASHCODE=element.MAIN.attrib["HASHCODE"]
276+
HASHCODE=element.MAIN.attrib["HASHCODE"],
277277
)
278278

279279

tests/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
def any_type_parametrize():
1818
return pytest.mark.parametrize(
19-
f"value, expects", [
19+
f"value, expects",
20+
[
2021
("foo", "foo"),
2122
(1234, 1234),
2223
(12.34, 12.34),
2324
(True, True),
24-
]
25+
],
2526
)

tests/test_cef_parser/test_compound.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ def test_algo(self):
4949

5050
def test_location(self):
5151
assert Compound(
52-
algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}
52+
algo="FindByFormula",
53+
location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289},
5354
).location == {'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}
5455
assert Compound(
55-
algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}
56+
algo="FindByFormula",
57+
location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289},
5658
).location == {'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}
5759
assert Compound(algo="FindByFormula").location == {}
5860

@@ -63,7 +65,7 @@ def test_location(self):
6365
{"fbf": Score(82.53, flag_string="No H adduct", flag_severity=2)},
6466
{"fbf": Score(60.62, flag_string="low score", flag_severity=2)},
6567
{"fbf": Score(62.90, flag_string="low score", flag_severity=2)},
66-
]
68+
],
6769
)
6870
def test_compound_scores(self, scores):
6971
assert Compound(algo="FindByFormula", compound_scores=scores).compound_scores == copy.deepcopy(scores)
@@ -222,11 +224,13 @@ def expected_compound(fbf_spectrum, tof_spectrum):
222224
compound_scores={"fbf": score},
223225
results=[
224226
Molecule(
225-
name="Diphenylamine", formula="C12 H11 N", matches={
227+
name="Diphenylamine",
228+
formula="C12 H11 N",
229+
matches={
226230
"overall": score,
227231
"tgt": score,
228-
}
229-
)
232+
},
233+
),
230234
],
231235
spectra=[fbf_spectrum, tof_spectrum],
232236
)
@@ -260,7 +264,7 @@ def test_parse_cef(tmpdir, expected_compound):
260264
{raw_xml}
261265
</CompoundList>
262266
</CEF>
263-
"""
267+
""",
264268
)
265269

266270
cef = parse_cef(PathPlus(tmpdir) / "demo.cef")

tests/test_cef_parser/test_device.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88

99
@pytest.mark.parametrize(
10-
"device_type, device_type_expects", [
10+
"device_type, device_type_expects",
11+
[
1112
("hello world", "hello world"),
1213
("An Instrument", "An Instrument"),
13-
]
14+
],
1415
)
1516
@pytest.mark.parametrize(
1617
"number, number_expects",

tests/test_cef_parser/test_molecule.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ def test_name(self):
1414

1515
def test_formula(self):
1616
assert Molecule(
17-
name="Dimethyl Phthalate", formula="C10 H10 O4"
17+
name="Dimethyl Phthalate",
18+
formula="C10 H10 O4",
1819
).formula == Formula({'C': 10, 'H': 10, 'O': 4})
1920
assert Molecule(
20-
name="Dimethyl Phthalate", formula=Formula({'C': 10, 'H': 10, 'O': 4})
21+
name="Dimethyl Phthalate",
22+
formula=Formula({'C': 10, 'H': 10, 'O': 4}),
2123
).formula == Formula({'C': 10, 'H': 10, 'O': 4})
2224
assert Molecule(name="Dimethyl Phthalate").formula == Formula()
2325

@@ -47,7 +49,7 @@ def test_dict():
4749
"overall": Score(62.90),
4850
"tgt": Score(62.90, flag_string="low score", flag_severity=2),
4951
},
50-
)
52+
),
5153
) == {
5254
"name": "Dimethyl Phthalate",
5355
"formula": Formula({'C': 10, 'H': 10, 'O': 4}),
@@ -126,7 +128,7 @@ def test_from_xml(raw_xml, expects):
126128
(raw_xml_5, {"fbf": Score(62.90, flag_string="low score", flag_severity=2)}),
127129
(
128130
raw_xml_multiline,
129-
{"fbf": Score(62.90, flag_string="low score", flag_severity=2), "abc": Score(12.34)}
131+
{"fbf": Score(62.90, flag_string="low score", flag_severity=2), "abc": Score(12.34)},
130132
),
131133
],
132134
)

tests/test_cef_parser/test_parse_compound_scores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
(raw_xml_5, {"fbf": Score(62.90, flag_string="low score", flag_severity=2)}),
3434
(
3535
raw_xml_multiline,
36-
{"fbf": Score(62.90, flag_string="low score", flag_severity=2), "abc": Score(12.34)}
36+
{"fbf": Score(62.90, flag_string="low score", flag_severity=2), "abc": Score(12.34)},
3737
),
3838
],
3939
)

tests/test_cef_parser/test_peak.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_creation(
9393
170.0964,
9494
890559.25,
9595
1,
96-
"M+H"
96+
"M+H",
9797
),
9898
(
9999
'<p x="171.0998" rx="171.0996" y="114286.09" z="1" s="M+H+1" />',
@@ -109,15 +109,15 @@ def test_creation(
109109
172.1028,
110110
7151.12,
111111
1,
112-
"M+H+2"
112+
"M+H+2",
113113
),
114114
(
115115
'<p x="192.0831" rx="192.0784" y="490.62" z="1" s="M+Na" />',
116116
192.0831,
117117
192.0784,
118118
490.62,
119119
1,
120-
"M+Na"
120+
"M+Na",
121121
),
122122
],
123123
)

0 commit comments

Comments
 (0)