Skip to content

Resonant Frequency & Electrical Impedance #6983

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

Merged
merged 24 commits into from
Oct 29, 2022

Conversation

SKVKPandey
Copy link
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 11, 2022
from math import sqrt


def resonant_frequency(inductance: float, capacitance: float) -> tuple:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tuple of what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tuple contains the values of inductance and capacitance that are required for calculating the resonant frequency of the LC Circuit.


else:
return (
"resonant_frequency",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you returning the function name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also the name of the value that the function is returning.

SKVKPandey and others added 6 commits October 15, 2022 09:40
Co-authored-by: Caeden <caedenperelliharris@gmail.com>
Co-authored-by: Caeden <caedenperelliharris@gmail.com>
Co-authored-by: Caeden <caedenperelliharris@gmail.com>
Co-authored-by: Paul <56065602+ZeroDayOwl@users.noreply.github.com>
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 19, 2022
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 19, 2022
@SKVKPandey SKVKPandey changed the title Resonant Frequency of LC Circuit Resonant Frequency & Electrical Impedance Oct 20, 2022
@SKVKPandey SKVKPandey requested review from ZeroDayOwl and CaedenPH and removed request for ZeroDayOwl and CaedenPH October 21, 2022 07:26
@@ -0,0 +1,41 @@
# https://en.wikipedia.org/wiki/Electrical_impedance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a brief description here about the impedance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the description for electrical impedance.

@@ -0,0 +1,41 @@
# https://en.wikipedia.org/wiki/LC_circuit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, perhaps add a brief explanation of LC circuits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the description for LC Circuit.

Comment on lines 13 to 22
>>> resonant_frequency(inductance=0, capacitance=5)
Traceback (most recent call last):
...
ValueError: Inductance cannot be 0 or negative
>>> resonant_frequency(inductance=10, capacitance=0)
Traceback (most recent call last):
...
ValueError: Capacitance cannot be 0 or negative
>>> resonant_frequency(inductance=10, capacitance=5)
('Resonant frequency', 0.022507907903927652)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These doctests are good, however following general conventions, maybe you can move the successful case/s before the failed ones.

Copy link
Contributor Author

@SKVKPandey SKVKPandey Oct 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the doctests according to the general conventions.

@SKVKPandey SKVKPandey requested a review from CaedenPH October 21, 2022 18:16
@SKVKPandey SKVKPandey removed the request for review from CaedenPH October 22, 2022 05:13
@SKVKPandey SKVKPandey requested a review from ZeroDayOwl October 22, 2022 05:13
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 22, 2022
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 22, 2022
SKVKPandey and others added 4 commits October 22, 2022 20:25
Co-authored-by: Paul <56065602+ZeroDayOwl@users.noreply.github.com>
Co-authored-by: Paul <56065602+ZeroDayOwl@users.noreply.github.com>
Co-authored-by: Paul <56065602+ZeroDayOwl@users.noreply.github.com>
@SKVKPandey SKVKPandey requested review from ZeroDayOwl and CaedenPH and removed request for ZeroDayOwl and CaedenPH October 22, 2022 15:00
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cclauss Can you review?

@cclauss cclauss merged commit bd50a30 into TheAlgorithms:master Oct 29, 2022
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 29, 2022
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

Successfully merging this pull request may close these issues.

4 participants