-
Notifications
You must be signed in to change notification settings - Fork 3
clean-Up: Variational formulation #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3db25e5
c1a238a
855eed0
2144490
aa81eaf
b413aac
761ebfb
e5ef454
42014a7
f242ef3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| /.venv/ | ||
| /data/ | ||
| /img/ | ||
| /demo/ | ||
| /LICENSE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ venv/ | |
| .env | ||
| .env.local | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Caches | ||
| .ruff_cache/ | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,17 +6,29 @@ | |
| from .criteria_config import CriteriaConfig | ||
| from .layer import Layer, WeakLayer | ||
| from .model_input import ModelInput | ||
| from .segment import Segment | ||
| from .presets import ( | ||
| LESS_WEAK_LAYER, | ||
| VERY_WEAK_LAYER, | ||
| WEAK_LAYER, | ||
| WEAK_LAYER_PRESETS, | ||
| weak_layer_from_preset, | ||
| ) | ||
| from .scenario_config import ScenarioConfig, SystemType, TouchdownMode | ||
| from .segment import Segment | ||
|
|
||
| __all__ = [ | ||
| "Config", | ||
| "WeakLayer", | ||
| "Layer", | ||
| "Segment", | ||
| "CriteriaConfig", | ||
| "ScenarioConfig", | ||
| "Layer", | ||
| "LESS_WEAK_LAYER", | ||
| "ModelInput", | ||
| "ScenarioConfig", | ||
| "Segment", | ||
| "SystemType", | ||
| "TouchdownMode", | ||
| "VERY_WEAK_LAYER", | ||
| "WEAK_LAYER", | ||
| "WEAK_LAYER_PRESETS", | ||
| "WeakLayer", | ||
| "weak_layer_from_preset", | ||
| ] | ||
|
Comment on lines
19
to
34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Confirm Both Consider whether a name like 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||
| """Named presets for WEAC components.""" | ||||||
|
|
||||||
| from weac.components.layer import WeakLayer | ||||||
|
|
||||||
| _WEAK_LAYER_PARAMS: dict[str, dict] = { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Tighten the inner
♻️ Suggested type tightening-_WEAK_LAYER_PARAMS: dict[str, dict] = {
+_WEAK_LAYER_PARAMS: dict[str, dict[str, float | int]] = {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| "very_weak": { | ||||||
| "rho": 125, | ||||||
| "h": 10, | ||||||
| "sigma_c": 5.16, | ||||||
| "tau_c": 4.09, | ||||||
| "E": 2.0, | ||||||
| }, | ||||||
| "weak": { | ||||||
| "rho": 125, | ||||||
| "h": 10, | ||||||
| "sigma_c": 6.16, | ||||||
| "tau_c": 5.09, | ||||||
| "E": 2.0, | ||||||
| }, | ||||||
| "less_weak": { | ||||||
| "rho": 125, | ||||||
| "h": 10, | ||||||
| "sigma_c": 7.16, | ||||||
| "tau_c": 6.09, | ||||||
| "E": 2.0, | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
| VERY_WEAK_LAYER = WeakLayer(**_WEAK_LAYER_PARAMS["very_weak"]) | ||||||
| WEAK_LAYER = WeakLayer(**_WEAK_LAYER_PARAMS["weak"]) | ||||||
| LESS_WEAK_LAYER = WeakLayer(**_WEAK_LAYER_PARAMS["less_weak"]) | ||||||
|
|
||||||
| WEAK_LAYER_PRESETS: dict[str, WeakLayer] = { | ||||||
| "very_weak": VERY_WEAK_LAYER, | ||||||
| "weak": WEAK_LAYER, | ||||||
| "less_weak": LESS_WEAK_LAYER, | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| def weak_layer_from_preset(name: str, **overrides) -> WeakLayer: | ||||||
| """Create a WeakLayer from a named preset, with optional overrides. | ||||||
|
|
||||||
| Without overrides, returns the shared frozen instance. | ||||||
| With overrides, returns a new instance. | ||||||
| """ | ||||||
| if name not in _WEAK_LAYER_PARAMS: | ||||||
| raise ValueError( | ||||||
| f"Unknown preset '{name}'. Available: {list(_WEAK_LAYER_PARAMS)}" | ||||||
| ) | ||||||
| if not overrides: | ||||||
| return WEAK_LAYER_PRESETS[name] | ||||||
| params = {**_WEAK_LAYER_PARAMS[name], **overrides} | ||||||
|
Comment on lines
+40
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid override keys raise When Either document the behaviour, or catch and re-raise for a uniform error surface: 🛡️ Proposed fix to normalise exceptions+from pydantic import ValidationError
+
def weak_layer_from_preset(name: str, **overrides) -> WeakLayer:
"""Create a WeakLayer from a named preset, with optional overrides.
Without overrides, returns the shared frozen instance.
With overrides, returns a new instance.
+
+ Raises:
+ ValueError: If *name* is not a known preset or an override key is
+ not a valid WeakLayer field.
"""
if name not in _WEAK_LAYER_PARAMS:
raise ValueError(
f"Unknown preset '{name}'. Available: {list(_WEAK_LAYER_PARAMS)}"
)
if not overrides:
return WEAK_LAYER_PRESETS[name]
params = {**_WEAK_LAYER_PARAMS[name], **overrides}
- return WeakLayer(**params)
+ try:
+ return WeakLayer(**params)
+ except ValidationError as exc:
+ raise ValueError(
+ f"Invalid override for preset '{name}': {exc}"
+ ) from exc🤖 Prompt for AI Agents |
||||||
| return WeakLayer(**params) | ||||||
Uh oh!
There was an error while loading. Please reload this page.