datastock 0.0.40__tar.gz → 0.0.42__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {datastock-0.0.40/datastock.egg-info → datastock-0.0.42}/PKG-INFO +1 -1
  2. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class0.py +1 -1
  3. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_check.py +9 -2
  4. {datastock-0.0.40 → datastock-0.0.42}/datastock/_generic_utils.py +108 -14
  5. {datastock-0.0.40 → datastock-0.0.42}/datastock/version.py +1 -1
  6. {datastock-0.0.40 → datastock-0.0.42/datastock.egg-info}/PKG-INFO +1 -1
  7. {datastock-0.0.40 → datastock-0.0.42}/LICENSE +0 -0
  8. {datastock-0.0.40 → datastock-0.0.42}/MANIFEST.in +0 -0
  9. {datastock-0.0.40 → datastock-0.0.42}/README.md +0 -0
  10. {datastock-0.0.40 → datastock-0.0.42}/_updateversion.py +0 -0
  11. {datastock-0.0.40 → datastock-0.0.42}/datastock/_DataCollection_utils.py +0 -0
  12. {datastock-0.0.40 → datastock-0.0.42}/datastock/__init__.py +0 -0
  13. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class.py +0 -0
  14. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1.py +0 -0
  15. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_binning.py +0 -0
  16. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_compute.py +0 -0
  17. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_domain.py +0 -0
  18. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_interpolate.py +0 -0
  19. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_show.py +0 -0
  20. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class1_uniformize.py +0 -0
  21. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class2.py +0 -0
  22. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class2_interactivity.py +0 -0
  23. {datastock-0.0.40 → datastock-0.0.42}/datastock/_class3.py +0 -0
  24. {datastock-0.0.40 → datastock-0.0.42}/datastock/_direct_calls.py +0 -0
  25. {datastock-0.0.40 → datastock-0.0.42}/datastock/_export_dataframe.py +0 -0
  26. {datastock-0.0.40 → datastock-0.0.42}/datastock/_find_plateau.py +0 -0
  27. {datastock-0.0.40 → datastock-0.0.42}/datastock/_generic_check.py +0 -0
  28. {datastock-0.0.40 → datastock-0.0.42}/datastock/_generic_utils_plot.py +0 -0
  29. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_BvsA_as_distribution.py +0 -0
  30. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_BvsA_as_distribution_check.py +0 -0
  31. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_as_array.py +0 -0
  32. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_as_array_1d.py +0 -0
  33. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_as_array_234d.py +0 -0
  34. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_as_mobile_lines.py +0 -0
  35. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_as_profile1d.py +0 -0
  36. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_correlations.py +0 -0
  37. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_old_backup.py +0 -0
  38. {datastock-0.0.40 → datastock-0.0.42}/datastock/_plot_text.py +0 -0
  39. {datastock-0.0.40 → datastock-0.0.42}/datastock/_saveload.py +0 -0
  40. {datastock-0.0.40 → datastock-0.0.42}/datastock/tests/__init__.py +0 -0
  41. {datastock-0.0.40 → datastock-0.0.42}/datastock/tests/output/__init__.py +0 -0
  42. {datastock-0.0.40 → datastock-0.0.42}/datastock/tests/test_01_DataStock.py +0 -0
  43. {datastock-0.0.40 → datastock-0.0.42}/datastock.egg-info/SOURCES.txt +0 -0
  44. {datastock-0.0.40 → datastock-0.0.42}/datastock.egg-info/dependency_links.txt +0 -0
  45. {datastock-0.0.40 → datastock-0.0.42}/datastock.egg-info/requires.txt +0 -0
  46. {datastock-0.0.40 → datastock-0.0.42}/datastock.egg-info/top_level.txt +0 -0
  47. {datastock-0.0.40 → datastock-0.0.42}/pyproject.toml +0 -0
  48. {datastock-0.0.40 → datastock-0.0.42}/setup.cfg +0 -0
  49. {datastock-0.0.40 → datastock-0.0.42}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datastock
3
- Version: 0.0.40
3
+ Version: 0.0.42
4
4
  Summary: A python library for generic class and data handling
5
5
  Home-page: https://github.com/ToFuProject/datastock
6
6
  Author: Didier VEZINET
@@ -168,7 +168,7 @@ class DataStock0(object):
168
168
  return_pfe=False,
169
169
  ):
170
170
 
171
- lsep = ['.', '-', '_', ',', ';', '~', '?']
171
+ lsep = [';', '&', '?', '#', ',', '~', '.', '-', '_']
172
172
  if sep is None:
173
173
  for ss in lsep:
174
174
  c0 = (
@@ -147,7 +147,14 @@ def _check_conflicts(dd=None, dd0=None, dd_name=None, returnas=None):
147
147
  or (
148
148
  not isinstance(v0[kk], np.ndarray)
149
149
  and not scpsp.issparse(v0[kk])
150
- and v0[kk] == dd0[k0][kk]
150
+ and (
151
+ v0[kk] == dd0[k0][kk]
152
+ or (
153
+ # asunit.Unit vs str should be the same
154
+ kk == 'units'
155
+ and str(v0[kk]) == str(dd0[k0][kk])
156
+ )
157
+ )
151
158
  )
152
159
  )
153
160
  )
@@ -1925,4 +1932,4 @@ def _select(dd=None, dd_name=None, log=None, returnas=None, **kwdargs):
1925
1932
  [k0 for jj, k0 in enumerate(dd.keys()) if ind[jj]],
1926
1933
  dtype=str,
1927
1934
  )
1928
- return ind
1935
+ return ind
@@ -361,10 +361,14 @@ def compare_dict(
361
361
 
362
362
  # numpy arrays
363
363
  elif isinstance(d0[k0], np.ndarray):
364
- if d0[k0].shape != d1[k0].shape:
365
- dkeys[key] = f'!= shapes ({d0[k0].shape} vs {d1[k0].shape})'
366
- elif not np.allclose(d0[k0], d1[k0], equal_nan=True):
367
- dkeys[key] = "not allclose"
364
+ msg = _compare_arrays(
365
+ dname=dname,
366
+ k0=k0,
367
+ d0=d0,
368
+ d1=d1,
369
+ )
370
+ if msg is not None:
371
+ dkeys[key] = msg
368
372
 
369
373
  # sparse arrays
370
374
  elif scpsp.issparse(d0[k0]):
@@ -375,16 +379,15 @@ def compare_dict(
375
379
 
376
380
  # lists and tuples
377
381
  elif isinstance(d0[k0], (list, tuple)):
378
- try:
379
- if not d0[k0] == d1[k0]:
380
- dkeys[key] = "!= list/tuple values"
381
- except Exception as err:
382
- msg = (
383
- f"Don't know how to handle {key}:\n"
384
- f"\t- type: {type(d0[k0])}\n"
385
- f"\t- value: {d0[k0]}\n"
386
- )
387
- raise NotImplementedError(msg)
382
+ msg = _compare_list_tuple(
383
+ dname=dname,
384
+ k0=k0,
385
+ d0=d0,
386
+ d1=d1,
387
+ key=key,
388
+ )
389
+ if msg is not None:
390
+ dkeys[key] = msg
388
391
 
389
392
  # functions
390
393
  elif callable(d0[k0]):
@@ -423,6 +426,97 @@ def compare_dict(
423
426
  return _compare_dict_verb_return(dkeys, returnas, verb)
424
427
 
425
428
 
429
+ def _compare_arrays(
430
+ dname=None,
431
+ k0=None,
432
+ d0=None,
433
+ d1=None,
434
+ ):
435
+
436
+ msg = None
437
+
438
+ # shape
439
+ if d0[k0].shape != d1[k0].shape:
440
+ msg = f'!= shapes ({d0[k0].shape} vs {d1[k0].shape})'
441
+
442
+ # dtype
443
+ elif not d0[k0].dtype == d1[k0].dtype:
444
+ msg = f"!= dtypes ({d0[k0].dtype} vs {d1[k0].dtype})"
445
+
446
+ # special case: array of str
447
+ if 'str' in d0[k0].dtype.name:
448
+ d0flat = d0[k0].ravel().tolist()
449
+ d1flat = d1[k0].ravel().tolist()
450
+ c0 = all([ss == d1flat[ii] for ii, ss in enumerate(d0flat)])
451
+ else:
452
+ try:
453
+ c0 = np.allclose(d0[k0], d1[k0], equal_nan=True)
454
+ except Exception as err:
455
+ msg = (
456
+ f"Failed to compare 2 arrays from '{dname}':\n"
457
+ f"\t- d0['{k0}'] = {d0[k0]}\n"
458
+ f"\t- d1['{k0}'] = {d1[k0]}\n"
459
+ )
460
+ raise Exception(msg) from err
461
+
462
+ if not c0:
463
+ msg = "not allclose"
464
+
465
+ return msg
466
+
467
+
468
+ def _compare_list_tuple(
469
+ dname=None,
470
+ k0=None,
471
+ d0=None,
472
+ d1=None,
473
+ key=None,
474
+ ):
475
+
476
+ msg = None
477
+
478
+ # length
479
+ if len(d0[k0]) != len(d1[k0]):
480
+ msg = f'!= length ({len(d0[k0])} vs {len(d1[k0])})'
481
+
482
+ # content type
483
+ ltyp0 = [_simple_type(type(ss)) for ss in d0[k0]]
484
+ ltyp1 = [_simple_type(type(ss)) for ss in d1[k0]]
485
+ if any([t0 != t1 for t0, t1 in zip(ltyp0, ltyp1)]):
486
+ msg = f"!= content type ({ltyp0} vs {ltyp1})"
487
+
488
+ # content
489
+ for ii in range(len(d0[k0])):
490
+
491
+ if isinstance(d0[k0][ii], np.ndarray):
492
+ c0 = np.allclose(d0[k0][ii], d1[k0][ii])
493
+
494
+ else:
495
+
496
+ try:
497
+ c0 = d0[k0][ii] == d1[k0][ii]
498
+ except Exception as err:
499
+ msg = (
500
+ f"Don't know how to handle {key}:\n"
501
+ f"\t- type: {type(d0[k0])}\n"
502
+ f"\t- value: {d0[k0]}\n"
503
+ )
504
+ raise NotImplementedError(msg) from err
505
+
506
+ if not c0:
507
+ msg = f"!= content at position {ii} ({d0[k0][ii]} vs {d1[k0][ii]})"
508
+ break
509
+
510
+ return msg
511
+
512
+
513
+ def _simple_type(typ):
514
+ return ''.join([
515
+ ss for ss in typ.__name__.replace('_', '')
516
+ if not ss.isdigit()
517
+ ])
518
+
519
+
426
520
  def compare_obj(
427
521
  obj0=None,
428
522
  obj1=None,
@@ -1,2 +1,2 @@
1
1
  # Do not edit, pipeline versioning governed by git tags!
2
- __version__ = '0.0.40'
2
+ __version__ = '0.0.42'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: datastock
3
- Version: 0.0.40
3
+ Version: 0.0.42
4
4
  Summary: A python library for generic class and data handling
5
5
  Home-page: https://github.com/ToFuProject/datastock
6
6
  Author: Didier VEZINET
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes