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

The Ackermann functions are not actual generators #24

Closed
AdrienCos opened this issue May 30, 2019 · 6 comments
Closed

The Ackermann functions are not actual generators #24

AdrienCos opened this issue May 30, 2019 · 6 comments

Comments

@AdrienCos
Copy link
Contributor

AdrienCos commented May 30, 2019

As the title mentions, the two Ackermann number generators in the file generators.py are not actual generators, for two reasons:

  • they to not have any yield instruction, causing them to be considered as simple functions by the interpreter
  • they do not operate in a loop, i.e. they output a single integer and finish

I believe that they should be rewritten to act as generator. A possible solution could be to have the generator start at A(1,0) (or any other value), and each new iteration would be A(i, 0), where i is an incremental counter.

Furthermore, the two generators cannot currently be called from the stegano-lsb-set command line tool, as they expect two arguments n and m to be passed to them. These arguments are currently not grabbed by the parser.

Edit: Added body of the issue

@cedricbonhomme
Copy link
Owner

Indeed you are correct. But the actual behavior is intended. But I'll look if I can improve this. Also if by chance your updates are working you can make a PR.

@AdrienCos
Copy link
Contributor Author

By actual behaviour, do you mean generating a unique number, instead of a series of numbers? Or the fact that it cannot be called from the command line?

@cedricbonhomme
Copy link
Owner

Not usable from the command line.
You can use it when using Stegano as a library. But this is not a good function, it grows way to fast for iterating over pixels. At least when m>2.
So I was wondering if the better choice would be to move it in another module. I do not want to write too complex code just to solve this. Unless if I found something clean (for the command line).

@AdrienCos
Copy link
Contributor Author

Right, the rate of increase was another concern I have about it. I guess it can be useful to hide very little information in a very large image.

For the command line interface, I have figured out how to cleanly call the function and pass it its arguments. However, it is not very helpful, as the function only returns one number. This means that if you need more than 3 bits to store your data, it throw a StopIteration exception at the second call. If you changed the function to generate a series of numbers, then it could work.

@cedricbonhomme
Copy link
Owner

I think that passing only 'm' from the command line would be enough. I encapsulated the function in a generator:
5694e5c#diff-66cf8190313cbed61a14d04dc9a763d6R58

@cedricbonhomme cedricbonhomme added this to the Release 0.9.4 milestone May 31, 2019
@AdrienCos
Copy link
Contributor Author

I have added the feature for both ackermann generators (and encapsulated the slow one). The changes are available in the PR #26.

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

No branches or pull requests

2 participants