-
Notifications
You must be signed in to change notification settings - Fork 19
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
simplify types #23
simplify types #23
Conversation
Signed-off-by: Rachel Kurchin <[email protected]>
…mmit, put them back Signed-off-by: Rachel Kurchin <[email protected]>
f7d0a94
to
a615a79
Compare
Codecov Report
@@ Coverage Diff @@
## master #23 +/- ##
===========================================
+ Coverage 0.00% 47.36% +47.36%
===========================================
Files 4 4
Lines 97 76 -21
===========================================
+ Hits 0 36 +36
+ Misses 97 40 -57
Continue to review full report at Codecov.
|
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Okay, there we have it! Personally, I feel quite good things up through fede982, but I'm on the fence about also removing I've also made some notes to myself about other potential small tweaks, the applicability of some of which will depend on how many commits in this we keep, so I'll do them after we decide rather than cluttering up the history here. |
This reverts commit 7a32c77.
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
… file that somehow came back Signed-off-by: Rachel Kurchin <[email protected]>
…fix return types of other singular functions, rename ET parameter to S, add default size dispatch since firstindex default to a scalar Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
be999c7
to
9f9743f
Compare
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, readme and tests are nice too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add indexing versions of position
and species
for the concrete implementations.
Signed-off-by: Rachel Kurchin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, but generally LGTM.
src/interface.jl
Outdated
Base.getindex(::AbstractSystem, ::Int) = error("Implement me") | ||
Base.size(::AbstractSystem) = error("Implement me") | ||
Base.length(::AbstractSystem) = error("Implement me") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only put the error("Implement me")
here during development. I guess with the readme making this clear to be implemented we should drop these stubs completely (and let Julia throw an error for us). Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see it both ways. On the one hand, it's redundant to throw an error "manually" here, but on the other, having all the required functions in the interface.jl
file does make it a useful reference for someone who wants to sit down and implement the interface...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would lean towards not putting the errors here, and perhaps adding a comment if we want the information to be in that file. See the first section of https://www.oxinabox.net/2020/04/19/Julia-Antipatterns.html for some discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @jgreener64 (and oxinabox) on that point very much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended to be implemented now during interface development? Then I think an error message is fine because it will flag that this is supposed to be implemented but isn't. But if it is an interface function that a user should implement, then I don't think the error message should be there.
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
Signed-off-by: Rachel Kurchin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good I think, just left a few fairly trivial comments.
struct FlexibleSystem{D,ET<:AbstractElement,AT<:AbstractParticle{ET}} <: AbstractSystem{D,ET,AT} | ||
box::SVector{D,<:SVector{D,<:Unitful.Length}} | ||
struct FlexibleSystem{D,S,L<:Unitful.Length,AT} <: AbstractSystem{D,S} | ||
box::SVector{D,<:SVector{D,L}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"morally" it seems to me that box
and boundary_conditions
should be tuples of ... rather than SVectors. But I don't have too strong a view on that.
end | ||
# convenience constructor where we don't have to preconstruct all the static stuff... | ||
function FlexibleSystem( | ||
box::Vector{Vector{L}}, | ||
box::Vector{<:AbstractVector{L}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why type this? the box could be provided as a Vector, AbstractVector, Tuple, .... same with bc and particles below. This is a convenience constructor no? I would then just make it convenient to construct the thing and enforce such strict typing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would probably be better. I was having trouble figuring out how to write it in a general enough way...will file an issue for this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I did it in JuLIP was to have a conversion interface e.g.
_convert_positions(X::Vector) = X
_convert_positions(X::AbstractVector) = collect(X)
_convert_positions(X::AbstractMatrix) = # convert into vector of SVectors
_convert_bc(bc::NTuple{3, Bool}) = bc
_convert_bc(bc::AbstractVector) = tuple(Bool.(bc)...)
and so forth. So this means that ANY sensible input will be automatically converted into the format needed internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will repost in the issue.
print(io, "StaticAtom: $(a.element.symbol)") | ||
end | ||
|
||
const AbstractAtomicSystem{D} = AbstractSystem{D,Element} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have time to look for the definition of AbstractSystem, so I'll add this comment here: I can sort of see why one might want to make the dimension a type parameter, though I'm not entirely sure where this is needed?
But does the element type really have to be a type parameter in the abstract type? What is the use case?
# | ||
# Implementation of AtomsBase interface in a struct-of-arrays style. | ||
# | ||
|
||
using StaticArrays | ||
|
||
export FastSystem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the FlexibleSystem
and FastSystem
terms a bit odd. Isn't it a bit context specific when they are fast / slow / convenient / inconvenient? Why not simply call them SystemSOA
and SystemAOS
then it is clear what they are. There could be a convenience constructor that can construct either, depending on a flag, with default probable being the AOS but I'm not sure about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 hahaha that's what they were originally called and I changed them at @mfherbst's suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - sorry, that's what I get for not paying attention. Just don't have the time I'm afraid. I can't even quite put my finger on why I don't like those terms. I guess I prefer technically precise terms? Especially with an interface function a user will never have to worry about it until they know what they are doing and then they'll just go and read the docs?
# | ||
Return the velocity of a particle `p`. | ||
""" | ||
velocity(p)::Union{Unitful.Velocity,Missing} = missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could there be also a momentum
function that call velocity
and mass
(and simply fails when there is no mass?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly...do we think that needs to be at this top level though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is so generic and universal that I think there is no harm introducing it? I don't have a strong view - you decide what you think is best.
@@ -81,82 +38,82 @@ struct DirichletZero <: BoundaryCondition end # Dirichlet zero boundary (i.e. m | |||
struct Periodic <: BoundaryCondition end # Periodic BCs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this have a flag true/false
? Since the bc is implemented as a vector (or tuple) of BCs, you probably want each element of that vector to be e.g. a Periodic()
. But now suppose you want a system that is open in the x, y direction and periodic in the z direction (e.g. dislocations). Then you need a different type Open()
and you have a type instability. But with Periodic(true), Periodic(false)
there is no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't really see how one needs anything other than a boolean here? I can see many other options such as reflecting, embedding, etc but those are not really relevant for the particle system per se, but rather for fields in the background, or for the embedding one would need additional structures anyhow into which to embed the System...
But I don't see any harm in keeping the Periodic
type.
|
||
A `D`-dimensional system comprised of particles identified by type `S`. | ||
""" | ||
abstract type AbstractSystem{D,S} end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - there it is now. So if I want a particle system that has multiple element types then I can't have that? I agree that in 99% of the cases I probably don't want that because it will likely give me type instabilities. Just making sure this is really important enough to sacrifice the flexibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the group of us has decent consensus that these belong here so I'm going to leave them in when I merge this, but I'll open an issue for further discussion of this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/interface.jl
Outdated
Base.getindex(::AbstractSystem, ::Int) = error("Implement me") | ||
Base.size(::AbstractSystem) = error("Implement me") | ||
Base.length(::AbstractSystem) = error("Implement me") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended to be implemented now during interface development? Then I think an error message is fine because it will flag that this is supposed to be implemented but isn't. But if it is an interface function that a user should implement, then I don't think the error message should be there.
…and bounding_box for now since there are type annotations... Signed-off-by: Rachel Kurchin <[email protected]>
Starting to work on this. Will try to commit-by-commit remove more things (and only ever committing a working state) so if we decide we want to go only part of the way, it's easy to just revert. This present commit removes only the
AbstractElement
type, which, now that I've done it, seems like unambiguously a good idea and I don't think it was adding much of anything.