@@ -71,12 +71,20 @@ def _apply_box_wrap(
7171 :class:`~swiftsimio.objects.cosmo_array`
7272 The coordinates wrapped to lie within the box dimensions.
7373 """
74+ rotation_is_identity = (
75+ True
76+ if current_transform is None
77+ else current_transform .rotation .approx_equal (Rotation .identity ())
78+ )
79+ # in scipy 1.16 approx_equal returns bool, in 1.17 returns array of bool, so:
80+ rotation_is_identity = (
81+ rotation_is_identity .all ()
82+ if hasattr (rotation_is_identity , "all" )
83+ else rotation_is_identity
84+ )
7485 if boxsize is None :
7586 return coords
76- elif (
77- current_transform is None
78- or (current_transform .rotation .approx_equal (Rotation .identity ())).squeeze ()
79- ):
87+ elif current_transform is None or rotation_is_identity :
8088 return (coords + offset_frac * boxsize ) % boxsize - offset_frac * boxsize
8189 else :
8290 return _apply_rotation (
@@ -1566,10 +1574,8 @@ def __init__(
15661574 self .id_particle_dataset_name = id_particle_dataset_name
15671575 self .coordinates_dataset_name = coordinates_dataset_name
15681576 self .velocities_dataset_name = velocities_dataset_name
1569- if not hasattr (self , "_coordinate_like_transform" ):
1570- self ._coordinate_like_transform = RigidTransform .identity ()
1571- if not hasattr (self , "_velocity_like_transform" ):
1572- self ._velocity_like_transform = RigidTransform .identity ()
1577+ self ._coordinate_like_transform = RigidTransform .identity ()
1578+ self ._velocity_like_transform = RigidTransform .identity ()
15731579 if self .halo_catalogue is None :
15741580 # in server mode we don't have a halo_catalogue yet
15751581 self ._spatial_mask = getattr (self , "_spatial_mask" , None )
@@ -1790,15 +1796,10 @@ def _copyinit(
17901796 """
17911797 sg = cls .__new__ (cls )
17921798 sg ._spatial_mask = _spatial_mask
1793- sg ._extra_mask = _extra_mask
1794- if _coordinate_like_transform is not None :
1795- sg ._coordinate_like_transform = _coordinate_like_transform
1796- if _velocity_like_transform is not None :
1797- sg ._velocity_like_transform = _velocity_like_transform
17981799 SWIFTGalaxy .__init__ (
17991800 sg ,
18001801 snapshot_filename ,
1801- halo_catalogue ,
1802+ halo_catalogue = None ,
18021803 auto_recentre = auto_recentre ,
18031804 transforms_like_coordinates = transforms_like_coordinates ,
18041805 transforms_like_velocities = transforms_like_velocities ,
@@ -1808,6 +1809,13 @@ def _copyinit(
18081809 coordinate_frame_from = coordinate_frame_from ,
18091810 _data_server = _data_server ,
18101811 )
1812+ if _extra_mask is not None :
1813+ sg ._extra_mask = _extra_mask
1814+ if _coordinate_like_transform is not None :
1815+ sg ._coordinate_like_transform = _coordinate_like_transform
1816+ if _velocity_like_transform is not None :
1817+ sg ._velocity_like_transform = _velocity_like_transform
1818+ sg .halo_catalogue = halo_catalogue
18111819 return sg
18121820
18131821 def __str__ (self ) -> str :
@@ -1930,8 +1938,8 @@ def _data_copy(
19301938 velocities_dataset_name = deepcopy (self .velocities_dataset_name ),
19311939 _spatial_mask = self ._spatial_mask ,
19321940 _extra_mask = deepcopy (self ._extra_mask ),
1933- _coordinate_like_transform = deepcopy (self ._coordinate_like_transform ),
1934- _velocity_like_transform = deepcopy (self ._velocity_like_transform ),
1941+ _coordinate_like_transform = copy (self ._coordinate_like_transform ),
1942+ _velocity_like_transform = copy (self ._velocity_like_transform ),
19351943 _data_server = _data_server ,
19361944 )
19371945 for particle_name in sg .metadata .present_group_names :
0 commit comments