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

time_vector method added. Should Fix #316 #318

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Peter230655
Copy link
Contributor

Added identical time_vector method in Problem and in ConstraintCollocator. Should fix issue #316

@moorepants
Copy link
Member

This needs to resolve conflicts.

@@ -686,6 +686,35 @@ def parse_free(self, free):

return parse_free(free, n, q, N, variable_duration)

def time_vector(self, t0=0.0, solution=None):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def time_vector(self, t0=0.0, solution=None):
def time_vector(self, solution=None, start_time=0.0):

I think people will rarely use the start time kwarg, so make it second. And rename to have more informative variable name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I now wonder, whether we should give t0 at all: I would not know how to tell opty not to start at t= = 0.0

Copy link
Member

Choose a reason for hiding this comment

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

We can leave it off and add it later if we ever think we need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can leave it off and add it later if we ever think we need it.

I left it in. Do you want me to remove it?

A numpy num_collocation_nodes-array of time instances.

"""
if isinstance(self.collocator.node_time_interval, sm.Symbol):
Copy link
Member

Choose a reason for hiding this comment

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

There is a flag self.collocator._variable_duration that should be used for this check.

msg = 'Solution vector must be provided for variable duration.'
raise ValueError(msg)
else:
return np.arange(t0, t0+self.collocator.num_collocation_nodes*
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return np.arange(t0, t0+self.collocator.num_collocation_nodes*
return np.arange(t0, t0 + self.collocator.num_collocation_nodes*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When do you put a space and when do you not put a space?
I thought in signatures one does not put a space?
Of course I will correct it.

Copy link
Member

Choose a reason for hiding this comment

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

PEP8 has the guidelines.

solution[-1], solution[-1])

else:
return np.arange(t0, t0+self.collocator.num_collocation_nodes*
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return np.arange(t0, t0+self.collocator.num_collocation_nodes*
return np.arange(t0, t0 + self.collocator.num_collocation_nodes*

@moorepants
Copy link
Member

This needs a unit test.

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.

2 participants