Coverage for install/scipp/core/__init__.py: 0%
60 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-17 01:51 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-17 01:51 +0000
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3# @author Simon Heybrock
5# ruff: noqa: E402, F401, F403, F821
6from .._scipp import _debug_
8if _debug_:
9 import warnings
11 warnings.warn(
12 'You are running a "Debug" build of Scipp. '
13 'For optimal performance use a "Release" build.',
14 stacklevel=1,
15 )
16 del warnings
17del _debug_
19from .._scipp import __version__
20from .cpp_classes import (
21 Coords,
22 DataArray,
23 Dataset,
24 DefaultUnit,
25 DType,
26 GroupByDataArray,
27 GroupByDataset,
28 Masks,
29 Unit,
30 Variable,
31)
33# Import errors
34from .cpp_classes import (
35 BinEdgeError,
36 BinnedDataError,
37 CoordError,
38 DataArrayError,
39 DatasetError,
40 DimensionError,
41 DTypeError,
42 UnitError,
43 VariableError,
44 VariancesError,
45)
47from .operations import as_const
49from .data_group import DataGroup
50from .dimensions import (
51 _rename_dims,
52 _rename_variable,
53 _rename_data_array,
54 _rename_dataset,
55)
58from .deprecation import _deprecated_attrs, _deprecated_meta, _deprecated_drop_attrs
60DataArray.attrs = property(_deprecated_attrs)
61DataArray.meta = property(_deprecated_meta)
62DataArray.drop_attrs = _deprecated_drop_attrs
63del _deprecated_attrs, _deprecated_meta, _deprecated_drop_attrs
65for cls in (Variable, DataArray, Dataset):
66 cls.rename_dims = _rename_dims
67Variable.rename = _rename_variable
68DataArray.rename = _rename_data_array
69Dataset.rename = _rename_dataset
70del _rename_dims, _rename_variable, _rename_data_array, _rename_dataset, cls
72from .bins import _bins, _set_bins
74Variable.bins = property(_bins, _set_bins)
75DataArray.bins = property(_bins, _set_bins)
76Dataset.bins = property(_bins, _set_bins)
78from .structured import _fields
80Variable.fields = property(
81 _fields,
82 doc='Provides access to fields of structured types such as vectors or matrices.',
83)
84del _fields
86from .bins import Bins
88# Prevent unwanted conversion to numpy arrays by operations. Properly defining
89# __array_ufunc__ should be possible by converting non-scipp arguments to
90# variables. The most difficult part is probably mapping the ufunc to scipp
91# functions.
92for _cls in (Variable, DataArray, Dataset):
93 _cls.__array_ufunc__ = None
94del _cls
97from .arithmetic import add, divide, floor_divide, mod, multiply, negative, subtract
98from .binning import bin, group, hist, nanhist, rebin
99from .bins import Lookup, lookup, bins, bins_like
100from .comparison import (
101 less,
102 greater,
103 less_equal,
104 greater_equal,
105 equal,
106 not_equal,
107 identical,
108 isclose,
109 allclose,
110)
111from .counts import counts_to_density, density_to_counts
112from .cumulative import cumsum
113from .dataset import irreducible_mask
114from .groupby import groupby
115from .hyperbolic import sinh, cosh, tanh, asinh, acosh, atanh
116from .logical import logical_not, logical_and, logical_or, logical_xor
117from .math import (
118 abs,
119 cross,
120 dot,
121 nan_to_num,
122 norm,
123 reciprocal,
124 pow,
125 sqrt,
126 exp,
127 log,
128 log10,
129 round,
130 floor,
131 ceil,
132 erf,
133 erfc,
134 midpoints,
135)
136from .operations import (
137 islinspace,
138 issorted,
139 allsorted,
140 sort,
141 values,
142 variances,
143 stddevs,
144 where,
145 to,
146 merge,
147 label_based_index_to_positional_index,
148)
149from .reduction import (
150 mean,
151 nanmean,
152 median,
153 nanmedian,
154 std,
155 nanstd,
156 var,
157 nanvar,
158 sum,
159 nansum,
160 min,
161 max,
162 nanmin,
163 nanmax,
164 all,
165 any,
166)
167from .shape import broadcast, concat, fold, flatten, squeeze, transpose
168from .trigonometry import sin, cos, tan, asin, acos, atan, atan2
169from .unary import isnan, isinf, isfinite, isposinf, isneginf, to_unit
170from .variable import (
171 scalar,
172 index,
173 zeros,
174 ones,
175 empty,
176 full,
177 vector,
178 vectors,
179 array,
180 linspace,
181 geomspace,
182 logspace,
183 arange,
184 datetime,
185 datetimes,
186 epoch,
187)
188from .like import zeros_like, ones_like, empty_like, full_like
190from .assignments import assign_coords, assign_masks, assign_attrs
192Dataset.assign_coords = assign_coords
193DataArray.assign_coords = assign_coords
194DataArray.assign_masks = assign_masks
195DataArray.assign_attrs = assign_attrs
196del assign_coords, assign_masks, assign_attrs
198# Remove submodules to reduce clutter
199del (
200 arithmetic,
201 assignments,
202 binning,
203 comparison,
204 counts,
205 cpp_classes,
206 cumulative,
207 dataset,
208 data_group,
209 dimensions,
210 like,
211 logical,
212 math,
213 operations,
214 reduction,
215 shape,
216 structured,
217 trigonometry,
218 unary,
219 variable,
220)
222__all__ = [
223 '__version__',
224 'BinEdgeError',
225 'BinnedDataError',
226 'Bins',
227 'CoordError',
228 'Coords',
229 'DType',
230 'DTypeError',
231 'DataArray',
232 'DataArrayError',
233 'DataGroup',
234 'Dataset',
235 'DatasetError',
236 'DefaultUnit',
237 'DimensionError',
238 'GroupByDataArray',
239 'GroupByDataset',
240 'Lookup',
241 'Masks',
242 'Unit',
243 'UnitError',
244 'Variable',
245 'VariableError',
246 'VariancesError',
247 'abs',
248 'acos',
249 'acosh',
250 'add',
251 'all',
252 'allclose',
253 'allsorted',
254 'any',
255 'arange',
256 'array',
257 'as_const',
258 'asin',
259 'asinh',
260 'atan',
261 'atan2',
262 'atanh',
263 'bin',
264 'bins',
265 'bins_like',
266 'broadcast',
267 'ceil',
268 'concat',
269 'cos',
270 'cosh',
271 'counts_to_density',
272 'cross',
273 'cumsum',
274 'datetime',
275 'datetimes',
276 'density_to_counts',
277 'divide',
278 'dot',
279 'empty',
280 'empty_like',
281 'epoch',
282 'equal',
283 'erf',
284 'erfc',
285 'exp',
286 'flatten',
287 'floor',
288 'floor_divide',
289 'fold',
290 'full',
291 'full_like',
292 'geomspace',
293 'greater',
294 'greater_equal',
295 'group',
296 'groupby',
297 'hist',
298 'identical',
299 'index',
300 'irreducible_mask',
301 'isclose',
302 'isfinite',
303 'isinf',
304 'islinspace',
305 'isnan',
306 'isneginf',
307 'isposinf',
308 'issorted',
309 'label_based_index_to_positional_index',
310 'less',
311 'less_equal',
312 'linspace',
313 'log',
314 'log10',
315 'logical_and',
316 'logical_not',
317 'logical_or',
318 'logical_xor',
319 'logspace',
320 'lookup',
321 'max',
322 'mean',
323 'median',
324 'merge',
325 'midpoints',
326 'min',
327 'mod',
328 'multiply',
329 'nan_to_num',
330 'nanhist',
331 'nanmax',
332 'nanmean',
333 'nanmedian',
334 'nanmin',
335 'nanstd',
336 'nansum',
337 'nanvar',
338 'negative',
339 'norm',
340 'not_equal',
341 'ones',
342 'ones_like',
343 'pow',
344 'rebin',
345 'reciprocal',
346 'round',
347 'scalar',
348 'sin',
349 'sinh',
350 'sort',
351 'sqrt',
352 'squeeze',
353 'std',
354 'stddevs',
355 'subtract',
356 'sum',
357 'tan',
358 'tanh',
359 'to',
360 'to_unit',
361 'transpose',
362 'values',
363 'var',
364 'variances',
365 'vector',
366 'vectors',
367 'where',
368 'zeros',
369 'zeros_like',
370]