Skip to content

Commit

Permalink
fix saving to save_compressed
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsavel committed Feb 5, 2024
1 parent 9ce2d90 commit 81c2e7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
63 changes: 20 additions & 43 deletions docs/pages/Quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 5,
"id": "876f888c-355c-465e-ade9-fa4704c2d95c",
"metadata": {
"pycharm": {
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"id": "2a9a6c9c-adac-42ff-b5de-6a26ceac4c50",
"metadata": {
"pycharm": {
Expand Down Expand Up @@ -101,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "5b2755dd-2306-42d3-81e9-d1ae45370af6",
"metadata": {
"pycharm": {
Expand All @@ -112,10 +112,10 @@
{
"data": {
"text/plain": [
"<cortecs.opac.opac.Opac at 0x297d6f8b0>"
"<cortecs.opac.opac.Opac at 0x295857ac0>"
]
},
"execution_count": 3,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -140,7 +140,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"id": "8c135e9c-c761-4a01-baed-c3fd5c5efcf9",
"metadata": {
"pycharm": {
Expand All @@ -155,7 +155,7 @@
" 2.99401875e-05, 2.99700788e-05, 3.00000000e-05])"
]
},
"execution_count": 4,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -166,7 +166,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "11f481a7-46e4-4f59-87dd-56c034fd6315",
"metadata": {
"pycharm": {
Expand All @@ -183,7 +183,7 @@
" 2800., 2900., 3000.])"
]
},
"execution_count": 5,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -194,7 +194,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"id": "5826bbb6-a03a-47cb-8b89-c95c392bc38c",
"metadata": {
"pycharm": {
Expand All @@ -209,7 +209,7 @@
" 1.e+04, 1.e+05, 1.e+06, 1.e+07, 1.e+08])"
]
},
"execution_count": 6,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -250,7 +250,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "ae63d6af-b7c9-4df3-ae5c-e4eb2be7bde7",
"metadata": {
"pycharm": {
Expand All @@ -261,10 +261,10 @@
{
"data": {
"text/plain": [
"<cortecs.fit.fit.Fitter at 0x297d6f760>"
"<cortecs.fit.fit.Fitter at 0x295856ef0>"
]
},
"execution_count": 7,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -296,7 +296,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "e9754778-f19a-4ce3-ba56-3c4dc3fbe2c9",
"metadata": {
"pycharm": {
Expand All @@ -308,7 +308,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4616/4616 [00:00<00:00, 21241.55it/s]\n"
"100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4616/4616 [00:00<00:00, 25651.91it/s]\n"
]
}
],
Expand Down Expand Up @@ -336,7 +336,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"id": "b7dbc38e-7f27-4491-b35d-8622bc95fa5b",
"metadata": {
"pycharm": {
Expand All @@ -359,37 +359,14 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"id": "32c502d8-27c6-4e94-a4f4-9f29092c613b",
"metadata": {},
"outputs": [],
"source": [
"fitter.save(\"test_pca\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "2de506cd-b1e9-4c5c-a628-86a83d76bcd5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Quickstart.ipynb installation.rst test_pca_coeffs.npy\n",
"absorb_coeffs_C2H4.npy integrations.rst test_pca_vectors.npy\n",
"api.rst optimizing.ipynb versioning.rst\n",
"faq.rst pressures.npy wavelengths.npy\n",
"fitting_nn.ipynb quickstart.rst\n",
"fitting_polynomial.ipynb temperatures.npy\n"
]
}
],
"source": [
"ls"
]
},
{
"cell_type": "markdown",
"id": "b12fcc21-2ecc-415b-9993-b741ae15f707",
Expand All @@ -414,8 +391,8 @@
"metadata": {},
"outputs": [],
"source": [
"pca_coeffs = np.load(\"test_pca_coeffs.npy\")\n",
"vectors = np.load(\"test_pca_vectors.npy\")"
"pca_coeffs = np.load(\"test_pca_coeffs.npz\")[\"pca_coeffs\"]\n",
"vectors = np.load(\"test_pca_vectors.npy\")[\"vectors\"]"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions src/cortecs/fit/fit_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,4 @@ def save_pca(savename, fit_results):
"""
# pdb.set_trace()
vectors, beta = fit_results
np.save(savename + "_coeffs.npy", beta)
np.save(savename + "_vectors.npy", vectors)
np.savez_compressed(savename + "npz", pca_coeffs=beta, vectors=vectors)

0 comments on commit 81c2e7e

Please sign in to comment.