Skip to content

Commit

Permalink
Merge pull request #31 from Albericvgn/fane
Browse files Browse the repository at this point in the history
shakira shakira
  • Loading branch information
faneshala authored May 26, 2024
2 parents 828b05e + e0485d1 commit bc1c759
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_balance_chemical_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
import sys
import os
import pytest

try:
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
38 changes: 38 additions & 0 deletions tests/test_setup_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import numpy as np
import sys
import os
import pytest

try:
current_dir = os.path.dirname(os.path.abspath(__file__))
except NameError:
current_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
src_path = os.path.join(current_dir, '..', 'src')
sys.path.insert(0, src_path)


from chembalancer.chembalancer import setup_matrix

def test_setup_matrix():
# Test data
elements = ['H', 'C', 'O']
counts = [
{'H': 2, 'C': 1},
{'H': 2, 'O': 1},
{'C': 1, 'O': 1},
]

# Expected matrix
expected_matrix = np.array([
[2, 1, 0],
[2, 0, 1],
[0, 1, 1]
])

# Call the function
matrix = setup_matrix(elements, counts)

# Assertions
assert isinstance(matrix, np.ndarray), "Output should be a numpy array"
assert matrix.shape == expected_matrix.shape, "Matrix shape does not match"
assert np.array_equal(matrix, expected_matrix), "Matrix content does not match"

0 comments on commit bc1c759

Please sign in to comment.