-
Notifications
You must be signed in to change notification settings - Fork 4
Full name for quantity #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
97f20c1
Basic test harness for names
rprospero 22fc8a6
Base 62 encode the hash for shorter names
rprospero 849bc48
Name info in unique id for NamedQuantity
rprospero d4a3818
Ruff formatting
rprospero f346eab
Properly attach run title and number to quantity information
rprospero f52a328
Make the name a part of all quantities
rprospero e02a8e2
Ensure that xml imports also include a proper name unique id
rprospero db27e4e
Ensure ASCII reader generates unique_id for data quantities
rprospero 82d99b8
Refactor our id_header
rprospero 7c2cfc3
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 9eea1b4
Minor formatting fixes
rprospero 0cd7e21
Remove debugging print statements
rprospero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,44 @@ | ||
| """ | ||
| Tests for generation of unique, but reproducible, names for data quantities | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| from sasdata.data import SasData | ||
| from sasdata.temp_ascii_reader import load_data_default_params | ||
| from sasdata.temp_hdf5_reader import load_data as hdf_load_data | ||
| from sasdata.temp_xml_reader import load_data as xml_load_data | ||
|
|
||
|
|
||
| def local_load(path: str) -> SasData: | ||
| """Get local file path""" | ||
| base = os.path.join(os.path.dirname(__file__), path) | ||
| if os.path.exists(f"{base}.h5"): | ||
| return hdf_load_data(f"{base}.h5").values() | ||
| if os.path.exists(f"{base}.xml"): | ||
| return xml_load_data(f"{base}.xml").values() | ||
| if os.path.exists(f"{base}.txt"): | ||
| return load_data_default_params(f"{base}.txt") | ||
| assert False | ||
|
|
||
|
|
||
| test_file_names = [ | ||
| ("ascii_test_1", "::Q:3KrS58TPgclJ1rgyr0VQp3"), | ||
| ("ISIS_1_1", "TK49 c10_SANS:79680:Q:4TghWEoJi6xxhyeDXhS751"), | ||
| ("cansas1d", "Test title:1234:Q:440tNBqdx9jvci6CgjmrmD"), | ||
| ("MAR07232_rest", "MAR07232_rest_out.dat:2:/sasentry01/sasdata01/Qx:2Y0qTTb054KSJnJaJv0rFl"), | ||
| ("simpleexamplefile", "::/sasentry01/sasdata01/Q:uoHMeB8mukElC1uLCy7Sd"), | ||
| ] | ||
|
|
||
|
|
||
| @pytest.mark.names | ||
| @pytest.mark.parametrize("x", test_file_names) | ||
| def test_quantity_name(x): | ||
| (f, expected) = x | ||
| data = [v for v in local_load(f"data/{f}")][0] | ||
| print(data.metadata.title) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want a print within the test here? |
||
| if data.metadata.title is not None: | ||
| assert data.abscissae.unique_id.startswith(data.metadata.title) | ||
| assert data.abscissae.unique_id == expected | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line required?