-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from ReactionMechanismGenerator/job
Job adapters
- Loading branch information
Showing
109 changed files
with
192,749 additions
and
4,494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import arc.checks.ts | ||
import arc.checks.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
A module with common functionalities used for checking the quality of calculations, | ||
contains helper functions for Scheduler. | ||
""" | ||
|
||
import datetime | ||
|
||
from typing import List, Optional | ||
|
||
|
||
def sum_time_delta(timedelta_list: List[datetime.timedelta]) -> datetime.timedelta: | ||
""" | ||
A helper function for summing datetime.timedelta objects. | ||
Args: | ||
timedelta_list (list): Time delta's to sum. | ||
Returns: | ||
datetime.timedelta: The timedelta sum. | ||
""" | ||
result = datetime.timedelta(0) | ||
for timedelta in timedelta_list: | ||
if type(timedelta) == type(result): | ||
result += timedelta | ||
return result | ||
|
||
|
||
def get_i_from_job_name(job_name: str) -> Optional[int]: | ||
""" | ||
Get the conformer or tsg index from the job name. | ||
Args: | ||
job_name (str): The job name, e.g., 'conformer12' or 'tsg5'. | ||
Returns: | ||
Optional[int]: The corresponding conformer or tsg index. | ||
""" | ||
i = None | ||
if 'conformer' in job_name: | ||
i = int(job_name[9:]) | ||
elif 'tsg' in job_name: | ||
i = int(job_name[3:]) | ||
return i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
# encoding: utf-8 | ||
|
||
""" | ||
This module contains unit tests for the arc.checks.common module | ||
""" | ||
|
||
import datetime | ||
import unittest | ||
|
||
import arc.checks.common as common | ||
|
||
|
||
class TestChecks(unittest.TestCase): | ||
""" | ||
Contains unit tests for the check module. | ||
""" | ||
def test_sum_time_delta(self): | ||
"""Test the sum_time_delta() function""" | ||
dt1 = datetime.timedelta(days=0, minutes=0, seconds=0) | ||
dt2 = datetime.timedelta(days=0, minutes=0, seconds=0) | ||
dt3 = datetime.timedelta(days=0, minutes=1, seconds=15) | ||
dt4 = datetime.timedelta(days=10, minutes=1, seconds=15, microseconds=300) | ||
fake_dt5 = None | ||
fake_dt6 = 'fake' | ||
fake_dt7 = 18.52 | ||
self.assertEqual(common.sum_time_delta([]), datetime.timedelta(days=0, minutes=0, seconds=0)) | ||
self.assertEqual(common.sum_time_delta([dt1]), datetime.timedelta(days=0, minutes=0, seconds=0)) | ||
self.assertEqual(common.sum_time_delta([dt1, dt2]), datetime.timedelta(days=0, minutes=0, seconds=0)) | ||
self.assertEqual(common.sum_time_delta([dt1, dt3]), datetime.timedelta(days=0, minutes=1, seconds=15)) | ||
self.assertEqual(common.sum_time_delta([dt3, dt4]), datetime.timedelta(days=10, minutes=2, seconds=30, microseconds=300)) | ||
self.assertEqual(common.sum_time_delta([dt3, fake_dt5, fake_dt6, fake_dt7]), | ||
datetime.timedelta(days=0, minutes=1, seconds=15)) | ||
|
||
def test_get_i_from_job_name(self): | ||
"""Test the get_i_from_job_name() function""" | ||
self.assertIsNone(common.get_i_from_job_name('')) | ||
self.assertIsNone(common.get_i_from_job_name('some_job_name')) | ||
self.assertEqual(common.get_i_from_job_name('conformer3'), 3) | ||
self.assertEqual(common.get_i_from_job_name('conformer33'), 33) | ||
self.assertEqual(common.get_i_from_job_name('conformer3355'), 3355) | ||
self.assertEqual(common.get_i_from_job_name('tsg2'), 2) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2)) |
Oops, something went wrong.