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

Bug in braid creation when some strands are equal. #2

Closed
jeanluct opened this issue Nov 27, 2014 · 3 comments
Closed

Bug in braid creation when some strands are equal. #2

jeanluct opened this issue Nov 27, 2014 · 3 comments

Comments

@jeanluct
Copy link
Owner

Bug discovered while writing taffy_xrods.m (talk), found that if z is zero get 'somehow there are still coincident coordinates' error.

The problem is that the code only looks for coincident particles in one coordinate (along the projection line). If particles are coincident in both coordinates, need to issue an error since it's impossible to define a braid. Adding noise, as is done currently, will give a braid, but it should't.

Here's a first code that should return a more proper error:

#!matlab

>> braid(zeros(10,2,4))

This returns the error

#!matlab

Warning: Coincident coordinates... adding a bit of noise. 
> In @braid/private/color_braiding at 50
  In braid.braid>braid.braid at 126 
Error using color_braiding (line 95)
Somehow there are still coincident trajectories...

Error in braidlab.braid (line 126)
        br = color_braiding(b,1:size(b,1),secnd);

But the error "Somehow there are still coincident trajectories..." should never actually happen. It is a safety check.

The second, related bug is when two strands are equal:

#!matlab

npts = 10; n = 4; XY = zeros(npts,2,n);
% Create constant braid (fixed strands).
for i = 1:n, XY(:,:,i) = i*ones(npts,2); end
XY(:,:,1) = XY(:,:,2); % Make two strands equals.
% Bug: nontrivial braid returned, since routine adds noise.  Should
% return error instead.
braid(XY)

This returns

#!matlab

Warning: Coincident coordinates... adding a bit of noise. 
> In @braid/private/color_braiding at 50
  In braid.braid>braid.braid at 126
  In bug_color_braiding_coincident at 9 

ans = 

< -1  1 -1  1  1 -1 -1 >

The braid will vary, since it is random. The warning is appropriate, since the coordinates are indeed coincident, but it should be an error about coincident particles.

This should be easy to fix: before even computing anything else, check if any coordinates are coincident. Maybe this is a bit difficult to do fast?

@jeanluct
Copy link
Owner Author

From Michael Allshouse on 2013-01-20 19:55:12+00:00

(Reply via mr...@mit.edu):

Can you send along the code/trajectories you are using so I can do some
testing to see what is going on in the code.

Michael

On Sun, Jan 20, 2013 at 9:47 AM, Jean-Luc Thiffeault <
issues-reply@bitbucket.org> wrote:

@jeanluct
Copy link
Owner Author

From Jean-Luc Thiffeault on 2013-01-20 21:33:42+00:00

Check for coincident particles in color_braiding. Resolves issue #2.

→ <<cset 8756c2a5b427>>

@jeanluct
Copy link
Owner Author

From Jean-Luc Thiffeault on 2013-01-20 21:35:35+00:00

Ok, I've just checked in a fix (8756c2a). Check for coincident particles, not just coincident coordinates. Now both code snippets above return

#!matlab

Error using color_braiding (line 48)
Coincident particles: braid not defined.

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

1 participant