Skip to content
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

Stop adding units to emitted data keys #166

Open
U8NWXD opened this issue Feb 22, 2022 · 0 comments
Open

Stop adding units to emitted data keys #166

U8NWXD opened this issue Feb 22, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@U8NWXD
Copy link
Member

U8NWXD commented Feb 22, 2022

Currently, when we emit data that has a unit in the state hierarchy and format it as a timeseries, we put the unit into the key and strip the units from the value. For example, we might get:

{
    'external': {
        ('antibiotic', 'millimolar'): [1, 2, 3],
    }
}

This is not ideal. Instead, our plotting functions should know how to handle Quantity objects.

Here's where we do the unit conversion:

if isinstance(value, Quantity):
unit_key = (key, str(value.units))
if unit_key not in timeseries:
timeseries[unit_key] = []
timeseries[unit_key].append(value.magnitude)

And here's a trace of the calls in emitter.py that lead to the code above:

  • vivarium.library.dict_utils.value_in_embedded_dict()
  • vivarium.core.emitter.timeseries_from_data()
  • vivarium.core.emitter.Emitter.get_timeseries()

Note that addressing this will probably be a breaking API change since doing so will change our output format.

@U8NWXD U8NWXD added the enhancement New feature or request label Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant