-
Notifications
You must be signed in to change notification settings - Fork 0
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 #112 from eastgenomics/improve_url_value_typing
Fix url value typing
- Loading branch information
Showing
5 changed files
with
47 additions
and
22 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
25 changes: 25 additions & 0 deletions
25
resources/home/dnanexus/generate_workbook/tests/test_utils.py
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,25 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.abspath( | ||
os.path.join(os.path.realpath(__file__), '../../') | ||
)) | ||
|
||
from utils.utils import is_numeric | ||
|
||
|
||
def test_is_numeric(): | ||
""" | ||
Tests that all forms of numerical value are correctly identified as | ||
being numeric | ||
""" | ||
numeric_values = ['5', '5.5', '-0.1', '1e-5'] | ||
non_numeric_values = ['5,6', '5, 6', '.', '3/4', ] | ||
|
||
assert all([is_numeric(x) for x in numeric_values]), ( | ||
'some numeric values do not properly evaluate to being numeric' | ||
) | ||
|
||
assert all([not is_numeric(x) for x in non_numeric_values]), ( | ||
'some non-numeric values wrongly evaluate to being numeric' | ||
) |
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,16 @@ | ||
def is_numeric(value:str) -> bool: | ||
""" | ||
Returns true if given value is in some form numeric | ||
Parameters | ||
---------- | ||
value : str | ||
string to check if can be cast to numeric type | ||
Returns | ||
------- | ||
bool | ||
True if value can be numeric | ||
""" | ||
return str(value).lstrip('-').replace('.', '').replace( | ||
'e-', '', 1).replace('e', '').isdigit() |
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