Skip to content

Commit

Permalink
Replace lists with generators
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc authored and hannes-ucsc committed Sep 20, 2023
1 parent b3dfea2 commit 1d86e67
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/hca_metadata_api/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def test_imaging_protocol(self):
version = '2019-04-03T103426.471000Z'
manifest, metadata_files = self._canned_bundle('staging', uuid, version)
bundle = Bundle(uuid, version, manifest, metadata_files)
imaging_protocol = one([p for p in bundle.protocols.values() if isinstance(p, ImagingProtocol)])
imaging_protocol = one(p for p in bundle.protocols.values() if isinstance(p, ImagingProtocol))
self.assertEqual(len(imaging_protocol.probe), 240)
assay_types = {probe.assay_type for probe in imaging_protocol.probe}
self.assertEqual(assay_types, {'in situ sequencing'})
Expand Down Expand Up @@ -547,7 +547,7 @@ def test_links_json_v2_0_0(self):
manifest, metadata_files = self._canned_bundle('prod', uuid, version)
bundle = Bundle(uuid, version, manifest, metadata_files)
for expected_count, link_type in [(6, 'process_link'), (2, 'supplementary_file_link')]:
actual_count = sum([1 for link in bundle.links if link.link_type == link_type])
actual_count = sum(1 for link in bundle.links if link.link_type == link_type)
self.assertEqual(expected_count, actual_count)
for link in bundle.links:
self.assertIn(link.source_type, api_entity_types)
Expand Down
2 changes: 1 addition & 1 deletion test/indexer/test_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ def test_cell_line_sample(self):
document_ids = one(contents[sample_entity_type])['document_id']
else:
document_ids = [d['document_id'] for d in contents[sample_entity_type]]
entity = one([d for d in contents[sample_entity_type] if d['document_id'] == sample['document_id']])
entity = one(d for d in contents[sample_entity_type] if d['document_id'] == sample['document_id'])
self.assertEqual(sample['biomaterial_id'], entity['biomaterial_id'])
self.assertTrue(sample['document_id'] in document_ids)
self.assertEqual(one(contents['specimens'])['organ'], ['blood'] if aggregate else 'blood')
Expand Down
2 changes: 1 addition & 1 deletion test/service/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ def _extract_bdbag_response(self,
self.assertEqual(200, response.status_code)
with ZipFile(BytesIO(response.content), 'r') as zip_fh:
zip_fh.extractall(zip_dir)
self.assertTrue(all(['manifest' == first(name.split('/')) for name in zip_fh.namelist()]))
self.assertTrue(all('manifest' == first(name.split('/')) for name in zip_fh.namelist()))
zip_fname = os.path.dirname(first(zip_fh.namelist()))
with open(os.path.join(zip_dir, zip_fname, 'data', 'participants.tsv'), 'r') as fh:
reader = csv.DictReader(fh, delimiter='\t')
Expand Down

0 comments on commit 1d86e67

Please sign in to comment.