Skip to content

Commit 4b28784

Browse files
tests: Incremented pattern_data_counter based on loaded patterns
1 parent 6dcad4d commit 4b28784

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

opxrd/database/opxrd.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os.path
22
import tempfile
3+
import time
34
import zipfile
45

56
import requests
@@ -30,8 +31,11 @@ def as_database_list(cls, root_dirpath : str, download : bool = True) -> list[Pa
3031
pattern_dbs = []
3132
for d in os.listdir(path=root_dirpath):
3233
dirpath = os.path.join(root_dirpath, d)
34+
print(f' - Loading database {d}')
35+
time.sleep(0.01)
3336
db = PatternDB.load(dirpath=dirpath, strict=True)
3437
db.name = d
38+
3539
pattern_dbs.append(db)
3640
return pattern_dbs
3741

@@ -54,6 +58,7 @@ def _download_zenodo_opxrd(cls, output_fpath : str):
5458

5559
print(f'- Downloading opXRD database from Zenodo ({zenodo_url})')
5660
print(f'- Download chunk progress (Chunk size = 1kB):')
61+
time.sleep(0.01)
5762
tracked_int = TrackedInt(start_value=0, finish_value=total_chunks)
5863
with open(output_fpath, 'wb') as f:
5964
for chunk in file_response.iter_content(chunk_size=1024):

opxrd/usage.ipynb

Lines changed: 21 additions & 20 deletions
Large diffs are not rendered by default.

tests/t_download.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os.path
22
import tempfile
3+
import time
34

45
from holytools.devtools import Unittest
56
from holytools.userIO import TrackedInt
@@ -35,11 +36,12 @@ def test_as_database_list(self):
3536
self.assertTrue(len(dbs) > 5)
3637

3738
print(f'- Checking pattern data ok')
38-
k = TrackedInt(start_value=0,finish_value=len(dbs))
39+
total_num_patterns = sum([len(db.patterns) for db in dbs])
40+
k = TrackedInt(start_value=0,finish_value=total_num_patterns)
3941
for db in dbs:
4042
for p in db.patterns:
4143
self.check_pattern_data(fpath='None',p=p)
42-
k.increment()
44+
k.increment()
4345

4446
@staticmethod
4547
def check_pattern_data(fpath: str, p: XrdPattern):

0 commit comments

Comments
 (0)