@@ -183,7 +183,7 @@ def cosmology(self) -> dict[str, Cosmology]:
183
183
"""
184
184
Get the cosmologies of the simulations in the collection
185
185
186
- Returns:
186
+ Returns
187
187
--------
188
188
cosmologies: dict[str, astropy.cosmology.Cosmology]
189
189
"""
@@ -194,7 +194,7 @@ def redshift(self) -> dict[str, float]:
194
194
"""
195
195
Get the redshift slices for the simulations in the collection
196
196
197
- Returns:
197
+ Returns
198
198
--------
199
199
redshifts: dict[str, float]
200
200
"""
@@ -205,7 +205,7 @@ def simulation(self) -> dict[str, SimulationParameters]:
205
205
"""
206
206
Get the simulation parameters for the simulations in the collection
207
207
208
- Returns:
208
+ Returns
209
209
--------
210
210
simulation_parameters: dict[str, opencosmo.parameters.SimulationParameters]
211
211
"""
@@ -254,6 +254,27 @@ def select(self, *args, **kwargs) -> SimulationCollection:
254
254
"""
255
255
return self .__map ("select" , * args , ** kwargs )
256
256
257
+ def take (self , n : int , at : str = "random" ) -> SimulationCollection :
258
+ """
259
+ Take a subest of rows from all datasets or collections in this collection.
260
+ This method will delegate to the underlying method in
261
+ :class:`opencosmo.Dataset`, or :class:`opencosmo.StructureCollection` depending
262
+ on the context. As such, behavior may vary depending on what this collection
263
+ contains. See their documentation for more info.
264
+
265
+ Parameters
266
+ ----------
267
+ n: int
268
+ The number of rows to take
269
+ at: str, default = "random"
270
+ The method to use to take rows. Must be one of "start", "end", "random".
271
+
272
+ """
273
+ if any (len (ds ) < n for ds in self .values ()):
274
+ raise ValueError (f"Not all datasets in this collection have at least { n } rows!" )
275
+ return self .__map ("take" , n , at )
276
+
277
+
257
278
def with_units (self , convention : str ) -> SimulationCollection :
258
279
"""
259
280
Transform all datasets or collections to use the given unit convention. This
@@ -268,15 +289,6 @@ def with_units(self, convention: str) -> SimulationCollection:
268
289
"""
269
290
return self .__map ("with_units" , convention )
270
291
271
- def take (self , * args , ** kwargs ) -> SimulationCollection :
272
- """
273
- Take a subest of rows from all datasets or collections in this collection.
274
- This method will delegate to the underlying method in
275
- :class:`opencosmo.Dataset`, or :class:`opencosmo.Collection` depending on the
276
- context. As such, behaviormay vary depending on what this collection contains.
277
- """
278
-
279
- return self .__map ("take" , * args , ** kwargs )
280
292
281
293
282
294
def open_single_dataset (
0 commit comments