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

Add functionality to directly convert a stockflow acset -> stockflow amr and stockflow amr -> stockflow acset #41

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

nanglo123
Copy link

No description provided.

if link['source'] in stocks_mapping:
link_dict = {'_id': link_id}
link_dict['s'] = stocks_mapping[link['source']]
link_dict['t'] = idx
Copy link
Author

Choose a reason for hiding this comment

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

I originally set link_dict['t'] = link['target'][4:] to set the 't' field of the output acset to the flow id defined by the input amr link's 'target' field.

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f966b18) 87.46% compared to head (c4c8423) 87.46%.

❗ Current head c4c8423 differs from pull request most recent head aaab268. Consider uploading reports for the commit aaab268 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #41   +/-   ##
=======================================
  Coverage   87.46%   87.46%           
=======================================
  Files           6        6           
  Lines         327      327           
  Branches       54       54           
=======================================
  Hits          286      286           
  Misses         36       36           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/acsets/amr_conversion/stockflow.py Outdated Show resolved Hide resolved
params_stock_flow_map[flow_id] = []

params_stock_flow_map[flow_id].extend(
re.findall(r'p\.([^()*+-/ ]+)', flow['ϕf']))
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this assume that a parameter always starts with p.?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, we assumed that was the case.

params_stock_flow_map[flow_id].extend(
re.findall(r'p\.([^()*+-/ ]+)', flow['ϕf']))
params_stock_flow_map[flow_id].extend(
re.findall(r'u\.([^()*+-/ ]+)', flow['ϕf']))
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this assume that a state always starts with u.?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, we assumed that was the case.

for parameter in amr['semantics']['ode']['parameters']:
if parameter['id'].startswith('p_'):
symbols[parameter['id'][2:]] = sympy.Symbol(
'p.' + parameter['id'][2:])
Copy link
Member

Choose a reason for hiding this comment

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

The whole p. and u. thing are implementation details in julia that the state variable of a dynamical system is called u and the parameters are p. Do we want to cannonicalize that in the standard?

Copy link
Contributor

Choose a reason for hiding this comment

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

We thought that u. and p. are required/expected in your ACSet implementation. So we parse them when reading in an ACSet and generate them when outputting an ACSet. If that's not the case, we can remove the custom handling of these.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jpfairbanks could you confirm if the u. and p. are expected in the ACSet or if we should remove this assumption?

@bgyori
Copy link
Contributor

bgyori commented Jan 19, 2024

@jpfairbanks, with these latest commits, @nanglo123 removed explicit handling of u. and p. so any names will work. Anything else to do on this PR?

@bgyori
Copy link
Contributor

bgyori commented Jan 31, 2024

We don't have merge permissions here so whoever does, please merge!

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.

3 participants