Skip to content

Commit

Permalink
Merge pull request #210 from datamol-io/pathstr
Browse files Browse the repository at this point in the history
Make sure paths are string in `datamol.fs.glob`
  • Loading branch information
hadim committed Sep 4, 2023
2 parents c0b6450 + 90b55c8 commit 22b5bb0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions datamol/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def glob(path: str, detail: bool = False, **kwargs) -> List[str]:
path: A glob-style path.
"""
# Get the list of paths
path = str(path)
fs = get_mapper(path).fs
paths = fs.glob(path, detail=detail, **kwargs)
paths = [fsspec.utils._unstrip_protocol(d, fs) for d in paths]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_conformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_generate_4():
smiles = "CCCC"
mol = dm.to_mol(smiles)
mol = dm.conformers.generate(mol, rms_cutoff=1, minimize_energy=True)
assert mol.GetNumConformers() == 21
assert mol.GetNumConformers() in [20, 21]
assert "rdkit_UFF_energy" in mol.GetConformer(0).GetPropsAsDict()


Expand Down
3 changes: 2 additions & 1 deletion tests/test_utils_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def test_glob(tmp_path):
with open(tmp_file, "w") as f:
f.write("hello")

assert len(dm.utils.fs.glob(tmp_path / "*.txt")) == 5
tmp_path_regex = tmp_path / "*.txt"
assert len(dm.utils.fs.glob(tmp_path_regex)) == 5


def test_copy_file(tmp_path):
Expand Down

0 comments on commit 22b5bb0

Please sign in to comment.