Coverage for install/scipp/__init__.py: 0%
83 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
4# ruff: noqa: E402, F401, F821
5"""Multi-dimensional data arrays with labeled dimensions.
7Scipp provides
9* Physical units are stored with each data or coord array and are handled in arithmetic operations.
10* Histograms, i.e., bin-edge axes, which are by 1 longer than the data extent.
11* Support for non-regular or scattered data and non-destructive binning.
12* Support for masks stored with data.
13* Propagation of uncertainties.
15See the online documentation for user guides and an API reference: https://scipp.github.io/
16""" # noqa: E501
18from .core import __version__
20# Import classes
21from .core import Variable, DataArray, DataGroup, Dataset, DType, Unit
23# Import errors
24from .core import (
25 BinEdgeError,
26 BinnedDataError,
27 CoordError,
28 DataArrayError,
29 DatasetError,
30 DimensionError,
31 DTypeError,
32 UnitError,
33 VariableError,
34 VariancesError,
35)
37# Import submodules
38from . import units
40# Import functions
42# Import python functions
43from .visualization import show, make_svg, to_html, make_html, table
45Variable._repr_html_ = make_html
46DataArray._repr_html_ = make_html
47Dataset._repr_html_ = make_html
48del visualization
50from .io.hdf5 import save_hdf5 as _save_hdf5
52Variable.save_hdf5 = _save_hdf5
53DataArray.save_hdf5 = _save_hdf5
54Dataset.save_hdf5 = _save_hdf5
55DataGroup.save_hdf5 = _save_hdf5
56del _save_hdf5
58from .format import format_variable as _format_variable
60Variable.__format__ = _format_variable
61del _format_variable
63from ._extend_units import extend_units
65extend_units()
66del extend_units
68from .compat.dict import to_dict, from_dict
70from .object_list import _repr_html_
71from .utils import collapse, slices
73del object_list, utils
75from .coords import transform_coords, show_graph
77from .core import add, divide, floor_divide, mod, multiply, negative, subtract
78from .core import bin, group, hist, nanhist, rebin
79from .core import Lookup, lookup, bins, bins_like
80from .core import (
81 less,
82 greater,
83 less_equal,
84 greater_equal,
85 equal,
86 not_equal,
87 identical,
88 isclose,
89 allclose,
90)
91from .core import counts_to_density, density_to_counts
92from .core import cumsum
93from .core import merge
94from .core import groupby
95from .core import logical_not, logical_and, logical_or, logical_xor
96from .core import (
97 abs,
98 nan_to_num,
99 norm,
100 reciprocal,
101 pow,
102 sqrt,
103 exp,
104 log,
105 log10,
106 round,
107 floor,
108 ceil,
109 erf,
110 erfc,
111 midpoints,
112)
113from .core import (
114 dot,
115 islinspace,
116 issorted,
117 allsorted,
118 cross,
119 sort,
120 values,
121 variances,
122 stddevs,
123 where,
124)
125from .core import (
126 mean,
127 nanmean,
128 median,
129 nanmedian,
130 std,
131 nanstd,
132 var,
133 nanvar,
134 sum,
135 nansum,
136 min,
137 max,
138 nanmin,
139 nanmax,
140 all,
141 any,
142)
143from .core import broadcast, concat, fold, flatten, squeeze, transpose
144from .core import sinh, cosh, tanh, asinh, acosh, atanh
145from .core import sin, cos, tan, asin, acos, atan, atan2
146from .core import isnan, isinf, isfinite, isposinf, isneginf, to_unit
147from .core import (
148 scalar,
149 index,
150 zeros,
151 zeros_like,
152 ones,
153 ones_like,
154 empty,
155 empty_like,
156 full,
157 full_like,
158 vector,
159 vectors,
160 array,
161 linspace,
162 geomspace,
163 logspace,
164 arange,
165 datetime,
166 datetimes,
167 epoch,
168)
169from .core import as_const
170from .core import to
172from .logging import display_logs, get_logger
174from .reduction import reduce
176del reduction
178# Mainly imported for docs
179from .core import Bins, Coords, GroupByDataset, GroupByDataArray, Masks
181from . import _binding
183_binding.bind_get()
184_binding.bind_pop()
185_binding.bind_conversion_to_builtin(Variable)
186# Assign method binding for all containers
187for _cls in (Variable, DataArray, Dataset):
188 _binding.bind_functions_as_methods(
189 _cls,
190 globals(),
191 (
192 'sum',
193 'nansum',
194 'mean',
195 'nanmean',
196 'median',
197 'nanmedian',
198 'std',
199 'nanstd',
200 'var',
201 'nanvar',
202 'max',
203 'min',
204 'nanmax',
205 'nanmin',
206 'all',
207 'any',
208 ),
209 )
210del _cls
211# Assign method binding for both Variable and DataArray
212for _cls in (Variable, DataArray):
213 _binding.bind_functions_as_methods(
214 _cls,
215 globals(),
216 (
217 'broadcast',
218 'flatten',
219 'fold',
220 'squeeze',
221 'transpose',
222 'floor',
223 'ceil',
224 'round',
225 ),
226 )
227 _binding.bind_function_as_method(cls=_cls, name='to', func=to, abbreviate_doc=False)
228del _cls
229del to
230# Assign method binding for JUST Variable
231_binding.bind_functions_as_methods(Variable, globals(), ('cumsum',))
232# Assign method binding for JUST Dataset
233_binding.bind_functions_as_methods(Dataset, globals(), ('squeeze',))
234for _cls in (DataArray, Dataset):
235 _binding.bind_functions_as_methods(_cls, globals(), ('groupby', 'transform_coords'))
236del _cls
237_binding.bind_functions_as_methods(Variable, globals(), ('bin', 'hist', 'nanhist'))
238_binding.bind_functions_as_methods(
239 DataArray, globals(), ('bin', 'group', 'hist', 'nanhist', 'rebin')
240)
241_binding.bind_functions_as_methods(Dataset, globals(), ('hist', 'rebin'))
242del _binding
244from . import data
245from . import spatial
246from .operations import elemwise_func
248del operations
250from .plotting import plot
252Variable.plot = plot
253DataArray.plot = plot
254Dataset.plot = plot
255del plotting
257from .core.util import VisibleDeprecationWarning
259del core
261from .curve_fit import curve_fit
263__all__ = [
264 'BinEdgeError',
265 'BinnedDataError',
266 'Bins',
267 'CoordError',
268 'Coords',
269 'DType',
270 'DTypeError',
271 'DataArray',
272 'DataArrayError',
273 'DataGroup',
274 'Dataset',
275 'DatasetError',
276 'DimensionError',
277 'GroupByDataArray',
278 'GroupByDataset',
279 'Lookup',
280 'Masks',
281 'Unit',
282 'UnitError',
283 'Variable',
284 'VariableError',
285 'VariancesError',
286 'VisibleDeprecationWarning',
287 'abs',
288 'acos',
289 'acosh',
290 'add',
291 'all',
292 'allclose',
293 'allsorted',
294 'any',
295 'arange',
296 'array',
297 'as_const',
298 'asin',
299 'asinh',
300 'atan',
301 'atanh',
302 'atan2',
303 'bin',
304 'bins',
305 'bins_like',
306 'broadcast',
307 'ceil',
308 'collapse',
309 'compat',
310 'concat',
311 'coords',
312 'cos',
313 'cosh',
314 'counts_to_density',
315 'cross',
316 'cumsum',
317 'curve_fit',
318 'data',
319 'datetime',
320 'datetimes',
321 'density_to_counts',
322 'display_logs',
323 'divide',
324 'dot',
325 'elemwise_func',
326 'empty',
327 'empty_like',
328 'epoch',
329 'equal',
330 'erf',
331 'erfc',
332 'exp',
333 'flatten',
334 'floor',
335 'floor_divide',
336 'fold',
337 'format',
338 'from_dict',
339 'full',
340 'full_like',
341 'geomspace',
342 'get_logger',
343 'greater',
344 'greater_equal',
345 'group',
346 'groupby',
347 'hist',
348 'histogram',
349 'identical',
350 'index',
351 'io',
352 'isclose',
353 'isfinite',
354 'isinf',
355 'islinspace',
356 'isnan',
357 'isneginf',
358 'isposinf',
359 'issorted',
360 'less',
361 'less_equal',
362 'linspace',
363 'log',
364 'log10',
365 'logging',
366 'logical_and',
367 'logical_not',
368 'logical_or',
369 'logical_xor',
370 'logspace',
371 'lookup',
372 'make_html',
373 'make_svg',
374 'max',
375 'mean',
376 'median',
377 'merge',
378 'midpoints',
379 'min',
380 'mod',
381 'multiply',
382 'nan_to_num',
383 'nanhist',
384 'nanmax',
385 'nanmean',
386 'nanmedian',
387 'nanmin',
388 'nanstd',
389 'nansum',
390 'nanvar',
391 'negative',
392 'norm',
393 'not_equal',
394 'ones',
395 'ones_like',
396 'plot',
397 'pow',
398 'rebin',
399 'reciprocal',
400 'reduce',
401 'reduction',
402 'round',
403 'scalar',
404 'show',
405 'show_graph',
406 'sin',
407 'sinh',
408 'slices',
409 'sort',
410 'spatial',
411 'sqrt',
412 'squeeze',
413 'std',
414 'stddevs',
415 'subtract',
416 'sum',
417 'table',
418 'tan',
419 'tanh',
420 'to_dict',
421 'to_html',
422 'to_unit',
423 'transform_coords',
424 'transpose',
425 'typing',
426 'units',
427 'utils',
428 'values',
429 'var',
430 'variances',
431 'vector',
432 'vectors',
433 'where',
434 'zeros',
435 'zeros_like',
436]