Skip to content

Commit

Permalink
fix a bug in the shape of the return in GetDischargeCapacities
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandezfran committed Feb 5, 2024
1 parent 3e215a5 commit 4ebaf59
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog of galpynostatic

## v0.3.3 (2024-02-05)

- Fix a bug in the shape of the return of `GetDischargeCapacities` in `preprocessing` module.
- Change the `if/else` condition in the `datasets` submodule by a `try/except` block.


## v0.3.2 (2024-01-30)

- `base` and `utils` modules are now tested directly.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/heuristic_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@
}
],
"source": [
"d_new, d_new_err = gp.make_prediction.optimal_particle_size(greg)\n",
"d_new, d_new_err = gp.make_prediction.optimal_particle_size(greg, d0=1e-5)\n",
"print(f\"{d_new:.3f} +/- {d_new_err:.3f} micrometers\")"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/map-driven_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}
],
"source": [
"spherical = gp.datasets.load_spherical()\n",
"spherical = gp.datasets.load_dataset(\"spherical\")\n",
"greg = gp.model.GalvanostaticRegressor(d=d)\n",
"\n",
"for m in (\"A\", \"B\"):\n",
Expand Down
6 changes: 3 additions & 3 deletions galpynostatic/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def load_dataset(geometry="spherical"):
ValueError
If the geometry is not `"spherical"`, `"cylindrical"` or `"planar"`.
"""
if geometry not in ("spherical", "cylindrical", "planar"):
raise ValueError(f"{geometry} is not a valid geometry.")
else:
try:
return pd.read_csv(PATH / f"{geometry}.csv")
except FileNotFoundError:
raise ValueError(f"{geometry} is not a valid geometry.")
6 changes: 3 additions & 3 deletions galpynostatic/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def transform(self, X):
Returns
-------
X_new : array-like of shape (n_measurements, 1)
X_new : array-like of shape (n_measurements, )
Discharge capacities in the same order as the ``pandas.DataFrame``
in the input list, but reshaped to fit.
"""
Expand All @@ -110,7 +110,7 @@ def transform(self, X):
except IndexError:
...

return X_new.reshape(-1, 1)
return X_new

def fit_transform(self, X, y=None, **fit_params):
"""Transform the curves to discharge capacities with optional params.
Expand All @@ -130,7 +130,7 @@ def fit_transform(self, X, y=None, **fit_params):
Returns
-------
X_new : array-like of shape (n_measurements, 1)
X_new : array-like of shape (n_measurements, )
Discharge capacities in the same order as the ``pandas.DataFrame``
in the input list, but reshaped to fit.
"""
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "galpynostatic"
version = "0.3.2"
version = "0.3.3"
authors = [{name = "Francisco Fernandez", email = "ffernandev@gmail.com"}]
readme = "README.md"
license = {file = "LICENSE"}
Expand All @@ -40,12 +40,12 @@ classifiers = [
]
urls = { Homepage = "https://github.com/fernandezfran/galpynostatic" }
dependencies = [
"importlib_metadata",
"matplotlib",
"numpy",
"pandas",
"scikit-learn",
"scipy",
"importlib_metadata",
]

[tool.setuptools]
Expand Down
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def nishikawa():
"ref": {
"dc": np.array(
[0.37869504, 0.3709768, 0.3157027, 0.2755689, 0.19977959]
).reshape(-1, 1),
),
"dcoeff": 1.0e-9,
"k0": 1.0e-6,
"dcoeff_err": 2.018390e-10,
Expand Down Expand Up @@ -141,7 +141,7 @@ def he():
"ref": {
"dc": np.array(
[159.23154, 153.38335, 135.33395, 104.71328, 55.44732]
).reshape(-1, 1),
),
"dcoeff": 1.0e-11,
"k0": 1.0e-8,
"dcoeff_err": 1.804718e-12,
Expand Down Expand Up @@ -182,7 +182,7 @@ def wang():
"ref": {
"dc": np.array(
[99.417946, 96.75683, 93.01233, 83.45085, 73.432816, 56.96607]
).reshape(-1, 1),
),
"dcoeff": 1.0e-8,
"k0": 1.0e-6,
"dcoeff_err": 3.704666e-09,
Expand Down Expand Up @@ -230,7 +230,7 @@ def lei():
3.5315654,
1.6230893,
]
).reshape(-1, 1),
),
"dcoeff": 1.0e-13,
"k0": 1.0e-8,
"dcoeff_err": 2.834146e-15,
Expand Down Expand Up @@ -278,7 +278,7 @@ def bak():
92.15335,
55.795765,
]
).reshape(-1, 1),
),
"dcoeff": 1.0e-13,
"k0": 1.0e-8,
"dcoeff_err": 4.435332e-12,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def test_get_discharge_capacities_internal_raise():
gdc = galpynostatic.preprocessing.GetDischargeCapacities(1.0)
dc = gdc.fit_transform(dfs)

np.testing.assert_array_almost_equal(dc, [[0]])
np.testing.assert_array_almost_equal(dc, [0])

0 comments on commit 4ebaf59

Please sign in to comment.