valarray 0.4__tar.gz → 0.4.1__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 (105) hide show
  1. {valarray-0.4 → valarray-0.4.1}/.gitignore +1 -0
  2. {valarray-0.4 → valarray-0.4.1}/PKG-INFO +35 -3
  3. {valarray-0.4 → valarray-0.4.1}/README.md +34 -2
  4. valarray-0.4.1/docs/dependency_graphs/core.mmd +30 -0
  5. valarray-0.4.1/docs/dependency_graphs/core_validation_errors.mmd +13 -0
  6. valarray-0.4.1/docs/dependency_graphs/core_validation_functions.mmd +15 -0
  7. valarray-0.4.1/docs/dependency_graphs/numpy.mmd +25 -0
  8. {valarray-0.4 → valarray-0.4.1}/pyproject.toml +1 -1
  9. {valarray-0.4 → valarray-0.4.1}/requirements_dev.txt +2 -1
  10. valarray-0.4.1/requirements_dev_optional.txt +1 -0
  11. valarray-0.4.1/test_data/core/string_utils.py +54 -0
  12. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/array_and_dtype.py +6 -0
  13. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/array_type_adapter.py +6 -2
  14. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/comparisons.py +1 -1
  15. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/errors_exceptions.py +1 -1
  16. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/validators.py +18 -0
  17. {valarray-0.4 → valarray-0.4.1}/tests/core/errors_exceptions/test_values_errors.py +1 -1
  18. {valarray-0.4 → valarray-0.4.1}/tests/core/test_array.py +51 -1
  19. valarray-0.4.1/tests/core/test_axes_and_fields.py +22 -0
  20. valarray-0.4/tests/core/test_axes_and_fields.py → valarray-0.4.1/tests/core/test_data_structures.py +1 -1
  21. {valarray-0.4 → valarray-0.4.1}/tests/core/test_misc.py +1 -1
  22. valarray-0.4.1/tests/core/test_string_utils.py +226 -0
  23. {valarray-0.4 → valarray-0.4.1}/tests/core/test_utils.py +1 -1
  24. {valarray-0.4 → valarray-0.4.1}/tests/core/test_validators.py +37 -10
  25. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/field_values/test_ax_and_field_strings.py +13 -9
  26. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/field_values/test_val_field_values_core.py +4 -8
  27. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/field_values/test_val_field_values_utils.py +23 -21
  28. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/test_val_array.py +3 -2
  29. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/test_val_shape.py +7 -7
  30. {valarray-0.4 → valarray-0.4.1}/tests/numpy/test_adapter.py +2 -1
  31. {valarray-0.4 → valarray-0.4.1}/tests/numpy/test_numpy_array.py +51 -1
  32. {valarray-0.4 → valarray-0.4.1}/tests/numpy/test_validation.py +3 -3
  33. {valarray-0.4 → valarray-0.4.1}/tests/test_imports.py +14 -4
  34. {valarray-0.4 → valarray-0.4.1}/valarray/core/__init__.py +5 -2
  35. {valarray-0.4 → valarray-0.4.1}/valarray/core/array.py +30 -1
  36. valarray-0.4.1/valarray/core/array_type_adapter/__init__.py +13 -0
  37. valarray-0.4/valarray/core/array_type_adapter.py → valarray-0.4.1/valarray/core/array_type_adapter/adapter.py +24 -7
  38. {valarray-0.4/valarray/core → valarray-0.4.1/valarray/core/array_type_adapter}/comparisons.py +3 -0
  39. valarray-0.4/valarray/core/errors_exceptions/generic.py → valarray-0.4.1/valarray/core/array_type_adapter/errors.py +10 -3
  40. {valarray-0.4 → valarray-0.4.1}/valarray/core/axes_and_fields.py +17 -56
  41. valarray-0.4.1/valarray/core/data_structures.py +65 -0
  42. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/__init__.py +0 -3
  43. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/validation_errors/values.py +3 -3
  44. valarray-0.4.1/valarray/core/string_utils/__init__.py +28 -0
  45. valarray-0.4.1/valarray/core/string_utils/array.py +112 -0
  46. valarray-0.4.1/valarray/core/string_utils/field.py +36 -0
  47. valarray-0.4.1/valarray/core/string_utils/general.py +74 -0
  48. valarray-0.4.1/valarray/core/string_utils/headings.py +5 -0
  49. {valarray-0.4 → valarray-0.4.1}/valarray/core/types/other.py +3 -1
  50. {valarray-0.4 → valarray-0.4.1}/valarray/core/utils.py +12 -4
  51. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/field_values/core.py +8 -2
  52. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/field_values/types_and_data_structures.py +9 -6
  53. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/field_values/utils.py +10 -11
  54. {valarray-0.4 → valarray-0.4.1}/valarray/core/validators/base.py +16 -3
  55. {valarray-0.4 → valarray-0.4.1}/valarray/core/validators/value_comparisons.py +9 -8
  56. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/__init__.py +3 -2
  57. valarray-0.4.1/valarray/numpy/array_type_adapter/__init__.py +13 -0
  58. valarray-0.4/valarray/numpy/array_type_adapter.py → valarray-0.4.1/valarray/numpy/array_type_adapter/adapter.py +9 -5
  59. {valarray-0.4/valarray/numpy → valarray-0.4.1/valarray/numpy/array_type_adapter}/comparisons.py +2 -2
  60. valarray-0.4.1/valarray/numpy/array_type_adapter/errors.py +30 -0
  61. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/axes_and_fields.py +2 -2
  62. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/errors_exceptions.py +0 -20
  63. valarray-0.4.1/valarray/settings.py +23 -0
  64. {valarray-0.4 → valarray-0.4.1}/.coveragerc +0 -0
  65. {valarray-0.4 → valarray-0.4.1}/assets/images/valarray_logo.svg +0 -0
  66. {valarray-0.4 → valarray-0.4.1}/docs/example_code/introduction/issue1_problem.py +0 -0
  67. {valarray-0.4 → valarray-0.4.1}/docs/example_code/introduction/issue1_solution.py +0 -0
  68. {valarray-0.4 → valarray-0.4.1}/docs/example_code/introduction/issue2_problem.py +0 -0
  69. {valarray-0.4 → valarray-0.4.1}/docs/example_code/introduction/issue2_solution.py +0 -0
  70. {valarray-0.4 → valarray-0.4.1}/docs/example_code/introduction/issue_3_problem.py +0 -0
  71. {valarray-0.4 → valarray-0.4.1}/docs/example_code/introduction/issue_3_solution.py +0 -0
  72. {valarray-0.4 → valarray-0.4.1}/requirements.txt +0 -0
  73. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/__init__.py +0 -0
  74. {valarray-0.4 → valarray-0.4.1}/tests/core/classes_for_testing/validated_array.py +0 -0
  75. {valarray-0.4 → valarray-0.4.1}/tests/core/errors_exceptions/test_axes_errors.py +0 -0
  76. {valarray-0.4 → valarray-0.4.1}/tests/core/errors_exceptions/test_dtype_errors.py +0 -0
  77. {valarray-0.4 → valarray-0.4.1}/tests/core/errors_exceptions/test_error_list.py +0 -0
  78. {valarray-0.4 → valarray-0.4.1}/tests/core/errors_exceptions/test_exceptions.py +0 -0
  79. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/test_val_array_values.py +0 -0
  80. {valarray-0.4 → valarray-0.4.1}/tests/core/validation_functions/test_val_dtype.py +0 -0
  81. {valarray-0.4 → valarray-0.4.1}/tests/numpy/common.py +0 -0
  82. {valarray-0.4 → valarray-0.4.1}/tests/numpy/test_numpy_comparisons.py +0 -0
  83. {valarray-0.4 → valarray-0.4.1}/tests/numpy/test_numpy_errors_and_exceptions.py +0 -0
  84. {valarray-0.4 → valarray-0.4.1}/valarray/__init__.py +0 -0
  85. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/error_list.py +0 -0
  86. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/exceptions.py +0 -0
  87. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/validation_errors/__init__.py +0 -0
  88. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/validation_errors/array_creation.py +0 -0
  89. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/validation_errors/axes.py +0 -0
  90. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/validation_errors/base.py +0 -0
  91. {valarray-0.4 → valarray-0.4.1}/valarray/core/errors_exceptions/validation_errors/dtype.py +0 -0
  92. {valarray-0.4 → valarray-0.4.1}/valarray/core/types/__init__.py +0 -0
  93. {valarray-0.4 → valarray-0.4.1}/valarray/core/types/generics.py +0 -0
  94. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/__init__.py +0 -0
  95. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/array.py +0 -0
  96. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/array_values.py +0 -0
  97. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/dtype.py +0 -0
  98. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/field_values/__init__.py +0 -0
  99. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/shape.py +0 -0
  100. {valarray-0.4 → valarray-0.4.1}/valarray/core/validation_functions/utils.py +0 -0
  101. {valarray-0.4 → valarray-0.4.1}/valarray/core/validators/__init__.py +0 -0
  102. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/array.py +0 -0
  103. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/types.py +0 -0
  104. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/validation_functions.py +0 -0
  105. {valarray-0.4 → valarray-0.4.1}/valarray/numpy/validators.py +0 -0
@@ -3,6 +3,7 @@
3
3
  .coverage
4
4
  *egg-info
5
5
  dist*
6
+ tach*
6
7
 
7
8
  ut_*
8
9
  temp*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: valarray
3
- Version: 0.4
3
+ Version: 0.4.1
4
4
  Summary: Library for validating numpy arrays.
5
5
  Project-URL: Homepage, https://codeberg.org/jfranek/valarray
6
6
  Author-email: "J. Franek" <franek.j27@email.cz>
@@ -18,7 +18,7 @@ Description-Content-Type: text/markdown
18
18
 
19
19
  In short, library for validating numpy arrays that also helps with static analysis and documentation. In long, see [Library rationale](#library-rationale).
20
20
 
21
- Currently intended primarily as a personal/hobby project (see [Caveats](#caveats))
21
+ Currently intended primarily as a personal/hobby project (see [Caveats](#caveats)). Also not considered stable (see [Breaking changes](#breaking-changes)).
22
22
 
23
23
  I have gotten away with using it in a professional setting, but YMMV.
24
24
 
@@ -83,7 +83,12 @@ except ValidationException as v_exc:
83
83
  - [Catching exceptions](#catching-exceptions)
84
84
  - [Special exceptions and errors](#special-exceptions-and-errors)
85
85
  - [Generic Errors](#generic-errors)
86
+ - [Settings](#settings)
86
87
  - [Caveats](#caveats)
88
+ - [Changelog](#changelog)
89
+ - [0.4.1](#041)
90
+ - [0.4](#04)
91
+ - [Breaking changes](#breaking-changes)
87
92
 
88
93
  # Library rationale
89
94
  This library aims to help with 3 issues encountered when working with numpy arrays:
@@ -691,8 +696,35 @@ These error types have subclasses ensuring proper type hints:
691
696
  - `InvalidArrayValuesError` -> `NumpyInvalidArrayValuesError`
692
697
  - `InvalidFieldValuesError` -> `NumpyInvalidFieldValuesError`
693
698
 
699
+ # Settings
700
+ Global settings for the library are defined in `valarray.settings` and can be modified using environment variables.
701
+ | ***variable name*** | ***environment variable*** | default value | description |
702
+ |---------------------|------------------------------|---------------|-----------------------------------------------------|
703
+ | function_cache_size | VALARRAY_FUNCTION_CACHE_SIZE | 512 | cache size for (internal) frequently used functions |
704
+
705
+
694
706
 
695
707
  # Caveats
696
708
  - I cannot guarantee that the test suite is foolproof ATM as I'm currently the only one testing this library.
697
709
  - Library has so far only been tested with `python==3.12` and `numpy==2.4.0`
698
- - Library isn't tested for performance, use in production only if the primary bottleneck is brain and not hardware.
710
+ - Library isn't tested for performance, use in production only if the primary bottleneck is brain and not hardware.
711
+
712
+ # Changelog
713
+ ## 0.4.1
714
+ - added cache for often used functions
715
+ - added __str__ and __len__ methods
716
+
717
+ ## 0.4
718
+ - first version with all basic features: creating a validated array, validating dtype, shape, array and field values
719
+
720
+
721
+ # Breaking changes
722
+ - **0.4** -> **0.4.1**
723
+ - changed __str__ method for `Validator` to `.error_string` property (to allow different string representation for error messages and general printing)
724
+ - changed imports due to refactoring to simplify dependencies:
725
+ - `GenericErrors`
726
+ - from `valarray.core.errors_exceptions` -> from `valarray.core`
727
+ - `NumpyErrors`
728
+ - from `valarray.numpy.errors_exceptions` -> from `valarray.numpy`
729
+ - `AxisNameAndIdx`, `FieldNameAndIdx`
730
+ - from `valarray.core.axes_and_fields` -> from `valarray.core.data_structures`
@@ -2,7 +2,7 @@
2
2
 
3
3
  In short, library for validating numpy arrays that also helps with static analysis and documentation. In long, see [Library rationale](#library-rationale).
4
4
 
5
- Currently intended primarily as a personal/hobby project (see [Caveats](#caveats))
5
+ Currently intended primarily as a personal/hobby project (see [Caveats](#caveats)). Also not considered stable (see [Breaking changes](#breaking-changes)).
6
6
 
7
7
  I have gotten away with using it in a professional setting, but YMMV.
8
8
 
@@ -67,7 +67,12 @@ except ValidationException as v_exc:
67
67
  - [Catching exceptions](#catching-exceptions)
68
68
  - [Special exceptions and errors](#special-exceptions-and-errors)
69
69
  - [Generic Errors](#generic-errors)
70
+ - [Settings](#settings)
70
71
  - [Caveats](#caveats)
72
+ - [Changelog](#changelog)
73
+ - [0.4.1](#041)
74
+ - [0.4](#04)
75
+ - [Breaking changes](#breaking-changes)
71
76
 
72
77
  # Library rationale
73
78
  This library aims to help with 3 issues encountered when working with numpy arrays:
@@ -675,8 +680,35 @@ These error types have subclasses ensuring proper type hints:
675
680
  - `InvalidArrayValuesError` -> `NumpyInvalidArrayValuesError`
676
681
  - `InvalidFieldValuesError` -> `NumpyInvalidFieldValuesError`
677
682
 
683
+ # Settings
684
+ Global settings for the library are defined in `valarray.settings` and can be modified using environment variables.
685
+ | ***variable name*** | ***environment variable*** | default value | description |
686
+ |---------------------|------------------------------|---------------|-----------------------------------------------------|
687
+ | function_cache_size | VALARRAY_FUNCTION_CACHE_SIZE | 512 | cache size for (internal) frequently used functions |
688
+
689
+
678
690
 
679
691
  # Caveats
680
692
  - I cannot guarantee that the test suite is foolproof ATM as I'm currently the only one testing this library.
681
693
  - Library has so far only been tested with `python==3.12` and `numpy==2.4.0`
682
- - Library isn't tested for performance, use in production only if the primary bottleneck is brain and not hardware.
694
+ - Library isn't tested for performance, use in production only if the primary bottleneck is brain and not hardware.
695
+
696
+ # Changelog
697
+ ## 0.4.1
698
+ - added cache for often used functions
699
+ - added __str__ and __len__ methods
700
+
701
+ ## 0.4
702
+ - first version with all basic features: creating a validated array, validating dtype, shape, array and field values
703
+
704
+
705
+ # Breaking changes
706
+ - **0.4** -> **0.4.1**
707
+ - changed __str__ method for `Validator` to `.error_string` property (to allow different string representation for error messages and general printing)
708
+ - changed imports due to refactoring to simplify dependencies:
709
+ - `GenericErrors`
710
+ - from `valarray.core.errors_exceptions` -> from `valarray.core`
711
+ - `NumpyErrors`
712
+ - from `valarray.numpy.errors_exceptions` -> from `valarray.numpy`
713
+ - `AxisNameAndIdx`, `FieldNameAndIdx`
714
+ - from `valarray.core.axes_and_fields` -> from `valarray.core.data_structures`
@@ -0,0 +1,30 @@
1
+ graph TD
2
+ valarray.core.validators --> valarray.core.types
3
+ valarray.core.validators --> valarray.core.array_type_adapter
4
+ valarray.core.axes_and_fields --> valarray.core.validators
5
+ valarray.core.axes_and_fields --> valarray.core.types
6
+ valarray.core.errors_exceptions --> valarray.core.validators
7
+ valarray.core.errors_exceptions --> valarray.core.types
8
+ valarray.core.errors_exceptions --> valarray.core.data_structures
9
+ valarray.core.utils --> valarray.core.validators
10
+ valarray.core.utils --> valarray.core.errors_exceptions
11
+ valarray.core.utils --> valarray.core.axes_and_fields
12
+ valarray.core.utils --> valarray.core.types
13
+ valarray.core.utils --> valarray.core.array_type_adapter
14
+ valarray.core.array --> valarray.core.errors_exceptions
15
+ valarray.core.array --> valarray.core.axes_and_fields
16
+ valarray.core.array --> valarray.core.utils
17
+ valarray.core.array --> valarray.core.validation_functions
18
+ valarray.core.array --> valarray.core.validators
19
+ valarray.core.array --> valarray.core.array_type_adapter
20
+ valarray.core.array --> valarray.core.types
21
+ valarray.core.array_type_adapter --> valarray.core.types
22
+ valarray.core.validation_functions --> valarray.core.axes_and_fields
23
+ valarray.core.validation_functions --> valarray.core.utils
24
+ valarray.core.validation_functions --> valarray.core.validators
25
+ valarray.core.validation_functions --> valarray.core.errors_exceptions
26
+ valarray.core.validation_functions --> valarray.core.data_structures
27
+ valarray.core.validation_functions --> valarray.core.types
28
+ valarray.core.validation_functions --> valarray.core.array_type_adapter
29
+ valarray.core.data_structures
30
+ valarray.core.types
@@ -0,0 +1,13 @@
1
+ graph TD
2
+ valarray.core.errors_exceptions.validation_errors.values --> valarray.core.errors_exceptions.validation_errors.base
3
+ valarray.core.errors_exceptions.error_list --> valarray.core.errors_exceptions.validation_errors.base
4
+ valarray.core.errors_exceptions.error_list --> valarray.core.errors_exceptions.exceptions
5
+ valarray.core.errors_exceptions.validation_errors.array_creation --> valarray.core.errors_exceptions.validation_errors.base
6
+ valarray.core.errors_exceptions.validation_errors.dtype --> valarray.core.errors_exceptions.validation_errors.base
7
+ valarray.core.errors_exceptions.validation_errors.axes --> valarray.core.errors_exceptions.validation_errors.base
8
+ valarray.core.errors_exceptions.exceptions --> valarray.core.errors_exceptions.validation_errors.dtype
9
+ valarray.core.errors_exceptions.exceptions --> valarray.core.errors_exceptions.validation_errors.array_creation
10
+ valarray.core.errors_exceptions.exceptions --> valarray.core.errors_exceptions.validation_errors.base
11
+ valarray.core.errors_exceptions.exceptions --> valarray.core.errors_exceptions.error_list
12
+ valarray.core.errors_exceptions.validation_errors.base
13
+ valarray.core.errors_exceptions.validation_errors
@@ -0,0 +1,15 @@
1
+ graph TD
2
+ valarray.core.validation_functions.array_values --> valarray.core.validation_functions.utils
3
+ valarray.core.validation_functions.field_values.utils --> valarray.core.validation_functions.field_values.types_and_data_structures
4
+ valarray.core.validation_functions.field_values.utils --> valarray.core.validation_functions.utils
5
+ valarray.core.validation_functions.field_values.core --> valarray.core.validation_functions.field_values.utils
6
+ valarray.core.validation_functions.field_values.core --> valarray.core.validation_functions.field_values.types_and_data_structures
7
+ valarray.core.validation_functions.field_values.core --> valarray.core.validation_functions.shape
8
+ valarray.core.validation_functions.array --> valarray.core.validation_functions.shape
9
+ valarray.core.validation_functions.array --> valarray.core.validation_functions.dtype
10
+ valarray.core.validation_functions.array --> valarray.core.validation_functions.field_values.core
11
+ valarray.core.validation_functions.array --> valarray.core.validation_functions.array_values
12
+ valarray.core.validation_functions.field_values.types_and_data_structures
13
+ valarray.core.validation_functions.utils
14
+ valarray.core.validation_functions.shape
15
+ valarray.core.validation_functions.dtype
@@ -0,0 +1,25 @@
1
+ graph TD
2
+ valarray.numpy.array_type_adapter --> valarray.numpy.array_type_adapter.errors
3
+ valarray.numpy.array_type_adapter --> valarray.numpy.array_type_adapter.comparisons
4
+ valarray.numpy.array_type_adapter --> valarray.numpy.array_type_adapter.adapter
5
+ valarray.numpy.array_type_adapter.adapter --> valarray.numpy.types
6
+ valarray.numpy.array_type_adapter.adapter --> valarray.numpy.array_type_adapter.comparisons
7
+ valarray.numpy.array_type_adapter.adapter --> valarray.numpy.array_type_adapter.errors
8
+ valarray.numpy.validators --> valarray.numpy.types
9
+ valarray.numpy.array_type_adapter.errors --> valarray.numpy.types
10
+ valarray.numpy.array_type_adapter.errors --> valarray.numpy.errors_exceptions
11
+ valarray.numpy.array --> valarray.numpy.array_type_adapter
12
+ valarray.numpy.array --> valarray.numpy.types
13
+ valarray.numpy.array --> valarray.numpy.axes_and_fields
14
+ valarray.numpy.errors_exceptions --> valarray.numpy.types
15
+ valarray.numpy --> valarray.numpy.array_type_adapter
16
+ valarray.numpy --> valarray.numpy.axes_and_fields
17
+ valarray.numpy --> valarray.numpy.array
18
+ valarray.numpy --> valarray.numpy.validators
19
+ valarray.numpy.validation_functions --> valarray.numpy.array_type_adapter
20
+ valarray.numpy.validation_functions --> valarray.numpy.types
21
+ valarray.numpy.validation_functions --> valarray.numpy.validators
22
+ valarray.numpy.validation_functions --> valarray.numpy.axes_and_fields
23
+ valarray.numpy.axes_and_fields --> valarray.numpy.types
24
+ valarray.numpy.array_type_adapter.comparisons --> valarray.numpy.types
25
+ valarray.numpy.types
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "valarray"
7
- version = "0.4"
7
+ version = "0.4.1"
8
8
  authors = [
9
9
  { name="J. Franek", email="franek.j27@email.cz" },
10
10
  ]
@@ -2,4 +2,5 @@ setuptools
2
2
  pytest
3
3
  pytest-cov
4
4
  build
5
- twine
5
+ twine
6
+ dotenv
@@ -0,0 +1 @@
1
+ tach #creating dependency graphs
@@ -0,0 +1,54 @@
1
+ from valarray.core import Field
2
+ from valarray.core.data_structures import HeadingAndLines
3
+
4
+ CONSTRAINTS_STR_LT1 = "Constraints: < 1"
5
+ CONSTRAINTS_STR_LT1_GE_NEG_5 = "Constraints: < 1, >= -5"
6
+
7
+ VALIDATOR_HAL_DUMMY = HeadingAndLines("Validators:", ("Dummy: description",))
8
+
9
+ FIELD_HAL_NO_IDX_NO_NAME = HeadingAndLines("Field < ? >", tuple())
10
+ FIELD_HAL_NO_IDX_NAME = HeadingAndLines("Field < ? > : 'name'", tuple())
11
+ FIELD_HAL_IDX_NO_NAME = HeadingAndLines("Field < 0 >", tuple())
12
+ FIELD_HAL_IDX_NAME = HeadingAndLines("Field < 0 > : 'name'", tuple())
13
+
14
+ FIELD_HAL_IDX_NAME_CONSTRAINTS_VALIDATORS = HeadingAndLines(
15
+ "Field < 0 > : 'name'",
16
+ (
17
+ "Constraints: < 1",
18
+ VALIDATOR_HAL_DUMMY,
19
+ ),
20
+ )
21
+
22
+ FIELD_STR = "Field < 0 > : 'first_field'"
23
+ FIELD_HAL = HeadingAndLines("Field < 1 > : 'second_field'", ("Constraints: >= 0",))
24
+
25
+
26
+ SCHEMA = (
27
+ 12,
28
+ "second_axis",
29
+ (
30
+ "first_field",
31
+ Field("second_field", ge=0),
32
+ ),
33
+ )
34
+ SCHEMA_HAL = HeadingAndLines(
35
+ "schema:",
36
+ (
37
+ "Axis < 0 >",
38
+ "Axis < 1 > : 'second_axis'",
39
+ HeadingAndLines(
40
+ "Axis < 2 >",
41
+ (
42
+ FIELD_STR,
43
+ FIELD_HAL,
44
+ ),
45
+ ),
46
+ ),
47
+ )
48
+
49
+ ARRAY_NAME_AND_TYPE_STR = "TestValidatedArray (type: 'test')"
50
+ DTYPE_STR = "data type: 'one' (DType1)"
51
+
52
+
53
+ ARRAY = [1, 2, 3, 4]
54
+ ARRAY_HAL = HeadingAndLines("values:", ("[1, 2, 3, 4]",))
@@ -39,5 +39,11 @@ class TestArray:
39
39
 
40
40
  return self
41
41
 
42
+ def __len__(self) -> int:
43
+ return len(self.val)
44
+
42
45
  def __repr__(self) -> str:
43
46
  return f"{self.__class__.__name__}()"
47
+
48
+ def __str__(self) -> str:
49
+ return str(self.val)
@@ -1,6 +1,6 @@
1
1
  from types import EllipsisType
2
2
 
3
- from valarray.core import ArrayTypeAdapter
3
+ from valarray.core.array_type_adapter import ArrayTypeAdapter
4
4
  from valarray.core.types import AxSizes
5
5
 
6
6
  from .array_and_dtype import TestArray, TestDtype, TestDtypeLike
@@ -11,6 +11,10 @@ from .errors_exceptions import TestErrors
11
11
  class TestArrayTypeAdapter(
12
12
  ArrayTypeAdapter[TestArray, TestDtypeLike, TestDtype, list[int], int]
13
13
  ):
14
+ @property
15
+ def type_name(self):
16
+ return "test"
17
+
14
18
  @property
15
19
  def errors(self):
16
20
  return TestErrors()
@@ -32,7 +36,7 @@ class TestArrayTypeAdapter(
32
36
  def create_empty_array(
33
37
  self, ax_sizes: AxSizes, dtypelike: TestDtypeLike | EllipsisType
34
38
  ) -> TestArray:
35
- return TestArray(is_empty=True)
39
+ return TestArray(is_empty=True, shap=(0,))
36
40
 
37
41
  def is_array_empty(self, arr: TestArray) -> bool:
38
42
  return arr.is_empty
@@ -1,5 +1,5 @@
1
1
  from tests.core.classes_for_testing.array_and_dtype import TestArray
2
- from valarray.core import Comparisons
2
+ from valarray.core.array_type_adapter import Comparisons
3
3
 
4
4
 
5
5
  class TestComparisons(Comparisons[TestArray, list[int], int]):
@@ -1,8 +1,8 @@
1
1
  from dataclasses import dataclass
2
2
 
3
+ from valarray.core.array_type_adapter import GenericErrors
3
4
  from valarray.core.errors_exceptions import (
4
5
  CannotCoerceDTypeError,
5
- GenericErrors,
6
6
  IncorrectDTypeError,
7
7
  InvalidArrayValuesError,
8
8
  InvalidFieldValuesError,
@@ -45,3 +45,21 @@ class TestValueErrorValidator(TestValidator):
45
45
  def validate(self, arr):
46
46
  if arr.val[0] < self.val:
47
47
  raise ValueError("value_error")
48
+
49
+
50
+ @dataclass
51
+ class TestWithDescriptionDummyValidator(TestValidator):
52
+ def validate(self, arr):
53
+ return True
54
+
55
+ @property
56
+ def description(self) -> str:
57
+ return "Dummy: description"
58
+
59
+
60
+ class TestWitoutDescriptionAndReprDummyValidator(TestValidator):
61
+ def __init__(self, valid: bool = True):
62
+ self.valid = valid
63
+
64
+ def validate(self, arr):
65
+ return self.valid
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
3
  from tests.core.classes_for_testing import TestComparisons, TestDummyValidator
4
- from valarray.core.axes_and_fields import AxisNameAndIdx, FieldNameAndIdx
4
+ from valarray.core.data_structures import AxisNameAndIdx, FieldNameAndIdx
5
5
  from valarray.core.errors_exceptions import (
6
6
  InvalidArrayValuesError,
7
7
  InvalidFieldValuesError,
@@ -2,8 +2,9 @@ from contextlib import nullcontext as does_not_raise
2
2
  from typing import Any
3
3
 
4
4
  import pytest
5
- from classes_for_testing import TestArray, TestValidatedArray
5
+ from classes_for_testing import TestArray, TestDtype, TestValidatedArray
6
6
 
7
+ from tests.core.test_validators import TestWithDescriptionDummyValidator
7
8
  from valarray.core.errors_exceptions import ValidationException
8
9
 
9
10
 
@@ -63,3 +64,52 @@ def test_repr():
63
64
  arr = TestValidatedArray(TestArray(is_empty=True))
64
65
 
65
66
  assert repr(arr) == "TestValidatedArray.empty()"
67
+
68
+
69
+ class TestTestValidatedArray(TestValidatedArray):
70
+ schema = ("n",)
71
+
72
+
73
+ @pytest.mark.parametrize(
74
+ "v_arr, expected_length",
75
+ [
76
+ (TestTestValidatedArray.empty(), 0),
77
+ (TestTestValidatedArray(TestArray(val=[1, 2, 3], shap=(3,))), 3),
78
+ ],
79
+ )
80
+ def test_len(v_arr: TestValidatedArray, expected_length: int):
81
+ length = len(v_arr)
82
+
83
+ assert (
84
+ length == expected_length
85
+ ), "actual/expected values for 'length' are not equal"
86
+
87
+
88
+ class ExampleTestArray(TestValidatedArray):
89
+ dtype = "one"
90
+ schema = (4,)
91
+ validators = (TestWithDescriptionDummyValidator(),)
92
+ lt = 5
93
+ ge = 0
94
+
95
+
96
+ STR = """ExampleTestArray (type: 'test')
97
+ data type: 'one' (DType1)
98
+ schema:
99
+ Axis < 0 >
100
+ Constraints: < 5, >= 0
101
+ Validators:
102
+ Dummy: description
103
+ values:
104
+ [1, 2, 3, 4]"""
105
+
106
+
107
+ def test_array_string():
108
+ expected_string = STR
109
+ string = str(
110
+ ExampleTestArray(TestArray(dtyp=TestDtype(1), shap=(4,), val=[1, 2, 3, 4]))
111
+ )
112
+
113
+ assert (
114
+ string == expected_string
115
+ ), "actual/expected values for 'string' are not equal"
@@ -0,0 +1,22 @@
1
+ from tests.core.test_validators import TestWithDescriptionDummyValidator
2
+ from valarray.core.axes_and_fields import Field
3
+
4
+
5
+ def test_field_string():
6
+ fld = Field(
7
+ name="example_field",
8
+ ge=-5,
9
+ lt=1,
10
+ validators=(TestWithDescriptionDummyValidator(),),
11
+ )
12
+
13
+ expected_string = """Field < ? > : 'example_field'
14
+ Constraints: < 1, >= -5
15
+ Validators:
16
+ Dummy: description"""
17
+
18
+ string = str(fld)
19
+
20
+ assert (
21
+ string == expected_string
22
+ ), "actual/expected values for 'string' are not equal"
@@ -1,6 +1,6 @@
1
1
  import pytest
2
2
 
3
- from valarray.core.axes_and_fields import AxisNameAndIdx, FieldNameAndIdx
3
+ from valarray.core.data_structures import AxisNameAndIdx, FieldNameAndIdx
4
4
 
5
5
 
6
6
  @pytest.mark.parametrize(
@@ -4,7 +4,7 @@ from typing import Any
4
4
  import pytest
5
5
 
6
6
  from tests.core.classes_for_testing import TestComparisons
7
- from valarray.core import Comparisons
7
+ from valarray.core.array_type_adapter import Comparisons
8
8
 
9
9
 
10
10
  class TestDifferentComparisons(Comparisons[Any, list[int], int]):