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

Concatenate/consolidate all algorithms with different implementations #8098

Open
CaedenPH opened this issue Jan 25, 2023 · 12 comments · Fixed by #9228, #9358, #9482, #9769 or #10073
Open

Concatenate/consolidate all algorithms with different implementations #8098

CaedenPH opened this issue Jan 25, 2023 · 12 comments · Fixed by #9228, #9358, #9482, #9769 or #10073
Labels
enhancement This PR modified some existing files good first issue help wanted

Comments

@CaedenPH
Copy link
Contributor

Feature description

There are lots of algorithms with the same concept but different implementations/methods in different files. All these should be moved into one file

@CaedenPH CaedenPH added the enhancement This PR modified some existing files label Jan 25, 2023
@mahak-dev

This comment was marked as off-topic.

@dev-soni-07

This comment was marked as off-topic.

@tianyizheng02
Copy link
Contributor

@digital-dev-07 Read the contributing guidelines.

If you are interested in resolving an open issue, simply make a pull request with your proposed fix. We do not assign issues in this repo so please do not ask for permission to work on an issue.

@ChrisO345 ChrisO345 reopened this Oct 2, 2023
@CaedenPH CaedenPH changed the title Concatenate all algorithms with different implementations Concatenate/consolidate all algorithms with different implementations Oct 2, 2023
ChrisO345 pushed a commit that referenced this issue Oct 2, 2023
* Removed ciphers/rabin_miller.py as it is already there maths/miller_rabin.py

* Renamed miller_rabin.py to rabain_miller.py

* Restore ciphers/rabin_miller.py and removed maths/rabin_miller.py
@ChrisO345 ChrisO345 reopened this Oct 2, 2023
@Rishikesh63

This comment was marked as spam.

@ChrisO345
Copy link
Collaborator

!assign

Please read the contributing guidelines. We do not assign issues in this repository. Instead open a new pull request and add Fixes: #8098 to the description.

@anasadh

This comment was marked as off-topic.

anasadh added a commit to anasadh/Python that referenced this issue Oct 6, 2023
@tianyizheng02 tianyizheng02 reopened this Oct 6, 2023
@Pranjal-231003
Copy link

i want to contribute, may someone guide me bit of the process in it

@tianyizheng02
Copy link
Contributor

@Pranjal-231003 The issue here is that some algorithms have multiple implementations, and these implementations are often scattered across multiple files. Sometimes these files will have very different names or will be scattered across multiple directories. This is a problem because it makes it harder for users to compare implementations and harder for contributors to figure out whether an algorithm is in the repo or not. We want to put different implementations of the same algorithm into a single file so that it's all in one place.

For example, this repo used to have factorial_recursive.py and factorial_iterative.py. We combined them into a single file factorial.py, and this file contains both the recursive implementation and the iterative implementation. This is the work that we're asking contributors to do for this issue.

If you want to contribute to solving this issue, look around the codebase and find an algorithm that's implemented by multiple files. Choose one of those files to keep, and copy the code from the other files into this main file. You may need to rename the file or rename some functions when you do this. Once you're done with that and you've confirmed that everything still works, please open a PR and one of us maintainers will get around to reviewing it eventually.

@ChrisO345 ChrisO345 reopened this Oct 8, 2023
@tianyizheng02 tianyizheng02 reopened this Oct 9, 2023
@tianyizheng02 tianyizheng02 reopened this Oct 16, 2023
shivaparihar6119 added a commit to shivaparihar6119/Python that referenced this issue Oct 19, 2023
shivaparihar6119 added a commit to shivaparihar6119/Python that referenced this issue Oct 19, 2023
shivaparihar6119 added a commit to shivaparihar6119/Python that referenced this issue Oct 19, 2023
@adesh1998
Copy link

I am planning to work on this issue but I am having trouble creating a branch. Could you please help me understand?

@cclauss
Copy link
Member

cclauss commented Nov 4, 2023

The trick is to always create pull requests on a branch other than master.

  1. Go to https://github.com/adesh1998/Python and click the Sync fork button so your master is up-to-date
  2. Go to https://github.com/adesh1998/Python/branches and click the New branch button at the upper-right and give the branch a name that makes it clear what the intended change is.

If step 1. is not done before step 2. then previous edits can creep in.

@cclauss
Copy link
Member

cclauss commented Nov 5, 2023

Let's be super careful about deleting the hard work of other people.

@excellentpu
Copy link

excellentpu commented Nov 26, 2023

#EDIT:

This post seems to be this user's only contribution to GitHub -- https://github.com/excellentpu

@CaedenPH Based on your needs, I understand that you want to understand how to connect or merge all algorithms using different implementation methods. Here are some possible methods:

Use module import:
In Python, different algorithms can be imported in the form of modules. Create a main file (such as main.py), and then import functions or classes from maths/primelib.py. In this way, all algorithms can be called and managed in a central location.

main.py

from maths.primelib import function1, function2, ...

result1 = function1()
result2 = function2()

Create a collection of algorithm classes:
You can create a main class that instantiates and manages all other classes containing algorithms. In this way, all algorithms can be accessed through this main class.

main_class.py

from maths.primelib import AlgorithmClass1, AlgorithmClass2, ...

class MainAlgorithmClass:
    def init(self):
        self.algo1 = AlgorithmClass1()
        self.algo2 = AlgorithmClass2()

    def execute_algo1(self):
        return self.algo1.function()

    def execute_algo2(self):
        return self.algo2.function()

Using the plugin architecture:
For more complex situations, you can consider using a plugin architecture. This typically involves defining a set of interfaces, and then each algorithm implements these interfaces. The main program dynamically loads these plugins (algorithms) at runtime. This approach is more flexible, but it is also more complex to implement.

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