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

Support for simulation initials, params as DataFrames #416

Merged
merged 3 commits into from Feb 20, 2019

Conversation

Projects
None yet
3 participants
@alubbock
Copy link
Member

commented Feb 8, 2019

Add support for supplying simulation initial conditions and parameter
values as pandas DataFrames. Previously this was handled by implict
conversion to numpy array, which might lose the column order (i.e.,
initials species or parameters get swapped).

Implicit conversion or simulation initials or param values from anything
other than a list is now disabled, meaning that users must now supply
a DataFrame, numpy array, or list for initials and param_values.

Fixes: #415

Support for simulation initials, params as DataFrames
Add support for supplying simulation initial conditions and parameter
values as pandas DataFrames. Previously this was handled by implict
conversion to numpy array, which might lose the column order (i.e.,
initials species or parameters get swapped).

Implicit conversion from anything other than a list is now disabled,
meaning that users must now supply a DataFrame, numpy array, or list
for initials and param_values.
@coveralls

This comment has been minimized.

Copy link

commented Feb 8, 2019

Coverage Status

Coverage increased (+0.05%) to 78.93% when pulling ce0401a on alubbock:sim_initials_params_pandas into 75355a5 on pysb:master.

@jmuhlich
Copy link
Member

left a comment

Good idea overall, some of the logic is just getting too hard to follow without a minor refactoring.

@@ -356,6 +360,11 @@ def _process_incoming_initials(self, new_initials):
'values'.format(cplx_pat))
else:
if not isinstance(new_initials, np.ndarray):
if not isinstance(new_initials, list):

This comment has been minimized.

Copy link
@jmuhlich

jmuhlich Feb 19, 2019

Member

Could this nested-not bit be refactored? Maybe normalize list->ndarray up top where DataFrame is normalized to dict, then this whole else can become elif isinstance(new_initials, np.ndarray) and the ValueError can be moved to a final else at the bottom.

@@ -469,6 +483,11 @@ def _process_incoming_params(self, new_params):
"must be equal length")
else:
if not isinstance(new_params, np.ndarray):
if not isinstance(new_params, list):

This comment has been minimized.

Copy link
@jmuhlich

jmuhlich Feb 19, 2019

Member

This would need the same treatment as _process_incoming_initials above.

@alubbock

This comment has been minimized.

Copy link
Member Author

commented Feb 19, 2019

Thanks, good suggestions again. Implemented.

@alubbock alubbock merged commit 967b986 into pysb:master Feb 20, 2019

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.4%) to 78.438%
Details

@alubbock alubbock deleted the alubbock:sim_initials_params_pandas branch Feb 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.