Skip to content

Context-dependent Descriptors + Electrolyte Rendering - #81

Merged
saraedum merged 25 commits into
echemdb:mainfrom
saraedum:unit-value
Dec 21, 2021
Merged

Context-dependent Descriptors + Electrolyte Rendering#81
saraedum merged 25 commits into
echemdb:mainfrom
saraedum:unit-value

Conversation

@saraedum

@saraedum saraedum commented Dec 1, 2021

Copy link
Copy Markdown
Member

Fixes #70.

This PR introduces a descriptor factory that can be used to add custom features to descriptors. Here a QuantityDescriptor that adds a astropy .quantity when there are exactly unit and value as keys in the metadata.

This also implements proper rendering of such quantities and rendering of the electrolyte through the | render filter. Both are rendered from MarkDown templates, see quantity.md and electrolyte.md.

Finally, this fixes some bugs in the data. Namely, it replaces M with mol / l which astropy understands.

Sorry for doing several things at once in the same PR.

Dependencies

@saraedum saraedum changed the title A demo of adapting descriptors depending on the context Adapting descriptors depending on the context Dec 1, 2021
Comment thread echemdb/data/cv/descriptor.py Outdated
import yaml
return yaml.dump(self._descriptor)

class UnitValueDescriptor(GenericDescriptor):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is new. A descriptor wrapper for descriptors that have value and unit.

Comment thread templates/unit_value.md Outdated
Functionally, these are the same, but morally these are quite different.
In particular, the pages will have a frontmatter eventually, while the
components won't.
run doctests with `pytest -n auto --doctest-plus --doctest-modules
echemdb/` to skip all tests that download the echemdb and run the tests
in parallel.
Comment thread .github/workflows/test.yml
@saraedum
saraedum marked this pull request as ready for review December 5, 2021 08:09
@saraedum saraedum changed the title Adapting descriptors depending on the context Context-dependent Descriptors + Electrolyte Rendering Dec 5, 2021
@saraedum
saraedum force-pushed the unit-value branch 3 times, most recently from b8bd77f to e777079 Compare December 7, 2021 18:51
@saraedum
saraedum force-pushed the unit-value branch 2 times, most recently from 4277b7d to 57a7dba Compare December 7, 2021 21:39
Comment thread echemdb/website/macros/render.py Outdated

@DunklesArchipel DunklesArchipel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terrific!

Co-authored-by: Albert Engstfeld <39313137+DunklesArchipel@users.noreply.github.com>
@saraedum
saraedum enabled auto-merge December 21, 2021 03:09
Comment thread echemdb/data/cv/descriptor.py Outdated
@saraedum
saraedum disabled auto-merge December 21, 2021 16:17
@saraedum
saraedum enabled auto-merge December 21, 2021 16:29
@saraedum
saraedum merged commit fad0039 into echemdb:main Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create 'entry.unit_value' from units and values in the yaml file

2 participants