std.transform.js 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { factory } from '../../utils/factory.js';
  2. import { createStd } from '../../function/statistics/std.js';
  3. import { errorTransform } from './utils/errorTransform.js';
  4. import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
  5. var name = 'std';
  6. var dependencies = ['typed', 'map', 'sqrt', 'variance'];
  7. /**
  8. * Attach a transform function to math.std
  9. * Adds a property transform containing the transform function.
  10. *
  11. * This transform changed the `dim` parameter of function std
  12. * from one-based to zero based
  13. */
  14. export var createStdTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
  15. var {
  16. typed,
  17. map,
  18. sqrt,
  19. variance
  20. } = _ref;
  21. var std = createStd({
  22. typed,
  23. map,
  24. sqrt,
  25. variance
  26. });
  27. return typed('std', {
  28. '...any': function any(args) {
  29. args = lastDimToZeroBase(args);
  30. try {
  31. return std.apply(null, args);
  32. } catch (err) {
  33. throw errorTransform(err);
  34. }
  35. }
  36. });
  37. }, {
  38. isTransformFunction: true
  39. });