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

Whenever I edit a file Revise thinks I changed a struct definition #772

Closed
ejmeitz opened this issue Nov 7, 2023 · 3 comments
Closed

Whenever I edit a file Revise thinks I changed a struct definition #772

ejmeitz opened this issue Nov 7, 2023 · 3 comments

Comments

@ejmeitz
Copy link

ejmeitz commented Nov 7, 2023

I have the following class defined in a file:

struct ConstraintCluster{N}
    constraints::SVector{N,<:Constraint}
end

whenever I edit anything in this file Revise throws and error saying that I modified this struct and force me to restart the Julia instance. I have no idea why this is happening and its making development extremely painful. If anyone could help me diagnose the issue that would be great.

Error:

┌ Error: Failed to revise D:\Code\repos\Molly.jl\src\constraints\constraints.jl
│ exception =
│ invalid redefinition of type ConstraintCluster
│ Stacktrace:
│ [1] top-level scope
│ @ none:0
│ Revise evaluation error at D:\Code\repos\Molly.jl\none:0

└ @ Revise C:\Users\ejmei.julia\packages\Revise\NiAIj\src\packagedef.jl:723

@thofma
Copy link

thofma commented Nov 8, 2023

Dup of #734

P.S.: I am doing ]add Revise@3.4.0 to work around this issue.

@timholy
Copy link
Owner

timholy commented Dec 31, 2023

I can't test this explicit issue (what is Constraint?), but since it's a dup of #734 (which I cannot reproduce), I'll close this.

What I really, really need is a self-contained MWE that replicates the issue.

@timholy timholy closed this as completed Dec 31, 2023
@ejmeitz
Copy link
Author

ejmeitz commented Jan 11, 2024

I don't really have time to set-up a test package and verify that this is a MWE but here is the contents of the file up to the problematic class definition (ConstraintCluster). If I modify any of the code that exists below this struct definition Revise breaks. Sorry I don't have time to test but maybe there's something that jumps out to you from this.

export
    DistanceConstraint, 
    NoSystemConstraints,
    n_dof


"""
Supertype for all constraint algorithms.
"""
abstract type ConstraintAlgorithm end
abstract type PositionConstraintAlgorithm <: ConstraintAlgorithm end
abstract type PositionAndVelocityConstraintAlgorithm <: ConstraintAlgorithm end

ConstrainsPositions = Union{PositionConstraintAlgorithm, PositionAndVelocityConstraintAlgorithm}

"""
Placeholder struct for [`System`](@ref) constructor when the system does not require constraints.
An example of a constraint algorithm is [`SHAKE`](@ref).
"""
struct NoSystemConstraints <: ConstraintAlgorithm end


"""
Supertype for all types of constraint.
"""
abstract type Constraint end

"""
Constraint between two atoms that maintains the distance between the two atoms.
# Arguments
- `atom_idxs::SVector{Int}` : The indices of atoms in the system participating in this constraint
- `dist::D` : Euclidean distance between the two atoms.
"""
struct DistanceConstraint{D} <: Constraint
    atom_idxs::SVector{2,<:Integer}
    dist::D
end

"""
Atoms in a cluster do not participate in any other constraints outside of that cluster.
"Small" clusters contain at most 4 bonds between 2,3,4 or 5 atoms around one central atom.
Small clusters include: 1 bond, 2 bonds, 1 angle, 3 bonds, 1 bond 1 angle, 4 bonds
Note that an angle constraints will be implemented as 3 distance constraints. These constraints
use special methods that improve computational performance. Any constraint not listed above
will come at a performance penatly.
"""
struct ConstraintCluster{N}
    constraints::SVector{N,<:Constraint}
end

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

No branches or pull requests

3 participants