-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0c3f89
commit 999e5f6
Showing
18 changed files
with
171 additions
and
81 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ name: "piel-coverage" | |
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- develop | ||
|
||
defaults: | ||
run: | ||
|
@@ -55,3 +57,18 @@ jobs: | |
coverage report -m | ||
echo "total=$(coverage report --format=total)" >> $GITHUB_ENV | ||
echo '### Total coverage: ${{ env.total }}%' | ||
- name: "Create badge" | ||
# if: ${{ github.ref == 'refs/heads/latest' }} | ||
# https://gist.githubusercontent.com/nedbat/8c6980f77988a327348f9b02bbaf67f5 | ||
uses: schneegans/[email protected] | ||
with: | ||
auth: ${{ secrets.GH_PAT }} | ||
gistID: 605df9da19061593715258b77e06ab9b | ||
filename: piel_coverage.json | ||
label: Coverage | ||
message: ${{ env.total }}% | ||
minColorRange: 60 | ||
maxColorRange: 95 | ||
valColorRange: ${{ env.total }} | ||
style: "for-the-badge" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import jax.numpy as jnp | ||
from piel.materials.thermal_conductivity import aluminum | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"temperature, expected", | ||
[ | ||
( | ||
300, | ||
211.78811, | ||
), # Expected value needs to be calculated or verified beforehand | ||
(400, 236.965), # Example expected values, replace with correct ones | ||
], | ||
) | ||
def test_aluminum_correct_calculations(temperature, expected): | ||
material_ref = ("aluminum", "1100") | ||
result = aluminum(temperature, material_ref) | ||
assert jnp.isclose( | ||
result, expected, rtol=1e-4 | ||
), f"Expected {expected}, got {result}" | ||
|
||
|
||
def test_aluminum_invalid_specification(): | ||
with pytest.raises(ValueError): | ||
aluminum(300, ("aluminum", "9999")) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"temperature", | ||
[ | ||
300, # scalar | ||
jnp.array([300, 350]), # JAX array | ||
], | ||
) | ||
def test_aluminum_input_types(temperature): | ||
material_ref = ("aluminum", "1100") | ||
result = aluminum(temperature, material_ref) | ||
assert isinstance(result, jnp.ndarray), "Result should be a JAX array" |
39 changes: 39 additions & 0 deletions
39
tests/materials/thermal_conductivity/test_stainless_steel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import jax.numpy as jnp | ||
from piel.materials.thermal_conductivity import stainless_steel | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"temperature, specification, expected", | ||
[ | ||
(300, ("stainless_steel", "304"), 15.308), # Example expected value | ||
(400, ("stainless_steel", "310"), 13.542), # Example expected value | ||
(300, ("stainless_steel", "316"), 15.308), # Example expected value | ||
], | ||
) | ||
def test_stainless_steel_valid_specifications(temperature, specification, expected): | ||
result = stainless_steel(temperature, specification) | ||
assert jnp.isclose( | ||
result, expected, rtol=1e-4 | ||
), f"Expected {expected}, got {result}" | ||
|
||
|
||
def test_stainless_steel_invalid_specification(): | ||
with pytest.raises(ValueError): | ||
stainless_steel(300, ("stainless_steel", "999")) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"temperature, specification", | ||
[ | ||
(jnp.array([300, 350]), ("stainless_steel", "304")), | ||
(jnp.array([300, 350, 400]), ("stainless_steel", "310")), | ||
], | ||
) | ||
def test_stainless_steel_temperature_array_input(temperature, specification): | ||
results = stainless_steel(temperature, specification) | ||
assert isinstance(results, jnp.ndarray), "Expected results to be a JAX array" | ||
assert results.shape == temperature.shape, "Result array should match input shape" | ||
|
||
|
||
# Add additional tests to cover edge cases or specific behaviors |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from piel.types import PhysicalPort | ||
from piel.types import PhysicalConnection, Connection | ||
from piel.types import PhysicalComponent, Environment, Component | ||
|
||
|
||
def test_physical_port_initialization(): | ||
port = PhysicalPort() | ||
assert port.domain is None | ||
assert port.connector is None | ||
assert port.manifold is None | ||
|
||
|
||
def test_physical_port_assignment(): | ||
port = PhysicalPort(domain="DC", connector="USB-C", manifold="Top") | ||
assert port.domain == "DC" | ||
assert port.connector == "USB-C" | ||
assert port.manifold == "Top" | ||
|
||
|
||
def test_physical_connection_initialization(): | ||
conn = PhysicalConnection(connections=[]) | ||
assert isinstance(conn.connections, list) | ||
assert conn.components is None | ||
|
||
|
||
def test_physical_connection_with_components(): | ||
conn = PhysicalConnection(connections=[Connection()], components=(Component(),)) | ||
assert len(conn.connections) == 1 | ||
assert isinstance(conn.components, tuple) | ||
assert len(conn.components) == 1 | ||
|
||
|
||
def test_physical_component_initialization(): | ||
component = PhysicalComponent(ports=[PhysicalPort()], connections=[]) | ||
assert isinstance(component.ports, list) | ||
assert isinstance(component.connections, list) | ||
assert component.environment is None | ||
|
||
|
||
def test_physical_component_assignment(): | ||
component = PhysicalComponent( | ||
ports=[PhysicalPort(connector="HDMI")], | ||
connections=[PhysicalConnection(connections=[Connection()])], | ||
environment=Environment(), | ||
manufacturer="Example Corp", | ||
model="Model X", | ||
) | ||
assert component.manufacturer == "Example Corp" | ||
assert component.model == "Model X" | ||
assert isinstance(component.environment, Environment) |