Skip to content

Commit

Permalink
feat: rename extrucal.py and throughput()
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwslee committed Feb 22, 2022
1 parent 0aa1ca0 commit 2f130a5
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 44 deletions.
214 changes: 204 additions & 10 deletions README.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ pip install extrucal

## Package Functions

- `throughput()`
- `throughput_cal()`
- This function calculates the extrusion throughput (Drag Flow) given the screw size, RPM, the channel depth of metering channel, and screw pitch

- `throughput_table()`
Expand All @@ -35,7 +35,7 @@ $ pip install extrucal
`extrucal` can be used to calculate throughput in extrusion processes and to generate table and plot for throughput as a function of screw RPM and channel depth in the metering section of screw

```python
from extrucal.extrucal import throughput, throughput_table, throughput_plot
from extrucal.extrusion import throughput_cal, throughput_table, throughput_plot
```

## Dependencies
Expand Down
17 changes: 12 additions & 5 deletions docs/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"metadata": {},
"outputs": [],
"source": [
"from extrucal.extrucal import throughput, throughput_table, throughput_plot"
"from extrucal.extrusion import throughput_cal, throughput_table, throughput_plot"
]
},
{
Expand Down Expand Up @@ -51,7 +51,7 @@
}
],
"source": [
"throughput(200, 10, 800)"
"throughput_cal(200, 10, 800)"
]
},
{
Expand Down Expand Up @@ -236,13 +236,13 @@
"data": {
"text/html": [
"\n",
"<div id=\"altair-viz-3564b54a014b4e35869b29ecde8e17eb\"></div>\n",
"<div id=\"altair-viz-54e6539e94aa4e93a7e73d93a47485d4\"></div>\n",
"<script type=\"text/javascript\">\n",
" var VEGA_DEBUG = (typeof VEGA_DEBUG == \"undefined\") ? {} : VEGA_DEBUG;\n",
" (function(spec, embedOpt){\n",
" let outputDiv = document.currentScript.previousElementSibling;\n",
" if (outputDiv.id !== \"altair-viz-3564b54a014b4e35869b29ecde8e17eb\") {\n",
" outputDiv = document.getElementById(\"altair-viz-3564b54a014b4e35869b29ecde8e17eb\");\n",
" if (outputDiv.id !== \"altair-viz-54e6539e94aa4e93a7e73d93a47485d4\") {\n",
" outputDiv = document.getElementById(\"altair-viz-54e6539e94aa4e93a7e73d93a47485d4\");\n",
" }\n",
" const paths = {\n",
" \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
Expand Down Expand Up @@ -303,6 +303,13 @@
"source": [
"throughput_plot(200, 800)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
8 changes: 4 additions & 4 deletions src/extrucal/extrucal.py → src/extrucal/extrusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



def throughput(size, depth, density, rpm=1, pitch=None, w_flight=None, n_flight=1):
def throughput_cal(size, depth, density, rpm=1, pitch=None, w_flight=None, n_flight=1):
"""
Calculates the extrusion throughput (Drag Flow) given the screw size, RPM,
the channel depth of metering channel, and screw pitch
Expand Down Expand Up @@ -37,7 +37,7 @@ def throughput(size, depth, density, rpm=1, pitch=None, w_flight=None, n_flight=
Examples
--------
>>> throughput(size=200, depth=10, density=800)
>>> throughput_cal(size=200, depth=10, density=800)
"""

# Test input type
Expand Down Expand Up @@ -256,7 +256,7 @@ def throughput_table(
rpm_title = [f"rpm={k}" for k in np.arange(min_rpm, max_rpm+0.1, delta_rpm)]
for d in depth:
for r in rpm:
throughput_list.append(throughput(size, d, density, r, pitch, w_flight, n_flight))
throughput_list.append(throughput_cal(size, d, density, r, pitch, w_flight, n_flight))
table[f"depth={d}"] = throughput_list
throughput_list = []
table_df = pd.DataFrame(table, index=rpm_title)
Expand Down Expand Up @@ -397,7 +397,7 @@ def throughput_plot(
rpm = [j for j in np.arange(min_rpm, max_rpm+0.1, delta_rpm)]
for d in depth:
for r in rpm:
throughput_list.append(throughput(size, d, density, r, pitch, w_flight, n_flight))
throughput_list.append(throughput_cal(size, d, density, r, pitch, w_flight, n_flight))
table[d] = throughput_list
throughput_list = []
table_df = pd.DataFrame(table, index=rpm)
Expand Down
46 changes: 23 additions & 23 deletions tests/test_extrucal.py → tests/test_extrusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import numpy as np
import altair as alt
from extrucal.extrucal import throughput, throughput_table, throughput_plot
from extrucal.extrusion import throughput_cal, throughput_table, throughput_plot
alt.renderers.enable('html')

def test_input_data():
Expand All @@ -16,19 +16,19 @@ def test_input_data():
# Test input types

with pytest.raises(TypeError):
throughput("200", 10, 800)
throughput_cal("200", 10, 800)
with pytest.raises(TypeError):
throughput(200, "10", 800)
throughput_cal(200, "10", 800)
with pytest.raises(TypeError):
throughput(200, 10, "800")
throughput_cal(200, 10, "800")
with pytest.raises(TypeError):
throughput(200, 10, 800, rpm="1")
throughput_cal(200, 10, 800, rpm="1")
with pytest.raises(TypeError):
throughput(200, 10, 800, pitch="200")
throughput_cal(200, 10, 800, pitch="200")
with pytest.raises(TypeError):
throughput(200, 10, 800, w_flight="20")
throughput_cal(200, 10, 800, w_flight="20")
with pytest.raises(TypeError):
throughput(200, 10, 800, n_flight=1.0)
throughput_cal(200, 10, 800, n_flight=1.0)

with pytest.raises(TypeError):
throughput_table("200", 800)
Expand Down Expand Up @@ -79,27 +79,27 @@ def test_input_data():
# Test input values

with pytest.raises(ValueError):
throughput(200, 1, 800)
throughput_cal(200, 1, 800)
with pytest.raises(ValueError):
throughput(200, 61, 800)
throughput_cal(200, 61, 800)
with pytest.raises(ValueError):
throughput(4, 1, 800)
throughput_cal(4, 1, 800)
with pytest.raises(ValueError):
throughput(501, 20, 800)
throughput_cal(501, 20, 800)
with pytest.raises(ValueError):
throughput(200, 10, 290)
throughput_cal(200, 10, 290)
with pytest.raises(ValueError):
throughput(200, 10, 3001)
throughput_cal(200, 10, 3001)
with pytest.raises(ValueError):
throughput(200, 10, 800, pitch=39)
throughput_cal(200, 10, 800, pitch=39)
with pytest.raises(ValueError):
throughput(200, 10, 800, pitch=501)
throughput_cal(200, 10, 800, pitch=501)
with pytest.raises(ValueError):
throughput(200, 10, 800, w_flight=1.9)
throughput_cal(200, 10, 800, w_flight=1.9)
with pytest.raises(ValueError):
throughput(200, 10, 800, w_flight=141)
throughput_cal(200, 10, 800, w_flight=141)
with pytest.raises(ValueError):
throughput(200, 10, 800, n_flight=3)
throughput_cal(200, 10, 800, n_flight=3)

with pytest.raises(ValueError):
throughput_table(200, 800, min_depth = 1)
Expand Down Expand Up @@ -154,19 +154,19 @@ def test_output():
# Test the output of throughput()

expected1 = 23.51
actual1 = throughput(200, 10, 800, rpm=1, pitch=200, w_flight=20, n_flight=1)
actual1 = throughput_cal(200, 10, 800, rpm=1, pitch=200, w_flight=20, n_flight=1)
assert actual1 == expected1, "Calculated Value is wrong!!!"

expected2 = 4540.04
actual2 = throughput(250, 12, 800, rpm=100, pitch=300, w_flight=25, n_flight=2)
actual2 = throughput_cal(250, 12, 800, rpm=100, pitch=300, w_flight=25, n_flight=2)
assert actual2 == expected2, "Calculated Value is wrong!!!"

expected3 = 1.69
actual3 = throughput(20, 2, 1000, rpm=30, pitch=20, w_flight=2, n_flight=1)
actual3 = throughput_cal(20, 2, 1000, rpm=30, pitch=20, w_flight=2, n_flight=1)
assert actual3 == expected3, "Calculated Value is wrong!!!"

expected4 = 12.24
actual4 = throughput(150, 6.8, 800, rpm=1, pitch=206, w_flight=9, n_flight=1)
actual4 = throughput_cal(150, 6.8, 800, rpm=1, pitch=206, w_flight=9, n_flight=1)
assert actual4 == expected4, "Calculated Value is wrong!!!"

# Test the output of throughput_table()
Expand Down

0 comments on commit 2f130a5

Please sign in to comment.