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

Scan_P debug #10

Open
Twenkid opened this Issue Sep 21, 2018 · 56 comments

Comments

Projects
None yet
2 participants
@Twenkid
Collaborator

Twenkid commented Sep 21, 2018

The older thread got too long.

What's the current specific bug?

Sorry these day I've been a bit distracted, a bit busy to collect big enough chunk of focus to say something meaningful. Regarding CogAlg I was thinking about how exactly to bite the problem of trackingl, either to start manually or immediately to approach automation which includes code analysis and would be ore general and easier for application for the other modules. I may start manual for some variables and thrn move to semi- automatic with an editor. I was also checking Python stuff.

That approach with locals() and exec could work persistently only in Python2, in 3 they don't allow write-access to the system dictionary of local vars outside of the official program flow, perhaps for security reasons and due to changes in the implementation of exec, which has turned from a special statement to a function. Another explicit dictionary of the local variables has to be used, like with the approach of sending arguments as a dictionary, or the vars to be set explicitly in normal code, if I use something like that I'd generate it.

I know you don't need that now, but I opened that topic and needed to clarify this.

def scan_P_(x, P, P_, _buff_, _P_, frame): # P scans shared-x-coordinate _Ps in _P_, forms overlaps

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 22, 2018

Owner
Owner

boris-kz commented Sep 22, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 23, 2018

Collaborator

OK, let's try to talk next week. In the meantime I'll try to spend some time observing the code carefully through its control flow and reflect about it and take some notes on the assignments and how the patterns are nested and when, also how functions are nested while calling. Both should be automated when I have enough focus.

I guess I'll be more concentrated once real rich feedback starts to come with recognition of real patterns and more material progress, as well as earning big enough prizes on a regular basis (I know it depends on the contribution) - both would suggest my brain that it shouldn't waste more time with the other unproductive nonsense, or at least to spend less time, depending on the results. :)

Are going to do something about it? You need to cultivate focus, there is
no way around it.

Maybe yes. Well, if you mean to focus only on your project 24H a day - no... :) That's too much. Especially in its current state.

Yes, I have to be able to follow the code "manually", step by step, and to see the relations. The tracking would track everything, code in general, assignments, how variables are transferred, where patterns are created, how they map to the input, ... Something like "Data mining for/with code".
...

BTW, I understand one reason why you stick to the raccoon, besides it was default in spectral clustering and for keeping a stable frame for the errors.

It has areas with low gradient, others with high; smooth leaves and sharp fur and mustaches, circular shapes of the eyes, thin contrasting lines etc.

(However any complex/visually rich image is supposed to have these.)

With the automation and automated testing it'd be useful if a set of simplified small images are applied, for debug and educational purposes, so that we can see how specific types of input are processed without a huge amount of varying patterns which complicate the output.

One with single contrasting pixel, with a short horizontal line - same color, gradient+-; vertical line, diagonal lines, different shapes etc. The whole image with dots and empty spaces, short horizontal lines and empty spaces, gradients left-to right etc.

Collaborator

Twenkid commented Sep 23, 2018

OK, let's try to talk next week. In the meantime I'll try to spend some time observing the code carefully through its control flow and reflect about it and take some notes on the assignments and how the patterns are nested and when, also how functions are nested while calling. Both should be automated when I have enough focus.

I guess I'll be more concentrated once real rich feedback starts to come with recognition of real patterns and more material progress, as well as earning big enough prizes on a regular basis (I know it depends on the contribution) - both would suggest my brain that it shouldn't waste more time with the other unproductive nonsense, or at least to spend less time, depending on the results. :)

Are going to do something about it? You need to cultivate focus, there is
no way around it.

Maybe yes. Well, if you mean to focus only on your project 24H a day - no... :) That's too much. Especially in its current state.

Yes, I have to be able to follow the code "manually", step by step, and to see the relations. The tracking would track everything, code in general, assignments, how variables are transferred, where patterns are created, how they map to the input, ... Something like "Data mining for/with code".
...

BTW, I understand one reason why you stick to the raccoon, besides it was default in spectral clustering and for keeping a stable frame for the errors.

It has areas with low gradient, others with high; smooth leaves and sharp fur and mustaches, circular shapes of the eyes, thin contrasting lines etc.

(However any complex/visually rich image is supposed to have these.)

With the automation and automated testing it'd be useful if a set of simplified small images are applied, for debug and educational purposes, so that we can see how specific types of input are processed without a huge amount of varying patterns which complicate the output.

One with single contrasting pixel, with a short horizontal line - same color, gradient+-; vertical line, diagonal lines, different shapes etc. The whole image with dots and empty spaces, short horizontal lines and empty spaces, gradients left-to right etc.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 23, 2018

Owner
Owner

boris-kz commented Sep 23, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 23, 2018

Collaborator
Collaborator

Twenkid commented Sep 23, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 23, 2018

Collaborator

One Pycharm's debugger function that may be useful:

View as array (on NP arrays, ndarray).
With slicing.

https://www.jetbrains.com/help/pycharm/debug-tool-window-variables.html
image[80:90, 20:30]
slice

Collaborator

Twenkid commented Sep 23, 2018

One Pycharm's debugger function that may be useful:

View as array (on NP arrays, ndarray).
With slicing.

https://www.jetbrains.com/help/pycharm/debug-tool-window-variables.html
image[80:90, 20:30]
slice

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 24, 2018

Owner
Owner

boris-kz commented Sep 24, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 24, 2018

Collaborator

I tried array view but my tuples are too complex and uneven, regular "variables" is better.

Well, then I see you actually do agree that visualisation-tracking-everything tools would be helpful.

Most of the code is designed from the first principles.

OK, one day I'll "bite" it and it would be easier.

The purpose is described in the comments, and we can always talk.

OK

I can pay you more than enough to live on Todor, for a lifetime.
But you have to get into "rational design".

I agree I have to make changes in my life design in order to direct the change.

I appreciate the pension offer, too, but let's hope CogAlg would work so I won't have to "live on" with it.

However, as of the "rational design", actually the Numpy fancy indexing thread was created because of unrational decision and wrong design in another computer vision related project I've been working on lately and which has feedback and results, a visual effects one.

As of being rational in general, practically and financially AGI is not... Especially back in the 2000s, it was "insane" for the "normal people". To me it's one of the many financially-wise terribly wrong decisions, but I wasn't interested for financial reasons.

As a developer and researcher I could be in the Valley since late 2000s and earning "more than enough" etc.

Collaborator

Twenkid commented Sep 24, 2018

I tried array view but my tuples are too complex and uneven, regular "variables" is better.

Well, then I see you actually do agree that visualisation-tracking-everything tools would be helpful.

Most of the code is designed from the first principles.

OK, one day I'll "bite" it and it would be easier.

The purpose is described in the comments, and we can always talk.

OK

I can pay you more than enough to live on Todor, for a lifetime.
But you have to get into "rational design".

I agree I have to make changes in my life design in order to direct the change.

I appreciate the pension offer, too, but let's hope CogAlg would work so I won't have to "live on" with it.

However, as of the "rational design", actually the Numpy fancy indexing thread was created because of unrational decision and wrong design in another computer vision related project I've been working on lately and which has feedback and results, a visual effects one.

As of being rational in general, practically and financially AGI is not... Especially back in the 2000s, it was "insane" for the "normal people". To me it's one of the many financially-wise terribly wrong decisions, but I wasn't interested for financial reasons.

As a developer and researcher I could be in the Valley since late 2000s and earning "more than enough" etc.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 25, 2018

Owner
Owner

boris-kz commented Sep 25, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 25, 2018

Collaborator
Collaborator

Twenkid commented Sep 25, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 25, 2018

Owner
Owner

boris-kz commented Sep 25, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 26, 2018

Collaborator
Collaborator

Twenkid commented Sep 26, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 27, 2018

Owner
Owner

boris-kz commented Sep 27, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 27, 2018

Collaborator
Collaborator

Twenkid commented Sep 27, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 27, 2018

Owner
Owner

boris-kz commented Sep 27, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 27, 2018

Collaborator
Collaborator

Twenkid commented Sep 27, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 27, 2018

Collaborator

I think it's because of that early return in scan_P_:

else:     # no x overlap between _P and next P: _P is included in unique blob segment:
           ini = 1
           if y > rng * 2 + 1:  # beyond 1st line of _fork_ Ps, else: blob segment ini only
               if len(_fork_[0]) == 1:
                   #try:
                       if _fork_[0][0][4][0] == 1:  # _fork roots, see if ini = 1, second [] is a fixed-id _P container
                           _P[0] = form_seg(_P[0], _fork_[0][0], _x)  # _P is added to blob segment at _fork_[0]
                           ini = 0  # no initialization
                           return ini, fork_
                   #except:

A tuple of two is returned, but the left-side requires 4 elements.

My error message: (Py 3.6.1)

File "D:\Py\cog\frame1.py", line 115, in form_P
P_, buff_, P, frame = scan_P_(x-1, P, P_, buff_, P, frame) # scans higher-line Ps for contiguity
ValueError: not enough values to unpack (expected 4, got 2)

Collaborator

Twenkid commented Sep 27, 2018

I think it's because of that early return in scan_P_:

else:     # no x overlap between _P and next P: _P is included in unique blob segment:
           ini = 1
           if y > rng * 2 + 1:  # beyond 1st line of _fork_ Ps, else: blob segment ini only
               if len(_fork_[0]) == 1:
                   #try:
                       if _fork_[0][0][4][0] == 1:  # _fork roots, see if ini = 1, second [] is a fixed-id _P container
                           _P[0] = form_seg(_P[0], _fork_[0][0], _x)  # _P is added to blob segment at _fork_[0]
                           ini = 0  # no initialization
                           return ini, fork_
                   #except:

A tuple of two is returned, but the left-side requires 4 elements.

My error message: (Py 3.6.1)

File "D:\Py\cog\frame1.py", line 115, in form_P
P_, buff_, P, frame = scan_P_(x-1, P, P_, buff_, P, frame) # scans higher-line Ps for contiguity
ValueError: not enough values to unpack (expected 4, got 2)

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator
Collaborator

Twenkid commented Sep 28, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator

First diagnostics:

That y > 5 relates to rng*2 + 1, the border line changes with the change of rng.

Therefore related code with this limit may be involved.

There's related code in the vertical_comp:

    min_coord = rng * 2 - 1  # min x and y for form_P input

 elif x > min_coord and y > min_coord:  # or min y is increased by x_comp on line y=0?
                _v = _m - abs(d) - ave  # _m - abs(d): projected m cancelled by negative d: d/2, + projected rdn value of overlapping dP: d/2
                vy = my + _my - abs(dy) - ave
                ders2 = _p, _d, dy + _dy, _v, vy
                dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)

Also in form_P:

 if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []]) 

 if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
            buff_.append([_P, _x, _fork_, roots])

That also eliminates the else: branch with len(fork)

..

I think it catches an exception when


#len(_fork_),x,_ix,y 1 812 799 41
..if y > rng * 2 + 1: 41
....if len(_fork_[0]) == 1:

But that _fork_ has no other elements and a query is made to missing indices: 
if _fork_[0][0][4][0] == 1: 

I've got code modified to log some things and some print outs.
A printout with rng = 3:

rng = 2:

If I catch these exception, there's another one (line numbers may vary from yours due to additional code):

frame_of_blobs = image_to_blobs(image)
 File "frame2.py", line 316, in image_to_blobs
   ders2__, _P_, frame = vertical_comp(ders_, ders2__, _P_, frame)  # vertical pixel comparison
 File "frame2.py", line 93, in vertical_comp
   dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)
 File "frame2.py", line 116, in form_P
   P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity
 File "frame2.py", line 207, in scan_P_
   _P[0], frame = form_blob(_P[0], frame)  # blob (all connected blob segments) += blob segment at _P[0]
 File "frame2.py", line 248, in form_blob
   _roots, _root_, _blob = _seg[4]
IndexError: list index out of range

Maybe because when there's an exception, _P[0] = form_seg(... is not hit.

...

Some printouts, f2 (rng=2), f3 (=3)
http://twenkid.com/cog/

Collaborator

Twenkid commented Sep 28, 2018

First diagnostics:

That y > 5 relates to rng*2 + 1, the border line changes with the change of rng.

Therefore related code with this limit may be involved.

There's related code in the vertical_comp:

    min_coord = rng * 2 - 1  # min x and y for form_P input

 elif x > min_coord and y > min_coord:  # or min y is increased by x_comp on line y=0?
                _v = _m - abs(d) - ave  # _m - abs(d): projected m cancelled by negative d: d/2, + projected rdn value of overlapping dP: d/2
                vy = my + _my - abs(dy) - ave
                ders2 = _p, _d, dy + _dy, _v, vy
                dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)

Also in form_P:

 if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []]) 

 if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
            buff_.append([_P, _x, _fork_, roots])

That also eliminates the else: branch with len(fork)

..

I think it catches an exception when


#len(_fork_),x,_ix,y 1 812 799 41
..if y > rng * 2 + 1: 41
....if len(_fork_[0]) == 1:

But that _fork_ has no other elements and a query is made to missing indices: 
if _fork_[0][0][4][0] == 1: 

I've got code modified to log some things and some print outs.
A printout with rng = 3:

rng = 2:

If I catch these exception, there's another one (line numbers may vary from yours due to additional code):

frame_of_blobs = image_to_blobs(image)
 File "frame2.py", line 316, in image_to_blobs
   ders2__, _P_, frame = vertical_comp(ders_, ders2__, _P_, frame)  # vertical pixel comparison
 File "frame2.py", line 93, in vertical_comp
   dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)
 File "frame2.py", line 116, in form_P
   P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity
 File "frame2.py", line 207, in scan_P_
   _P[0], frame = form_blob(_P[0], frame)  # blob (all connected blob segments) += blob segment at _P[0]
 File "frame2.py", line 248, in form_blob
   _roots, _root_, _blob = _seg[4]
IndexError: list index out of range

Maybe because when there's an exception, _P[0] = form_seg(... is not hit.

...

Some printouts, f2 (rng=2), f3 (=3)
http://twenkid.com/cog/

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator

Strangely while adding code that wasn't changing the processing, it started to complete runs without throwing an exception. However according to the log, if roots == 0 and if len(_fork_) == 0 are not reached.

A log: f2noexc,txt
http://twenkid.com/cog/f2noexc.txt

My latest addition was just copying the latest fork


 if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
            print("@if _x > ix:", x,ix)
            lastFork = copy.copy(_fork_) 

For printing latest previous fork in that case of exception, however there's no exception.
After the run it's []

Collaborator

Twenkid commented Sep 28, 2018

Strangely while adding code that wasn't changing the processing, it started to complete runs without throwing an exception. However according to the log, if roots == 0 and if len(_fork_) == 0 are not reached.

A log: f2noexc,txt
http://twenkid.com/cog/f2noexc.txt

My latest addition was just copying the latest fork


 if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
            print("@if _x > ix:", x,ix)
            lastFork = copy.copy(_fork_) 

For printing latest previous fork in that case of exception, however there's no exception.
After the run it's []

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator

This is not the problem. The problem is that roots and len(fork) are always > 0, on lines y==6 - y==8
Then at least from what I see here:

   if _buff_:
            _P, _x, _fork_, roots = _buff_.popleft()  # load _P buffered in prior run of scan_P_, if any
        elif _P_:
            _P, _x, _fork_ = _P_.popleft()
            roots = 0  # number of Ps connected to current _P[(pri_s, I, D, Dy, V, Vy, ders2_)]
        else:
            break
        _ix = _x - len(_P[0][6])

        if P[0][0] == _P[0][0]:  # if s == _s: core sign match, + selective inclusion if contiguity eval
            fork_.append(_P)  # P-connected _Ps, appended with blob and converted to Py_ after P_ scan
            roots += 1

_P_ contains a _fork_ > 0 or/and P[0][0] == _P[0][0]: - then roots is increased.

Collaborator

Twenkid commented Sep 28, 2018

This is not the problem. The problem is that roots and len(fork) are always > 0, on lines y==6 - y==8
Then at least from what I see here:

   if _buff_:
            _P, _x, _fork_, roots = _buff_.popleft()  # load _P buffered in prior run of scan_P_, if any
        elif _P_:
            _P, _x, _fork_ = _P_.popleft()
            roots = 0  # number of Ps connected to current _P[(pri_s, I, D, Dy, V, Vy, ders2_)]
        else:
            break
        _ix = _x - len(_P[0][6])

        if P[0][0] == _P[0][0]:  # if s == _s: core sign match, + selective inclusion if contiguity eval
            fork_.append(_P)  # P-connected _Ps, appended with blob and converted to Py_ after P_ scan
            roots += 1

_P_ contains a _fork_ > 0 or/and P[0][0] == _P[0][0]: - then roots is increased.

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator

Why they have to be different, what's the reasoning and the path in the code that is expected to be taken so that they are with the expected values. If you know that you'll know what's wrong.

Collaborator

Twenkid commented Sep 28, 2018

Why they have to be different, what's the reasoning and the path in the code that is expected to be taken so that they are with the expected values. If you know that you'll know what's wrong.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator

roots is 0 if a 0 is pushed in buff, or else if buff is empty but a prior line P exists.

_P, _x, fork = P.popleft()
roots = 0

Then if the sign if P[0][0] == _P[0][0]: matches, roots is always incremented.

In order to have 0 for roots in the buffer, control flow should go there:

        if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
            buff_.append([_P, _x, _fork_, roots])

And roots to be 0.

So if roots is always 1, then maybe always when x > ix, if P[0][0] == _P[0][0] is also true, then the buffer is filled with initialized roots.

Collaborator

Twenkid commented Sep 28, 2018

roots is 0 if a 0 is pushed in buff, or else if buff is empty but a prior line P exists.

_P, _x, fork = P.popleft()
roots = 0

Then if the sign if P[0][0] == _P[0][0]: matches, roots is always incremented.

In order to have 0 for roots in the buffer, control flow should go there:

        if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
            buff_.append([_P, _x, _fork_, roots])

And roots to be 0.

So if roots is always 1, then maybe always when x > ix, if P[0][0] == _P[0][0] is also true, then the buffer is filled with initialized roots.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 28, 2018

Owner
Owner

boris-kz commented Sep 28, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 28, 2018

Collaborator
  1. Why there's an else here?

 else:
        if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []])  # empty _fork_ in the first line of _Ps, x-1: delayed P displacement
        elif x < X - 200:  # right error margin: >len(fork_P[6])?
            P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity

Are the conditions mutually exclusive?

  1. As of fork - it is loaded there in Scan_P:

 elif _P_:
            _P, _x, _fork_ = _P_.popleft()

The call tree is:

vertical_comp->form_P->scan_P

More specifically when:


elif x > min_coord and y > min_coord:  # or min y is increased by x_comp on line y=0?
... 
             dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)

dP_ is renamed to P_

Then if signs don't match:

else:
        if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []])  # empty _fork_ in the first line of _Ps, x-1: delayed P displacement

So that's how you expect an empty fork.

Initialize the pattern:

I, D, Dy, V, Vy, ders2_ = 0, 0, 0, 0, 0, [] # new P initialization

Then update it with p, d, ... current values from the received ders2 arguments.

Then pack the pattern into a list:

P = [(s, I, D, Dy, V, Vy, ders2_)]

and return it:
return P, P_, buff_, _P_, frame # accumulated within line, P_ is a buffer for conversion to _P_

Now there is the frist _P_ in _dP_ in vertical_comp, where more are accumulated and eventually read back:


_P, _x, _fork_ = _P_.popleft()

Where _P is a dP, i.e. ders2
Then in scan_p there's also:
P_.append([P, x, fork_])

So let's see the buffer.

In form_P, if y == rng*2, then elif x < X -200 is never checked.

Therefore form_P passes the buffer to another iteration of scan_P.


  if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []])  # empty _fork_ in the first line of _Ps, x-1: delayed P displacement
        elif x < X - 200:  # right error margin: >len(fork_P[6])?
            P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity


While _ix < x ... In case there is a buffer with elements, the oldest (left) items from the buffer are popped, including roots.

Otherwise, if buff is empty and the upper line container of dP is not empty, only 3 elements (not 4) are popped from the container of upper line patterns.


 elif _P_:
            _P, _x, _fork_ = _P_.popleft()
            roots = 0  # number of Ps connected to current _P[(pri_s, I, D, Dy, V, Vy, ders2_)]
        else:

roots is added manually, "initialized".

That should be a creation of a "root" for a fork.

Like with the question above, are these conditions guaranteed to be mutually exclusive. I see that the patterns are "displaced" there. If they are not displaced correctly, the conditions won't be mutually exclusive.

I'd give a general suggestion that the conditions which are checked as mutually exclusive should have more guarantees and measures that they really are mutually exclusive.

Collaborator

Twenkid commented Sep 28, 2018

  1. Why there's an else here?

 else:
        if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []])  # empty _fork_ in the first line of _Ps, x-1: delayed P displacement
        elif x < X - 200:  # right error margin: >len(fork_P[6])?
            P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity

Are the conditions mutually exclusive?

  1. As of fork - it is loaded there in Scan_P:

 elif _P_:
            _P, _x, _fork_ = _P_.popleft()

The call tree is:

vertical_comp->form_P->scan_P

More specifically when:


elif x > min_coord and y > min_coord:  # or min y is increased by x_comp on line y=0?
... 
             dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)

dP_ is renamed to P_

Then if signs don't match:

else:
        if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []])  # empty _fork_ in the first line of _Ps, x-1: delayed P displacement

So that's how you expect an empty fork.

Initialize the pattern:

I, D, Dy, V, Vy, ders2_ = 0, 0, 0, 0, 0, [] # new P initialization

Then update it with p, d, ... current values from the received ders2 arguments.

Then pack the pattern into a list:

P = [(s, I, D, Dy, V, Vy, ders2_)]

and return it:
return P, P_, buff_, _P_, frame # accumulated within line, P_ is a buffer for conversion to _P_

Now there is the frist _P_ in _dP_ in vertical_comp, where more are accumulated and eventually read back:


_P, _x, _fork_ = _P_.popleft()

Where _P is a dP, i.e. ders2
Then in scan_p there's also:
P_.append([P, x, fork_])

So let's see the buffer.

In form_P, if y == rng*2, then elif x < X -200 is never checked.

Therefore form_P passes the buffer to another iteration of scan_P.


  if y == rng * 2:  # first line of Ps -> P_, _P_ is empty until vertical_comp returns P_:
            P_.append([P, x-1, []])  # empty _fork_ in the first line of _Ps, x-1: delayed P displacement
        elif x < X - 200:  # right error margin: >len(fork_P[6])?
            P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity


While _ix < x ... In case there is a buffer with elements, the oldest (left) items from the buffer are popped, including roots.

Otherwise, if buff is empty and the upper line container of dP is not empty, only 3 elements (not 4) are popped from the container of upper line patterns.


 elif _P_:
            _P, _x, _fork_ = _P_.popleft()
            roots = 0  # number of Ps connected to current _P[(pri_s, I, D, Dy, V, Vy, ders2_)]
        else:

roots is added manually, "initialized".

That should be a creation of a "root" for a fork.

Like with the question above, are these conditions guaranteed to be mutually exclusive. I see that the patterns are "displaced" there. If they are not displaced correctly, the conditions won't be mutually exclusive.

I'd give a general suggestion that the conditions which are checked as mutually exclusive should have more guarantees and measures that they really are mutually exclusive.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 29, 2018

Owner
Owner

boris-kz commented Sep 29, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator
Collaborator

Twenkid commented Sep 29, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator

IndexError: invalid index to scalar variable. for if _fork_[0][0][4][0] == 1:


Traceback (most recent call last):
  File "frame3.py", line 291, in <module>
    frame_of_blobs = image_to_blobs(image)
  File "frame3.py", line 267, in image_to_blobs
    ders2__, _P_, frame = vertical_comp(ders_, ders2__, _P_, frame)  # vertical pixel comparison
  File "frame3.py", line 93, in vertical_comp
    dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)
  File "frame3.py", line 114, in form_P
    P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity
  File "frame3.py", line 156, in scan_P_
    if _fork_[0][0][4][0] == 1:  # _fork roots, see if ini = 1, second [] is a fixed-id _P container
  IndexError: invalid index to scalar variable.
Collaborator

Twenkid commented Sep 29, 2018

IndexError: invalid index to scalar variable. for if _fork_[0][0][4][0] == 1:


Traceback (most recent call last):
  File "frame3.py", line 291, in <module>
    frame_of_blobs = image_to_blobs(image)
  File "frame3.py", line 267, in image_to_blobs
    ders2__, _P_, frame = vertical_comp(ders_, ders2__, _P_, frame)  # vertical pixel comparison
  File "frame3.py", line 93, in vertical_comp
    dP, dP_, dbuff_, _dP_, dframe = form_P(ders2, x, dP, dP_, dbuff_, _dP_, dframe)
  File "frame3.py", line 114, in form_P
    P_, buff_, _P_, frame = scan_P_(x-1, P, P_, buff_, _P_, frame)  # scans higher-line Ps for contiguity
  File "frame3.py", line 156, in scan_P_
    if _fork_[0][0][4][0] == 1:  # _fork roots, see if ini = 1, second [] is a fixed-id _P container
  IndexError: invalid index to scalar variable.
@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator

The log suggests that fork has only one element and the 4-th element is scalar, not a list, thus it doesn't have an index [0]. I guess it's then not of the type that it was expected?

(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x0000017C93B26548>)
_fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
[[(1,
   812,
   70,
   77,
   436,
   515,
   [(70, 6, 5, 23, 26),
    (70, 5, 14, 28, 26),
    (72, 4, 16, 30, 35),
    (72, 6, 0, 32, 46),
    (73, 6, 1, 37, 47),
    (74, 5, 3, 43, 49),
    (75, 3, 5, 47, 52),
    (76, 3, 8, 45, 55),
    (76, 7, 5, 39, 60),
    (77, 15, 8, 46, 61),
    (77, 10, 12, 66, 58)])]]
[(1,
  812,
  70,
  77,
  436,
  515,
  [(70, 6, 5, 23, 26),
   (70, 5, 14, 28, 26),
   (72, 4, 16, 30, 35),
   (72, 6, 0, 32, 46),
   (73, 6, 1, 37, 47),
   (74, 5, 3, 43, 49),
   (75, 3, 5, 47, 52),
   (76, 3, 8, 45, 55),
   (76, 7, 5, 39, 60),
   (77, 15, 8, 46, 61),
   (77, 10, 12, 66, 58)])]
(1,
 812,
 70,
 77,
 436,
 515,
 [(70, 6, 5, 23, 26),
  (70, 5, 14, 28, 26),
  (72, 4, 16, 30, 35),
  (72, 6, 0, 32, 46),
  (73, 6, 1, 37, 47),
  (74, 5, 3, 43, 49),
  (75, 3, 5, 47, 52),
  (76, 3, 8, 45, 55),
  (76, 7, 5, 39, 60),
  (77, 15, 8, 46, 61),
  (77, 10, 12, 66, 58)])
436

else:     # no x overlap between _P and next P: _P is included in unique blob segment:
          ini = 1
          if y > rng * 2 + 1 + 400:  # beyond 1st line of _fork_ Ps, else: blob segment ini only
              if len(_fork_[0]) == 1:
                  try:                
                    if _fork_[0][0][4][0] == 1:  # _fork roots, see if ini = 1, second [] is a fixed-id _P container
                        _P[0] = form_seg(_P[0], _fork_[0][0], _x)  # _P is added to blob segment at _fork_[0]
                        ini = 0  # no initialization
                  except:
                         import pprint                    
                         import sys
                         print(sys.exc_info())
                         print("_fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]")
                         pprint.pprint(_fork_)
                         pprint.pprint(_fork_[0])
                         pprint.pprint(_fork_[0][0])
                         pprint.pprint(_fork_[0][0][4])
                         exit(0)

_fork_[0][0] is that tuple:

S: scalar, L: list, T: tuple
New line means included in:

S, S, S, S, S, L,
                     T                ...  x10
                        S,S,S,S,S     

(1,
 812,
 70,
 77,
 436,
 515,
 [(70, 6, 5, 23, 26),
  (70, 5, 14, 28, 26),
  (72, 4, 16, 30, 35),
  (72, 6, 0, 32, 46),
  (73, 6, 1, 37, 47),
  (74, 5, 3, 43, 49),
  (75, 3, 5, 47, 52),
  (76, 3, 8, 45, 55),
  (76, 7, 5, 39, 60),
  (77, 15, 8, 46, 61),
  (77, 10, 12, 66, 58)])
Collaborator

Twenkid commented Sep 29, 2018

The log suggests that fork has only one element and the 4-th element is scalar, not a list, thus it doesn't have an index [0]. I guess it's then not of the type that it was expected?

(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x0000017C93B26548>)
_fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
[[(1,
   812,
   70,
   77,
   436,
   515,
   [(70, 6, 5, 23, 26),
    (70, 5, 14, 28, 26),
    (72, 4, 16, 30, 35),
    (72, 6, 0, 32, 46),
    (73, 6, 1, 37, 47),
    (74, 5, 3, 43, 49),
    (75, 3, 5, 47, 52),
    (76, 3, 8, 45, 55),
    (76, 7, 5, 39, 60),
    (77, 15, 8, 46, 61),
    (77, 10, 12, 66, 58)])]]
[(1,
  812,
  70,
  77,
  436,
  515,
  [(70, 6, 5, 23, 26),
   (70, 5, 14, 28, 26),
   (72, 4, 16, 30, 35),
   (72, 6, 0, 32, 46),
   (73, 6, 1, 37, 47),
   (74, 5, 3, 43, 49),
   (75, 3, 5, 47, 52),
   (76, 3, 8, 45, 55),
   (76, 7, 5, 39, 60),
   (77, 15, 8, 46, 61),
   (77, 10, 12, 66, 58)])]
(1,
 812,
 70,
 77,
 436,
 515,
 [(70, 6, 5, 23, 26),
  (70, 5, 14, 28, 26),
  (72, 4, 16, 30, 35),
  (72, 6, 0, 32, 46),
  (73, 6, 1, 37, 47),
  (74, 5, 3, 43, 49),
  (75, 3, 5, 47, 52),
  (76, 3, 8, 45, 55),
  (76, 7, 5, 39, 60),
  (77, 15, 8, 46, 61),
  (77, 10, 12, 66, 58)])
436

else:     # no x overlap between _P and next P: _P is included in unique blob segment:
          ini = 1
          if y > rng * 2 + 1 + 400:  # beyond 1st line of _fork_ Ps, else: blob segment ini only
              if len(_fork_[0]) == 1:
                  try:                
                    if _fork_[0][0][4][0] == 1:  # _fork roots, see if ini = 1, second [] is a fixed-id _P container
                        _P[0] = form_seg(_P[0], _fork_[0][0], _x)  # _P is added to blob segment at _fork_[0]
                        ini = 0  # no initialization
                  except:
                         import pprint                    
                         import sys
                         print(sys.exc_info())
                         print("_fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]")
                         pprint.pprint(_fork_)
                         pprint.pprint(_fork_[0])
                         pprint.pprint(_fork_[0][0])
                         pprint.pprint(_fork_[0][0][4])
                         exit(0)

_fork_[0][0] is that tuple:

S: scalar, L: list, T: tuple
New line means included in:

S, S, S, S, S, L,
                     T                ...  x10
                        S,S,S,S,S     

(1,
 812,
 70,
 77,
 436,
 515,
 [(70, 6, 5, 23, 26),
  (70, 5, 14, 28, 26),
  (72, 4, 16, 30, 35),
  (72, 6, 0, 32, 46),
  (73, 6, 1, 37, 47),
  (74, 5, 3, 43, 49),
  (75, 3, 5, 47, 52),
  (76, 3, 8, 45, 55),
  (76, 7, 5, 39, 60),
  (77, 15, 8, 46, 61),
  (77, 10, 12, 66, 58)])
@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 29, 2018

Owner
Owner

boris-kz commented Sep 29, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator

x was 811 with the margin 200
x,y: 811 408

With margin 250 (X-250), x,y:
762 414

Collaborator

Twenkid commented Sep 29, 2018

x was 811 with the margin 200
x,y: 811 408

With margin 250 (X-250), x,y:
762 414

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 29, 2018

Owner
Owner

boris-kz commented Sep 29, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator

Margin seems not to help, just the point is moving to the left.

(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x00000226DECDEA08>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
500 519 411
[[(1,
   529,
   138,
   111,
   1015,
   1162,
   [(127, 31, 32, 194, 272),
    (125, 56, 27, 221, 275),
    (133, 43, 31, 294, 289),
    (144, 8, 21, 306, 326)])]]
[(1,
  529,
  138,
  111,
  1015,
  1162,
  [(127, 31, 32, 194, 272),
   (125, 56, 27, 221, 275),
   (133, 43, 31, 294, 289),
   (144, 8, 21, 306, 326)])]
(1,
 529,
 138,
 111,
 1015,
 1162,
 [(127, 31, 32, 194, 272),
  (125, 56, 27, 221, 275),
  (133, 43, 31, 294, 289),
  (144, 8, 21, 306, 326)])
1015
(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x0000018E93DD0EC8>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
600 418 409
[[(0,
   687,
   -973,
   -811,
   -831,
   207,
   [(179, -132, -12, 94, 364),
    (185, -244, -156, -84, 181),
    (152, -262, -198, -230, 25),
    (107, -234, -224, -245, -125),
    (64, -101, -221, -366, -238)])]]
[(0,
  687,
  -973,
  -811,
  -831,
  207,
  [(179, -132, -12, 94, 364),
   (185, -244, -156, -84, 181),
   (152, -262, -198, -230, 25),
   (107, -234, -224, -245, -125),
   (64, -101, -221, -366, -238)])]
(0,
 687,
 -973,
 -811,
 -831,
 207,
 [(179, -132, -12, 94, 364),
  (185, -244, -156, -84, 181),
  (152, -262, -198, -230, 25),
  (107, -234, -224, -245, -125),
  (64, -101, -221, -366, -238)])
-831

D:\Py\cog>python frame3.py
(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x0000021A6FC92CC8>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
800 219 408
[[(0,
   365,
   -434,
   -465,
   -583,
   -331,
   [(89, -42, 38, -94, 91),
    (118, -178, -181, -165, -31),
    (96, -163, -215, -150, -187),
    (62, -51, -107, -174, -204)])]]
[(0,
  365,
  -434,
  -465,
  -583,
  -331,
  [(89, -42, 38, -94, 91),
   (118, -178, -181, -165, -31),
   (96, -163, -215, -150, -187),
   (62, -51, -107, -174, -204)])]
(0,
 365,
 -434,
 -465,
 -583,
 -331,
 [(89, -42, 38, -94, 91),
  (118, -178, -181, -165, -31),
  (96, -163, -215, -150, -187),
  (62, -51, -107, -174, -204)])
-583

Collaborator

Twenkid commented Sep 29, 2018

Margin seems not to help, just the point is moving to the left.

(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x00000226DECDEA08>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
500 519 411
[[(1,
   529,
   138,
   111,
   1015,
   1162,
   [(127, 31, 32, 194, 272),
    (125, 56, 27, 221, 275),
    (133, 43, 31, 294, 289),
    (144, 8, 21, 306, 326)])]]
[(1,
  529,
  138,
  111,
  1015,
  1162,
  [(127, 31, 32, 194, 272),
   (125, 56, 27, 221, 275),
   (133, 43, 31, 294, 289),
   (144, 8, 21, 306, 326)])]
(1,
 529,
 138,
 111,
 1015,
 1162,
 [(127, 31, 32, 194, 272),
  (125, 56, 27, 221, 275),
  (133, 43, 31, 294, 289),
  (144, 8, 21, 306, 326)])
1015
(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x0000018E93DD0EC8>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
600 418 409
[[(0,
   687,
   -973,
   -811,
   -831,
   207,
   [(179, -132, -12, 94, 364),
    (185, -244, -156, -84, 181),
    (152, -262, -198, -230, 25),
    (107, -234, -224, -245, -125),
    (64, -101, -221, -366, -238)])]]
[(0,
  687,
  -973,
  -811,
  -831,
  207,
  [(179, -132, -12, 94, 364),
   (185, -244, -156, -84, 181),
   (152, -262, -198, -230, 25),
   (107, -234, -224, -245, -125),
   (64, -101, -221, -366, -238)])]
(0,
 687,
 -973,
 -811,
 -831,
 207,
 [(179, -132, -12, 94, 364),
  (185, -244, -156, -84, 181),
  (152, -262, -198, -230, 25),
  (107, -234, -224, -245, -125),
  (64, -101, -221, -366, -238)])
-831

D:\Py\cog>python frame3.py
(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x0000021A6FC92CC8>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
800 219 408
[[(0,
   365,
   -434,
   -465,
   -583,
   -331,
   [(89, -42, 38, -94, 91),
    (118, -178, -181, -165, -31),
    (96, -163, -215, -150, -187),
    (62, -51, -107, -174, -204)])]]
[(0,
  365,
  -434,
  -465,
  -583,
  -331,
  [(89, -42, 38, -94, 91),
   (118, -178, -181, -165, -31),
   (96, -163, -215, -150, -187),
   (62, -51, -107, -174, -204)])]
(0,
 365,
 -434,
 -465,
 -583,
 -331,
 [(89, -42, 38, -94, 91),
  (118, -178, -181, -165, -31),
  (96, -163, -215, -150, -187),
  (62, -51, -107, -174, -204)])
-583

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator
margin = 1000 as well :)

(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x000001BC7128CE08>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
1000 20 407
[[(1,
   511,
   554,
   475,
   161,
   476,
   [(61, 23, -13, -95, 26),
    (60, 84, 65, -158, -6),
    (63, 152, 137, -133, -20),
    (79, 165, 169, 19, 30),
    (109, 105, 114, 219, 163),
    (139, 25, 3, 309, 283)])]]
[(1,
  511,
  554,
  475,
  161,
  476,
  [(61, 23, -13, -95, 26),
   (60, 84, 65, -158, -6),
   (63, 152, 137, -133, -20),
   (79, 165, 169, 19, 30),
   (109, 105, 114, 219, 163),
   (139, 25, 3, 309, 283)])]
(1,
 511,
 554,
 475,
 161,
 476,
 [(61, 23, -13, -95, 26),
  (60, 84, 65, -158, -6),
  (63, 152, 137, -133, -20),
  (79, 165, 169, 19, 30),
  (109, 105, 114, 219, 163),
  (139, 25, 3, 309, 283)])
161
Collaborator

Twenkid commented Sep 29, 2018

margin = 1000 as well :)

(<class 'IndexError'>, IndexError('invalid index to scalar variable.',), <traceback object at 0x000001BC7128CE08>)
margin, x,y; _fork_, _fork_[0]_, _fork_[0][0], _fork[0][0][4]
1000 20 407
[[(1,
   511,
   554,
   475,
   161,
   476,
   [(61, 23, -13, -95, 26),
    (60, 84, 65, -158, -6),
    (63, 152, 137, -133, -20),
    (79, 165, 169, 19, 30),
    (109, 105, 114, 219, 163),
    (139, 25, 3, 309, 283)])]]
[(1,
  511,
  554,
  475,
  161,
  476,
  [(61, 23, -13, -95, 26),
   (60, 84, 65, -158, -6),
   (63, 152, 137, -133, -20),
   (79, 165, 169, 19, 30),
   (109, 105, 114, 219, 163),
   (139, 25, 3, 309, 283)])]
(1,
 511,
 554,
 475,
 161,
 476,
 [(61, 23, -13, -95, 26),
  (60, 84, 65, -158, -6),
  (63, 152, 137, -133, -20),
  (79, 165, 169, 19, 30),
  (109, 105, 114, 219, 163),
  (139, 25, 3, 309, 283)])
161
@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator

How exactly to initialize it? With just fork_ = [] as in the top of the function,

if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
           buff_.append([_P, _x, _fork_, roots])
       else:     # no x overlap between _P and next P: _P is included in unique blob segment:
           ini = 1
           if y > rng * 2 + 1 + 400:  # beyond 1st line of _fork_ Ps, else: blob segment ini only
               if len(_fork_[0]) == 1:
                   fork_ = [] 

Then it encounters:

    if len(_fork_[0]) == 1:
IndexError: list index out of range

Accessing a missing index.

Collaborator

Twenkid commented Sep 29, 2018

How exactly to initialize it? With just fork_ = [] as in the top of the function,

if _x > ix:  # x overlap between _P and next P: _P is buffered for next scan_P_
           buff_.append([_P, _x, _fork_, roots])
       else:     # no x overlap between _P and next P: _P is included in unique blob segment:
           ini = 1
           if y > rng * 2 + 1 + 400:  # beyond 1st line of _fork_ Ps, else: blob segment ini only
               if len(_fork_[0]) == 1:
                   fork_ = [] 

Then it encounters:

    if len(_fork_[0]) == 1:
IndexError: list index out of range

Accessing a missing index.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 29, 2018

Owner
Owner

boris-kz commented Sep 29, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 29, 2018

Collaborator
Collaborator

Twenkid commented Sep 29, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 30, 2018

Collaborator

OK. What's "L is always n ders2 -1" ? (As well as "add extended syntax to fork")?

Collaborator

Twenkid commented Sep 30, 2018

OK. What's "L is always n ders2 -1" ? (As well as "add extended syntax to fork")?

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 30, 2018

Collaborator

And now using average.
_P[0] = form_seg(_P[0], _fork_[0][0], _ave_x)

That with the number - 1 - sounds like missing some +1 somewhere, like the first element.

Counting and the border cases are a general issue in software which must be watched.

One must be careful whether it starts from 0 or 1, whether iteration includes the last element or not etc., when the counter is incremented and is it in the right time, also when there's a skip/continue/break that's a possible source for bugs in while-loops due to forgotten or inadequate increment of the counter or comparison of the termination condition.

Collaborator

Twenkid commented Sep 30, 2018

And now using average.
_P[0] = form_seg(_P[0], _fork_[0][0], _ave_x)

That with the number - 1 - sounds like missing some +1 somewhere, like the first element.

Counting and the border cases are a general issue in software which must be watched.

One must be careful whether it starts from 0 or 1, whether iteration includes the last element or not etc., when the counter is incremented and is it in the right time, also when there's a skip/continue/break that's a possible source for bugs in while-loops due to forgotten or inadequate increment of the counter or comparison of the termination condition.

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 30, 2018

Collaborator

So "add syntax" means a function from the hierarchy in the header to call its neighbour higher level function?

    1Le, line y:    x_comp(p_): lateral pixel comparison -> tuple of derivatives ders ) array ders_
    2Le, line y- 1: y_comp(ders_): vertical pixel comp -> 2D tuple ders2 ) array ders2_ 
    3Le, line y- 1+ rng*2: form_P(ders2) -> 1D pattern P ) P_  
    4Le, line y- 2+ rng*2: scan_P_(P, _P) -> _P, fork_, root_: downward and upward connections between Ps of adjacent lines 
    5Le, line y- 3+ rng*2: form_segment(_P, segment) -> segment: merge vertically-connected Ps into non-forking blob segments
    6Le, line y- 4+ rng*2+ segment depth: term_segment, form_blob -> blob: merge terminated connected segments into blob
Collaborator

Twenkid commented Sep 30, 2018

So "add syntax" means a function from the hierarchy in the header to call its neighbour higher level function?

    1Le, line y:    x_comp(p_): lateral pixel comparison -> tuple of derivatives ders ) array ders_
    2Le, line y- 1: y_comp(ders_): vertical pixel comp -> 2D tuple ders2 ) array ders2_ 
    3Le, line y- 1+ rng*2: form_P(ders2) -> 1D pattern P ) P_  
    4Le, line y- 2+ rng*2: scan_P_(P, _P) -> _P, fork_, root_: downward and upward connections between Ps of adjacent lines 
    5Le, line y- 3+ rng*2: form_segment(_P, segment) -> segment: merge vertically-connected Ps into non-forking blob segments
    6Le, line y- 4+ rng*2+ segment depth: term_segment, form_blob -> blob: merge terminated connected segments into blob
@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 30, 2018

Collaborator

You mean this old code?:


def form_seg(P, seg, last_x):  # continued or initialized blob segment is incremented by attached _P
    s, I, D, Dy, V, Vy, ders2_ = P  # s is identical, ders2_ is a replacement
    (s, Ls, Is, Ds, Dys, Vs, Vys), Py_, _x, xD, root, fork_ = seg  # fork_ assigned at ini only, roots at form_blob?

    x = last_x - len(ders2_) // 2
    xd = x - _x  # conditional full comp(x) and comp(S): internal vars are secondary?
    xD += xd  # for segment normalization and orientation eval, | += |xd| for curved max_L norm, orient?
    Ls += len(ders2_)  # ders2_ in P buffered in Py_

That now sounds as the Alg has once expected that len(ders2_) was > 0 (1), but it was 0, so Ls+=0 hasn't modified anything.

Collaborator

Twenkid commented Sep 30, 2018

You mean this old code?:


def form_seg(P, seg, last_x):  # continued or initialized blob segment is incremented by attached _P
    s, I, D, Dy, V, Vy, ders2_ = P  # s is identical, ders2_ is a replacement
    (s, Ls, Is, Ds, Dys, Vs, Vys), Py_, _x, xD, root, fork_ = seg  # fork_ assigned at ini only, roots at form_blob?

    x = last_x - len(ders2_) // 2
    xd = x - _x  # conditional full comp(x) and comp(S): internal vars are secondary?
    xD += xd  # for segment normalization and orientation eval, | += |xd| for curved max_L norm, orient?
    Ls += len(ders2_)  # ders2_ in P buffered in Py_

That now sounds as the Alg has once expected that len(ders2_) was > 0 (1), but it was 0, so Ls+=0 hasn't modified anything.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 30, 2018

Collaborator

OK, I don't know how len(ders2_) would return len(ders2_)-1... Are you sure you've checked the values correctly.

Only if it was compared to something else.

Collaborator

Twenkid commented Sep 30, 2018

OK, I don't know how len(ders2_) would return len(ders2_)-1... Are you sure you've checked the values correctly.

Only if it was compared to something else.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@Twenkid

This comment has been minimized.

Show comment
Hide comment
@Twenkid

Twenkid Sep 30, 2018

Collaborator

I won't give you philosophy, I say your claim makes no sense to me at the moment, I don't know what to check.

L = len(ders2_), this should not return len(ders2_) - 1

Yes, it shouldn't, either you think the value of ders2_ was different than it was or you've seen not the values at the right moment, but a cycle earlier or you subtract one somewhere - perhaps in a hidden part of code which is invisible.

Collaborator

Twenkid commented Sep 30, 2018

I won't give you philosophy, I say your claim makes no sense to me at the moment, I don't know what to check.

L = len(ders2_), this should not return len(ders2_) - 1

Yes, it shouldn't, either you think the value of ders2_ was different than it was or you've seen not the values at the right moment, but a cycle earlier or you subtract one somewhere - perhaps in a hidden part of code which is invisible.

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

@boris-kz

This comment has been minimized.

Show comment
Hide comment
@boris-kz

boris-kz Sep 30, 2018

Owner
Owner

boris-kz commented Sep 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment