Skip to content

Commit 799c249

Browse files
authored
Fix is_active check issue in cavity and dipole (#198)
* Fix `is_active` check issue in cavity and dipole * Update `CHANGELOG.md`
1 parent 2f6a332 commit 799c249

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 🚨 Breaking Changes
66

7-
- Cheetah is now vectorised. This means that you can run multiple simulations in parallel by passing a batch of beams and settings, resulting a number of interfaces being changed. For Cheetah developers this means that you now have to account for an arbitrary-dimensional tensor of most of the properties of you element, rather than a single value, vector or whatever else a property was before. (see #116, #157, #170, #172, #173) (@jank324, @cr-xu)
7+
- Cheetah is now vectorised. This means that you can run multiple simulations in parallel by passing a batch of beams and settings, resulting a number of interfaces being changed. For Cheetah developers this means that you now have to account for an arbitrary-dimensional tensor of most of the properties of you element, rather than a single value, vector or whatever else a property was before. (see #116, #157, #170, #172, #173, #198) (@jank324, @cr-xu)
88

99
### 🚀 Features
1010

cheetah/accelerator/cavity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262

6363
@property
6464
def is_active(self) -> bool:
65-
return any(self.voltage != 0)
65+
return torch.any(self.voltage != 0)
6666

6767
@property
6868
def is_skippable(self) -> bool:

cheetah/accelerator/dipole.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def is_skippable(self) -> bool:
9999

100100
@property
101101
def is_active(self):
102-
return any(self.angle != 0)
102+
return torch.any(self.angle != 0)
103103

104104
def transfer_map(self, energy: torch.Tensor) -> torch.Tensor:
105105
device = self.length.device
@@ -108,7 +108,7 @@ def transfer_map(self, energy: torch.Tensor) -> torch.Tensor:
108108
R_enter = self._transfer_map_enter()
109109
R_exit = self._transfer_map_exit()
110110

111-
if any(self.length != 0.0): # Bending magnet with finite length
111+
if torch.any(self.length != 0.0): # Bending magnet with finite length
112112
R = base_rmatrix(
113113
length=self.length,
114114
k1=torch.zeros_like(self.length),

0 commit comments

Comments
 (0)