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
implement a Field class similar to fields in Django, Marshmallow and DRF #68
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d3f8315
implement a Field class similar to fields in Django, Marshmallow and DRF
mikofski aba70dd
refactor as Parameter class instead of Field
mikofski 9950336
fix data reader tests with new 'extra' key
mikofski d95b4f2
update registries, remove __init__, add docstrings for metadata
mikofski 80fc320
fix xlrd reader and test to use DataParameter
mikofski 48654e0
add cached file to be used in testing
mikofski dad883b
add meta attr to formulas and formula importer base class
mikofski 4694f16
separate formulas, use Meta and FormulaParameter
mikofski e3c0483
move formulas_importer to class Meta
mikofski 7a57ea8
update test_sim with Parameters
mikofski 850c6a8
make simulation output folders recursively
mikofski f063e42
fix sim ID maker - no colon in filename
mikofski 0911643
add settings argument to simulations
mikofski 47ee88f
use OutputParameter
mikofski 50b94d2
really heinous hacks to close #9
mikofski f9b396e
remove comment with link to Django snippet 1040
mikofski File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Testing field subclasses in different layers. | ||
""" | ||
|
||
from carousel.core import Field, UREG | ||
from carousel.core.data_sources import DataSource | ||
from carousel.contrib.readers import ArgumentReader | ||
|
||
|
||
class VelocityData(DataSource): | ||
data_reader = ArgumentReader | ||
data_cache_enabled = False | ||
Field._attrs = ['units', 'isconstant', 'uncertainty', 'argpos'] | ||
distance = Field(units='m', isconstant=True, uncertainty=0.01, argpos=0) | ||
elapsed_time = Field(units='s', isconstant=True, uncertainty=0.01, argpos=1) | ||
|
||
def __prepare_data__(self): | ||
pass | ||
|
||
|
||
def test_data_with_fields(): | ||
v = VelocityData(distance=96540, elapsed_time=3600) | ||
assert isinstance(v, DataSource) | ||
assert v['distance'] == 96540 * UREG.m | ||
assert v['distance'] == 3600 * UREG.s | ||
return v | ||
|
||
|
||
if __name__ == '__main__': | ||
v = test_data_with_fields() |
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.
so here 'my test field' will be assigned to the 'units' attribute first? But then replaced by 'W/m**2' it looks like, is that correct?