Skip to content

Commit

Permalink
ohmslaw 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanBindez committed Jul 5, 2024
1 parent 0052e8e commit d00da13
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 44 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

git add .
git commit -m 'ohmslaw 2.0.0'
git commit -m 'ohmslaw 2.1.1'
git push -u origin main
git tag v2.0.0
git tag v2.1.1
git push --tag
make clean
make upload
13 changes: 0 additions & 13 deletions docs/user/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ Watts:
$ ohmslaw watts -R 15 -I 20
Find resistor:

.. code:: bash
$ ohmslaw find_resistor --source 10 --component_voltage 2
Series:

Expand All @@ -48,13 +42,6 @@ Parallel:
$ ohmslaw parallel 5 10 15
Best combination:

.. code:: bash
$ ohmslaw best_combination -sv 12 -cv 5 -cc 0.02 -r 100 20 3 450 550
To list all command line options, simply type

.. code:: bash
Expand Down
27 changes: 0 additions & 27 deletions ohmslaw/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ def calculate_watts(I, R):
ohms = Ohms()
return ohms.watts(I, R)

def find_resistor(source, component_voltage, component_current=0.02):
"""Calculate resistor value to limit current."""
ohms = Ohms()
return ohms.find_resistor(source, component_voltage, component_current)

def calculate_series(*resistors):
"""Calculate total resistance for resistors in series."""
ohms = Ohms()
Expand All @@ -36,10 +31,6 @@ def calculate_parallel(*resistors):
ohms = Ohms()
return ohms.parallel(*resistors)

def calculate_best_combination(source_voltage, component_voltage, component_current, resistors):
"""Find the best combination of resistors."""
ohms = Ohms()
return ohms.best_combination(source_voltage, component_voltage, component_current, resistors)

def main() -> str:
parser = argparse.ArgumentParser(description="Perform electrical calculations based on Ohm's Law")
Expand All @@ -64,12 +55,6 @@ def main() -> str:
watts_parser.add_argument('-R', type=float, required=True, help='Resistance in ohms')
watts_parser.add_argument('-I', type=float, required=True, help='Current in amperes')

# Subparser for find_resistor operation
find_resistor_parser = subparsers.add_parser('find_resistor', help='Calculate resistor value to limit current')
find_resistor_parser.add_argument('--source', type=float, required=True, help='Source voltage in volts')
find_resistor_parser.add_argument('--component_voltage', type=float, required=True, help='Component voltage in volts')
find_resistor_parser.add_argument('--component_current', type=float, default=0.02, help='Component current in amperes (default: 0.02)')

# Subparser for series operation
series_parser = subparsers.add_parser('series', help='Calculate total resistance for resistors in series')
series_parser.add_argument('resistors', type=float, nargs='+', help='List of resistances in ohms')
Expand All @@ -78,13 +63,6 @@ def main() -> str:
parallel_parser = subparsers.add_parser('parallel', help='Calculate total resistance for resistors in parallel')
parallel_parser.add_argument('resistors', type=float, nargs='+', help='List of resistances in ohms')

# Subparser for best_combination operation
best_combination_parser = subparsers.add_parser('best_combination', help='Find the best combination of resistors')
best_combination_parser.add_argument('-sv', '--source_voltage', type=float, required=True, help='Source voltage in volts')
best_combination_parser.add_argument('-cv', '--component_voltage', type=float, required=True, help='Component voltage in volts')
best_combination_parser.add_argument('-cc', '--component_current', type=float, required=True, help='Component current in amperes')
best_combination_parser.add_argument('-r', '--resistors', type=float, nargs='+', required=True, help='List of available resistors in ohms')

args = parser.parse_args()

result = None
Expand All @@ -97,15 +75,10 @@ def main() -> str:
result = str(calculate_resistance(args.V, args.I)) + " Ohms"
elif args.operation == 'watts':
result = str(calculate_watts(args.R, args.I)) + " Watts"
elif args.operation == 'find_resistor':
result = str(find_resistor(args.source, args.component_voltage, args.component_current)) + " Ohms"
elif args.operation == 'series':
result = str(calculate_series(*args.resistors)) + " Ohms"
elif args.operation == 'parallel':
result = str(calculate_parallel(*args.resistors)) + " Ohms"
elif args.operation == 'best_combination':
combination, voltage = calculate_best_combination(args.source_voltage, args.component_voltage, args.component_current, args.resistors)
result = f"Best combination: {combination} with voltage: {voltage} V"

return result

Expand Down
2 changes: 1 addition & 1 deletion ohmslaw/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.0"
__version__ = "2.1.1"

if __name__ == "__main__":
print(__version__)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ohmslaw"
version = "2.0.0"
version = "2.1.1"
authors = [
{ name="Juan Bindez", email="juanbindez780@gmail.com" },
]
Expand Down

0 comments on commit d00da13

Please sign in to comment.