Skip to content

Commit

Permalink
Fix for amplitude_bell size offset (#50)
Browse files Browse the repository at this point in the history
* Fix to amplitude-bell size offset

* Updated amplitude test

* Test case to check anomaly sizes

* Update lengths test case

* Pre-commit confirm test_lengths.py

* Update to test_lengths

* Typecheck
  • Loading branch information
arrrrrmin authored Mar 6, 2024
1 parent b2b18ca commit d154e09
Show file tree
Hide file tree
Showing 4 changed files with 1,060 additions and 999 deletions.
11 changes: 7 additions & 4 deletions gutenTAG/anomalies/types/amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def generate(self, anomaly_protocol: AnomalyProtocol) -> AnomalyProtocol:

length = anomaly_protocol.end - anomaly_protocol.start
if anomaly_protocol.creeping_length == 0:
transition_length = int(length * 0.2)
plateau = np.ones(int(length * 0.6))
transition_length = int(round(length * 0.2))
plateau_length = length - 2 * transition_length
plateau = np.ones(plateau_length)
start_transition = norm.pdf(
np.linspace(-3, 0, transition_length), scale=1.05
)
Expand All @@ -47,11 +48,13 @@ def generate(self, anomaly_protocol: AnomalyProtocol) -> AnomalyProtocol:
)
else:
anomaly_length = length - anomaly_protocol.creeping_length
creeping_length = int(round(anomaly_length * 0.8))
creeping = self.generate_creeping(
anomaly_protocol, custom_anomaly_length=int(anomaly_length * 0.8)
anomaly_protocol, custom_anomaly_length=creeping_length
)
end_transition_length = anomaly_length - creeping_length
end_transition = norm.pdf(
np.linspace(0, 3, int(anomaly_length * 0.2)), scale=1.05
np.linspace(0, 3, end_transition_length), scale=1.05
)
amplitude_bell = np.concatenate(
[creeping, end_transition / end_transition.max()]
Expand Down
6 changes: 6 additions & 0 deletions tests/configs/example-config-amplitude.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ timeseries:
kinds:
- kind: amplitude
amplitude_factor: 2.0
- position: end
length: 47
channel: 0
kinds:
- kind: amplitude
amplitude_factor: 2.0
Loading

0 comments on commit d154e09

Please sign in to comment.