Skip to content

Commit

Permalink
fix: fixes interactive function inspection and cleans dependencies
Browse files Browse the repository at this point in the history
fixes #27, fixes #28
  • Loading branch information
eckelsjd committed Nov 5, 2024
1 parent 3b5f054 commit 569a4d9
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 89 deletions.
110 changes: 34 additions & 76 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ dependencies = [
"scipy>=1.14",
"matplotlib>=3.9",
"networkx>=3.2",
"uqtils>=0.4",
"scikit-learn>=1.3",
"pyyaml>=6.0.2",
"pydantic>=2.9.1",
"dill>=0.3.9",
]
requires-python = ">=3.11"
readme = "README.md"
Expand Down Expand Up @@ -84,6 +83,7 @@ dev = [
test = [
"pytest>=7.4",
"pytest-cov>=4.1",
"uqtils>=0.4.2",
]
doc = [
"mkdocs>=1.5",
Expand Down
12 changes: 6 additions & 6 deletions src/amisc/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import numpy as np
import yaml
from pydantic import BaseModel, ConfigDict, Field, field_validator
from uqtils import ax_default

from amisc.component import Component, IndexSet, MiscTree
from amisc.serialize import Serializable, _builtin
Expand Down Expand Up @@ -1456,10 +1455,10 @@ def plot_slice(self, inputs: list[str] = None,
y_surr = output_slices_surr[output_var][:, j]
ax.plot(x, y_surr, '--r', label='Surrogate')

ylabel = ylabels[i] if j == 0 else ''
xlabel = xlabels[j] if i == len(outputs) - 1 else ''
legend = (i == 0 and j == len(inputs) - 1)
ax_default(ax, xlabel, ylabel, legend=legend)
ax.set_xlabel(xlabels[j] if i == len(outputs) - 1 else '')
ax.set_ylabel(ylabels[i] if j == 0 else '')
if i == 0 and j == len(inputs) - 1:
ax.legend()
fig.set_size_inches(subplot_size_in * len(inputs), subplot_size_in * len(outputs))
fig.tight_layout()

Expand Down Expand Up @@ -1580,7 +1579,8 @@ def plot_allocation(self, cmap: str = 'Blues', text_bar_width: float = 0.06, arr
arrowprops={'arrowstyle': '->', 'linewidth': 1})
else:
pass # Don't label really small bars
ax_default(ax, '', "Fraction of total cost", legend=False)
ax.set_xlabel('')
ax.set_ylabel('Fraction of total cost')
ax.set_xticks(x, xlabels)
ax.set_xlim(left=-1, right=x[-1] + 1)

Expand Down
6 changes: 2 additions & 4 deletions src/amisc/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
import numpy as np
from numpy.typing import ArrayLike
from scipy.optimize import direct
from sklearn.linear_model import Ridge
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import MaxAbsScaler

from amisc.serialize import PickleSerializable, Serializable
from amisc.typing import LATENT_STR_ID, Dataset, MultiIndex
from amisc.utils import _RidgeRegression

__all__ = ['TrainingData', 'SparseGrid']

Expand Down Expand Up @@ -269,7 +267,7 @@ def impute_missing_data(self, alpha: MultiIndex, beta: MultiIndex):
yi_mat = np.concatenate([yi_all[var][:, np.newaxis] if len(yi_all[var].shape) == 1 else
yi_all[var].reshape((N, -1)) for var in output_vars], axis=-1)

imputer = Pipeline([('scaler', MaxAbsScaler()), ('model', Ridge(alpha=1))])
imputer = _RidgeRegression(alpha=1.0)
imputer.fit(xi_mat, yi_mat)

# Run the imputer for this coordinate
Expand Down
Loading

0 comments on commit 569a4d9

Please sign in to comment.