Skip to content

Commit

Permalink
Do not force ML loading unless needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
freddieknets committed Oct 24, 2022
1 parent 9d58869 commit ecd4444
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion xdyna/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .da import DA
from .da_meta import regenerate_da_metadata
from .protectfile import ProtectFile, get_hash
#from .sixtrack import particles_to_sixtrack_initial, sixtrack_initial_to_particles, sixtrack_dump2_to_particles

__version__ = '0.0.2'
9 changes: 4 additions & 5 deletions xdyna/da.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
import xobjects as xo
# import xtrack as xt
import xpart as xp

from .protectfile import ProtectFile
from .da_meta import _DAMetaData
from .ml import MLBorder
from .geometry import _bleed, distance_to_polygon_2D


Expand Down Expand Up @@ -72,7 +71,6 @@ def __init__(self, filename, *, min_turns=None, max_turns=None, nseeds=0, emitta
# ================ Generation of intial conditions ================
# =================================================================


def _prepare_generation(self, emittance=None, nseeds=None, pairs_shift=0, pairs_shift_var=None):
# Does survival already exist?
if self._surv is not None:
Expand Down Expand Up @@ -134,7 +132,7 @@ def _create_pairs(self):
def generate_random_initial(self, *, num_part=1000, r_max=25, px_norm=0, py_norm=0, zeta=0, delta=0.00027,
emittance=None, nseeds=None, pairs_shift=0, pairs_shift_var=None):
"""Generate the initial conditions in a 2D random grid.
traditionally this is .000000001
"""
self._prepare_generation(emittance, nseeds, pairs_shift, pairs_shift_var)
Expand Down Expand Up @@ -189,7 +187,7 @@ def generate_initial_radial(self, *, angles, r_min, r_max, r_step=None, r_num=No
px_norm=0, py_norm=0, zeta=0, delta=0.00027,
emittance=None, nseeds=None, pairs_shift=0, pairs_shift_var=None):
"""Generate the initial conditions in a 2D polar grid.
traditionally this is .000000001
"""
self._prepare_generation(emittance, nseeds, pairs_shift, pairs_shift_var)
Expand Down Expand Up @@ -255,6 +253,7 @@ def generate_initial_radial(self, *, angles, r_min, r_max, r_step=None, r_num=No

# Not allowed on parallel process
def add_random_initial(self, *, num_part=5000, min_turns=None):
from .ml import MLBorder

# TODO: make compatible with seeds and with pairs
if self.meta.nseeds > 0 or self.meta.pairs_shift != 0:
Expand Down

0 comments on commit ecd4444

Please sign in to comment.