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

Vertex name changes #346

Merged
merged 24 commits into from
Jun 14, 2021
Merged

Conversation

andrewtarzia
Copy link
Collaborator

@andrewtarzia andrewtarzia commented Jun 4, 2021

Related Issues: #344
Requested Reviewers: @lukasturcani

This PR makes all vertex classes (except for Cage and Cof base classes) publicly accessible by simply changing class names. Also removes designation of Cage and Cof types within name, as that is designated by the access point. (sorry if my terminology here is wrong). An example of accessing the vertices was added.

The following example shows that this works.

import stk

vertex = stk.Vertex(0, [0, 0, 0])
print(vertex)
try:
    vertex = stk.LinearVertex(1, [0, 0, 0])
    print(vertex, 'should not show')
except AttributeError:
    print('success on fail')
vertex = stk.cage.LinearVertex(1, [0, 0, 0])
print(vertex)
vertex = stk.cage.vertices.LinearVertex(1, [0, 0, 0])
print(vertex)
vertex = stk.cage.OnePlusOneVertex(1, [0, 0, 0], 0)
print(vertex)
vertex = stk.polymer.linear.TailVertex(0, [0, 0, 0], False)
print(vertex)
vertex = stk.cof.NonLinearVertex(0, [0, 0, 0], False)
print(vertex)
vertex = stk.host_guest.HostVertex(0, [0, 0, 0])
print(vertex)
vertex = stk.macrocycle.CycleVertex(0, [0, 0, 0], False, 0)
print(vertex)
vertex = stk.metal_complex.MonoDentateLigandVertex(0, [0, 0, 0])
print(vertex)
vertex = stk.rotaxane.AxleVertex(0, [0, 0, 0])
print(vertex)
try:
    vertex = stk.AxleVertex(1, [0, 0, 0])
    print(vertex, 'should not show')
except AttributeError:
    print('success on fail')
try:
    vertex = stk.HostVertex(1, [0, 0, 0])
    print(vertex, 'should not show')
except AttributeError:
    print('success on fail')

docs/source/basic_examples.rst Outdated Show resolved Hide resolved
vertices._LinearCageVertex.init_at_center,
vertices._NonLinearCageVertex.init_at_center,
vertices._UnaligningVertex.init_at_center,
vertices.LinearVertex.init_at_center,
Copy link
Owner

Choose a reason for hiding this comment

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

now that the vertices are public, I think they should be accessed in tests by the public API, not by this "unofficial" API. so stk.cage.LinearVertex not vertices.LinearVertex.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree and have replaced all vertices = stk.cage.vertices (for example) with direct calls to stk.cage.VERTEXNAME.

@lukasturcani
Copy link
Owner

I also have some concerns about exposing all of the vertex classes. I'm not against it, but I guess I would like to know what the arguments for and against this are? For example, what is the cost / benefit of exposing stk.host_guest.HostVertex?

@andrewtarzia
Copy link
Collaborator Author

andrewtarzia commented Jun 14, 2021

I see your concern and my main argument is how do you decide which to make public and which not to? There is no technical reason I see for that other than the desire to minimise access until needed.

For example, why make the cage vertex accessible, but not the host vertex? A user may be just as inclined to use that in their own code as an stk.cage.LinearVertex

@lukasturcani
Copy link
Owner

I guess with cages the extensibility argument is a bit easier. The amount of cage topologies we have already, means that we have a pretty good understanding of how this vertex can be used to easily build new topology graphs. With something like host guest, we have experience in using it in 1 topology graph. so the reusability of it a lot less well understood. I guess I'm not convinced that just because a user wants to use that vertex, that I want to allow them to, because doing so would remove my flexibility to modify it in the future.

Having said that, I think we can expose them because removing them can be easy for the users to fix (just copy paste the code into their own scripts). So I think it is a worthwhile experiment.

class NewCageTopology(stk.cage.Cage):

_vertex_prototypes = (
stk.cage.LinearVertex(0, [0, 0, 0]),
Copy link
Owner

Choose a reason for hiding this comment

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

Also, I think there is a type error here. the position should be a tuple of float so (0., 0., 0.)

https://stk.readthedocs.io/en/stable/stk.molecular.topology_graphs.topology_graph.vertex.html#stk.molecular.topology_graphs.topology_graph.vertex.Vertex

I realize that this type error exists in the actual code, but I don't want you to change that. This PR just needs to make sure that users get a fully correct example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@lukasturcani lukasturcani merged commit 8155ed4 into lukasturcani:master Jun 14, 2021
@andrewtarzia andrewtarzia deleted the vertex_name_changes branch June 14, 2021 21:03
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.

None yet

2 participants