numdaplot 0.1.0__py3-none-any.whl
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.
- numdaplot/__init__.py +506 -0
- numdaplot/arrays/__init__.py +5 -0
- numdaplot/arrays/array.py +92 -0
- numdaplot/arrays/array_arithmetic.py +404 -0
- numdaplot/arrays/array_calculation.py +143 -0
- numdaplot/arrays/array_conversion.py +150 -0
- numdaplot/arrays/array_creation.py +371 -0
- numdaplot/arrays/array_data.py +281 -0
- numdaplot/arrays/array_layout.py +179 -0
- numdaplot/arrays/array_logic.py +227 -0
- numdaplot/arrays/array_reflected_arithmetic.py +334 -0
- numdaplot/arrays/array_refusals.py +339 -0
- numdaplot/arrays/array_selection.py +195 -0
- numdaplot/arrays/array_sorting.py +59 -0
- numdaplot/arrays/axis_number.py +58 -0
- numdaplot/arrays/calculation/__init__.py +5 -0
- numdaplot/arrays/calculation/counting_statistics.py +325 -0
- numdaplot/arrays/calculation/location_statistics.py +268 -0
- numdaplot/arrays/calculation/math_function_values.py +183 -0
- numdaplot/arrays/calculation/statistic_values.py +209 -0
- numdaplot/arrays/calculation/time_function_values.py +419 -0
- numdaplot/arrays/conversion/__init__.py +5 -0
- numdaplot/arrays/conversion/array_text.py +62 -0
- numdaplot/arrays/conversion/equality_check.py +72 -0
- numdaplot/arrays/conversion/python_values.py +70 -0
- numdaplot/arrays/conversion/time_text.py +290 -0
- numdaplot/arrays/creation/__init__.py +5 -0
- numdaplot/arrays/creation/date_parts.py +89 -0
- numdaplot/arrays/creation/date_parts_values.py +437 -0
- numdaplot/arrays/creation/distribution.py +54 -0
- numdaplot/arrays/creation/filled_values.py +58 -0
- numdaplot/arrays/creation/list_conversion.py +311 -0
- numdaplot/arrays/creation/list_shape.py +97 -0
- numdaplot/arrays/creation/normal.py +65 -0
- numdaplot/arrays/creation/numpy_conversion.py +149 -0
- numdaplot/arrays/creation/random_integers.py +104 -0
- numdaplot/arrays/creation/random_values.py +97 -0
- numdaplot/arrays/creation/range_values.py +73 -0
- numdaplot/arrays/creation/spacing.py +84 -0
- numdaplot/arrays/creation/spacing_values.py +63 -0
- numdaplot/arrays/creation/uniform.py +63 -0
- numdaplot/arrays/equality.py +68 -0
- numdaplot/arrays/layout/__init__.py +5 -0
- numdaplot/arrays/layout/sorting_values.py +113 -0
- numdaplot/arrays/layout/unique_values.py +49 -0
- numdaplot/arrays/mapping/__init__.py +5 -0
- numdaplot/arrays/mapping/mapped_values.py +286 -0
- numdaplot/arrays/mapping/unmatched.py +50 -0
- numdaplot/arrays/mapping/value_change.py +55 -0
- numdaplot/arrays/mapping/value_mapping.py +161 -0
- numdaplot/arrays/math_functions/__init__.py +5 -0
- numdaplot/arrays/math_functions/absolute.py +27 -0
- numdaplot/arrays/math_functions/cosine.py +28 -0
- numdaplot/arrays/math_functions/exponential.py +27 -0
- numdaplot/arrays/math_functions/logarithm.py +72 -0
- numdaplot/arrays/math_functions/math_function.py +58 -0
- numdaplot/arrays/math_functions/round.py +58 -0
- numdaplot/arrays/math_functions/sine.py +28 -0
- numdaplot/arrays/math_functions/square_root.py +27 -0
- numdaplot/arrays/operations/__init__.py +5 -0
- numdaplot/arrays/operations/boolean_operands.py +48 -0
- numdaplot/arrays/operations/combination.py +157 -0
- numdaplot/arrays/operations/float_errors.py +170 -0
- numdaplot/arrays/operations/integer_bounds.py +175 -0
- numdaplot/arrays/operations/integer_rules.py +397 -0
- numdaplot/arrays/operations/operand.py +139 -0
- numdaplot/arrays/operations/time_arithmetic.py +479 -0
- numdaplot/arrays/operations/time_bounds.py +286 -0
- numdaplot/arrays/operations/time_result_bounds.py +397 -0
- numdaplot/arrays/operations/transformation.py +54 -0
- numdaplot/arrays/operations/type_requirements.py +94 -0
- numdaplot/arrays/replacement.py +66 -0
- numdaplot/arrays/selection/__init__.py +5 -0
- numdaplot/arrays/selection/comparison_masks.py +131 -0
- numdaplot/arrays/selection/membership_masks.py +118 -0
- numdaplot/arrays/selection/missing_mask.py +50 -0
- numdaplot/arrays/selection/region_index.py +178 -0
- numdaplot/arrays/selection/replaced_values.py +120 -0
- numdaplot/arrays/selection/rule_mask.py +83 -0
- numdaplot/arrays/selection/time_reference.py +172 -0
- numdaplot/arrays/shape.py +74 -0
- numdaplot/arrays/type_match.py +51 -0
- numdaplot/data_types/__init__.py +5 -0
- numdaplot/data_types/library.py +57 -0
- numdaplot/data_types/numpy_mapping.py +207 -0
- numdaplot/data_types/pandas_mapping.py +114 -0
- numdaplot/data_types/time_of_day.py +292 -0
- numdaplot/data_types/type.py +224 -0
- numdaplot/data_types/value_family.py +149 -0
- numdaplot/data_types/value_type.py +147 -0
- numdaplot/dates/__init__.py +5 -0
- numdaplot/dates/custom_date_format.py +83 -0
- numdaplot/dates/date_format.py +120 -0
- numdaplot/dates/date_part.py +59 -0
- numdaplot/dates/date_part_unit.py +153 -0
- numdaplot/dates/date_period.py +57 -0
- numdaplot/dates/duration_in.py +58 -0
- numdaplot/dates/duration_unit.py +90 -0
- numdaplot/dates/period_unit.py +101 -0
- numdaplot/dates/time_function.py +56 -0
- numdaplot/dates/time_zone.py +68 -0
- numdaplot/dates/time_zone_change.py +71 -0
- numdaplot/dates/time_zone_mode.py +81 -0
- numdaplot/dates/to_duration.py +58 -0
- numdaplot/errors/__init__.py +7 -0
- numdaplot/errors/broadcast_warning.py +36 -0
- numdaplot/errors/calculation_warning.py +35 -0
- numdaplot/errors/cell_out_of_range_error.py +77 -0
- numdaplot/errors/column_not_found_error.py +64 -0
- numdaplot/errors/conflicting_settings_error.py +60 -0
- numdaplot/errors/dimension_error.py +62 -0
- numdaplot/errors/display_warning.py +32 -0
- numdaplot/errors/duplicate_column_error.py +82 -0
- numdaplot/errors/duplicate_label_error.py +55 -0
- numdaplot/errors/duplicate_statistic_error.py +55 -0
- numdaplot/errors/duplicate_value_error.py +54 -0
- numdaplot/errors/empty_array_error.py +55 -0
- numdaplot/errors/empty_list_error.py +52 -0
- numdaplot/errors/empty_region_error.py +34 -0
- numdaplot/errors/empty_text_error.py +34 -0
- numdaplot/errors/empty_total_error.py +62 -0
- numdaplot/errors/empty_values_error.py +34 -0
- numdaplot/errors/file_access_error.py +70 -0
- numdaplot/errors/file_exists_error.py +62 -0
- numdaplot/errors/file_not_found_error.py +56 -0
- numdaplot/errors/incompatible_charts_error.py +80 -0
- numdaplot/errors/incompatible_types_error.py +104 -0
- numdaplot/errors/integer_overflow_error.py +61 -0
- numdaplot/errors/invalid_base_error.py +52 -0
- numdaplot/errors/invalid_bin_width_error.py +66 -0
- numdaplot/errors/invalid_bounds_error.py +58 -0
- numdaplot/errors/invalid_chart_data_error.py +81 -0
- numdaplot/errors/invalid_color_count_error.py +63 -0
- numdaplot/errors/invalid_color_error.py +51 -0
- numdaplot/errors/invalid_column_name_error.py +52 -0
- numdaplot/errors/invalid_conversion_error.py +119 -0
- numdaplot/errors/invalid_count_error.py +61 -0
- numdaplot/errors/invalid_date_format_error.py +51 -0
- numdaplot/errors/invalid_deviation_error.py +52 -0
- numdaplot/errors/invalid_fraction_error.py +51 -0
- numdaplot/errors/invalid_label_count_error.py +61 -0
- numdaplot/errors/invalid_limits_error.py +111 -0
- numdaplot/errors/invalid_opacity_error.py +52 -0
- numdaplot/errors/invalid_point_size_error.py +52 -0
- numdaplot/errors/invalid_position_error.py +106 -0
- numdaplot/errors/invalid_resolution_error.py +51 -0
- numdaplot/errors/invalid_rotation_error.py +53 -0
- numdaplot/errors/invalid_seed_error.py +53 -0
- numdaplot/errors/invalid_separator_error.py +52 -0
- numdaplot/errors/invalid_shape_error.py +52 -0
- numdaplot/errors/invalid_sheet_name_error.py +54 -0
- numdaplot/errors/invalid_size_error.py +58 -0
- numdaplot/errors/invalid_step_error.py +77 -0
- numdaplot/errors/invalid_suffixes_error.py +61 -0
- numdaplot/errors/invalid_time_zone_change_error.py +63 -0
- numdaplot/errors/invalid_type_error.py +79 -0
- numdaplot/errors/irregular_list_error.py +36 -0
- numdaplot/errors/join_relation_error.py +183 -0
- numdaplot/errors/missing_dependency_error.py +58 -0
- numdaplot/errors/missing_type_error.py +36 -0
- numdaplot/errors/missing_value_error.py +62 -0
- numdaplot/errors/not_single_value_error.py +53 -0
- numdaplot/errors/numdaplot_error.py +25 -0
- numdaplot/errors/numdaplot_warning.py +34 -0
- numdaplot/errors/occupied_cell_error.py +63 -0
- numdaplot/errors/out_of_domain_error.py +70 -0
- numdaplot/errors/readability_warning.py +35 -0
- numdaplot/errors/refused_operation_error.py +64 -0
- numdaplot/errors/refused_setting_error.py +60 -0
- numdaplot/errors/rejected_dates.py +60 -0
- numdaplot/errors/repeated_key.py +36 -0
- numdaplot/errors/shape_mismatch_error.py +67 -0
- numdaplot/errors/time_overflow_error.py +131 -0
- numdaplot/errors/time_zone_mismatch_error.py +83 -0
- numdaplot/errors/unknown_time_zone_error.py +51 -0
- numdaplot/errors/unmatched_value_error.py +81 -0
- numdaplot/errors/unsupported_image_format_error.py +56 -0
- numdaplot/errors/unsupported_index_error.py +38 -0
- numdaplot/errors/unsupported_missing_error.py +129 -0
- numdaplot/errors/unsupported_type_error.py +62 -0
- numdaplot/errors/value_conversion_error.py +215 -0
- numdaplot/ordering/__init__.py +5 -0
- numdaplot/ordering/missing_position.py +46 -0
- numdaplot/ordering/order.py +46 -0
- numdaplot/package_version.py +36 -0
- numdaplot/plots/__init__.py +5 -0
- numdaplot/plots/chart_layer.py +47 -0
- numdaplot/plots/charts/__init__.py +5 -0
- numdaplot/plots/charts/bar_chart.py +98 -0
- numdaplot/plots/charts/bar_layout.py +58 -0
- numdaplot/plots/charts/bin_count.py +61 -0
- numdaplot/plots/charts/bin_width.py +78 -0
- numdaplot/plots/charts/box_chart.py +97 -0
- numdaplot/plots/charts/cell_values.py +61 -0
- numdaplot/plots/charts/chart.py +59 -0
- numdaplot/plots/charts/chart_settings.py +105 -0
- numdaplot/plots/charts/color_scale.py +147 -0
- numdaplot/plots/charts/heatmap_chart.py +92 -0
- numdaplot/plots/charts/histogram_chart.py +93 -0
- numdaplot/plots/charts/line_chart.py +100 -0
- numdaplot/plots/charts/line_type.py +75 -0
- numdaplot/plots/charts/marker_shape.py +113 -0
- numdaplot/plots/charts/missing_chart.py +60 -0
- numdaplot/plots/charts/missing_map_chart.py +27 -0
- numdaplot/plots/charts/orientation.py +58 -0
- numdaplot/plots/charts/outliers.py +49 -0
- numdaplot/plots/charts/percentages.py +55 -0
- numdaplot/plots/charts/pie_chart.py +87 -0
- numdaplot/plots/charts/scatter_chart.py +159 -0
- numdaplot/plots/charts/value_axis.py +66 -0
- numdaplot/plots/data/__init__.py +5 -0
- numdaplot/plots/data/array_values.py +128 -0
- numdaplot/plots/data/chart_data.py +143 -0
- numdaplot/plots/data/chart_values.py +109 -0
- numdaplot/plots/data/column_reading.py +468 -0
- numdaplot/plots/data/heatmap_values.py +63 -0
- numdaplot/plots/data/missing_cells.py +165 -0
- numdaplot/plots/data/pie_values.py +215 -0
- numdaplot/plots/data/point_values.py +249 -0
- numdaplot/plots/data/position_kind.py +83 -0
- numdaplot/plots/data/renamed_layers.py +340 -0
- numdaplot/plots/data/sample_values.py +160 -0
- numdaplot/plots/data/shown_columns.py +248 -0
- numdaplot/plots/data/table_values.py +256 -0
- numdaplot/plots/data/unique_labels.py +45 -0
- numdaplot/plots/drawing/__init__.py +5 -0
- numdaplot/plots/drawing/bar_drawing.py +316 -0
- numdaplot/plots/drawing/box_drawing.py +344 -0
- numdaplot/plots/drawing/cell_merging.py +237 -0
- numdaplot/plots/drawing/chart_texts.py +124 -0
- numdaplot/plots/drawing/color_bar.py +57 -0
- numdaplot/plots/drawing/color_scale_values.py +120 -0
- numdaplot/plots/drawing/default_labels.py +41 -0
- numdaplot/plots/drawing/drawn_chart.py +50 -0
- numdaplot/plots/drawing/grid_axes.py +75 -0
- numdaplot/plots/drawing/heatmap_drawing.py +313 -0
- numdaplot/plots/drawing/histogram_drawing.py +350 -0
- numdaplot/plots/drawing/label_room.py +344 -0
- numdaplot/plots/drawing/label_thinning.py +216 -0
- numdaplot/plots/drawing/layer_alignment.py +319 -0
- numdaplot/plots/drawing/layer_colors.py +123 -0
- numdaplot/plots/drawing/line_drawing.py +85 -0
- numdaplot/plots/drawing/marker_codes.py +20 -0
- numdaplot/plots/drawing/missing_drawing.py +360 -0
- numdaplot/plots/drawing/moment_period_formatter.py +253 -0
- numdaplot/plots/drawing/pie_drawing.py +185 -0
- numdaplot/plots/drawing/plot_axes.py +38 -0
- numdaplot/plots/drawing/plot_drawing.py +288 -0
- numdaplot/plots/drawing/plot_theme.py +45 -0
- numdaplot/plots/drawing/position_axis.py +278 -0
- numdaplot/plots/drawing/scatter_drawing.py +364 -0
- numdaplot/plots/drawing/series_colors.py +177 -0
- numdaplot/plots/drawing/size_inches.py +45 -0
- numdaplot/plots/drawing/style_drawing.py +410 -0
- numdaplot/plots/drawing/text_contrast.py +44 -0
- numdaplot/plots/drawing/tick_rotation.py +354 -0
- numdaplot/plots/drawing/time_axis.py +212 -0
- numdaplot/plots/drawing/whole_numbers.py +72 -0
- numdaplot/plots/figure/__init__.py +5 -0
- numdaplot/plots/figure/cell.py +95 -0
- numdaplot/plots/figure/figure.py +256 -0
- numdaplot/plots/figure/figure_drawing.py +99 -0
- numdaplot/plots/figure/figure_style.py +60 -0
- numdaplot/plots/figure/layout.py +71 -0
- numdaplot/plots/figure/placement.py +150 -0
- numdaplot/plots/layer_reading.py +166 -0
- numdaplot/plots/output/__init__.py +5 -0
- numdaplot/plots/output/image_saving.py +187 -0
- numdaplot/plots/output/plot_display.py +181 -0
- numdaplot/plots/output/shown_object.py +45 -0
- numdaplot/plots/overlay_checks.py +245 -0
- numdaplot/plots/plot.py +31 -0
- numdaplot/plots/plot_data.py +140 -0
- numdaplot/plots/plot_distribution_creation.py +237 -0
- numdaplot/plots/plot_output.py +124 -0
- numdaplot/plots/plot_overlays.py +273 -0
- numdaplot/plots/plot_overview_creation.py +195 -0
- numdaplot/plots/plot_series_creation.py +213 -0
- numdaplot/plots/style/__init__.py +5 -0
- numdaplot/plots/style/axis_settings.py +60 -0
- numdaplot/plots/style/color.py +168 -0
- numdaplot/plots/style/custom_color.py +65 -0
- numdaplot/plots/style/grid_lines.py +49 -0
- numdaplot/plots/style/image_options.py +71 -0
- numdaplot/plots/style/legend_position.py +149 -0
- numdaplot/plots/style/plot_style.py +136 -0
- numdaplot/plots/style/size.py +70 -0
- numdaplot/plots/style/size_unit.py +62 -0
- numdaplot/positions/__init__.py +5 -0
- numdaplot/positions/axis.py +54 -0
- numdaplot/positions/index.py +51 -0
- numdaplot/positions/range.py +90 -0
- numdaplot/positions/region.py +92 -0
- numdaplot/py.typed +0 -0
- numdaplot/ratios/__init__.py +5 -0
- numdaplot/ratios/fraction.py +40 -0
- numdaplot/ratios/measure.py +48 -0
- numdaplot/rules/__init__.py +5 -0
- numdaplot/rules/between.py +78 -0
- numdaplot/rules/bounds.py +83 -0
- numdaplot/rules/case.py +48 -0
- numdaplot/rules/contains.py +63 -0
- numdaplot/rules/equal.py +43 -0
- numdaplot/rules/greater.py +39 -0
- numdaplot/rules/greater_or_equal.py +38 -0
- numdaplot/rules/is_in.py +67 -0
- numdaplot/rules/is_missing.py +25 -0
- numdaplot/rules/is_present.py +25 -0
- numdaplot/rules/less.py +39 -0
- numdaplot/rules/less_or_equal.py +38 -0
- numdaplot/rules/not_equal.py +45 -0
- numdaplot/rules/rule.py +62 -0
- numdaplot/rules/rule_values.py +44 -0
- numdaplot/rules/value_rule.py +110 -0
- numdaplot/settings/__init__.py +5 -0
- numdaplot/settings/argument_types.py +327 -0
- numdaplot/settings/field_types.py +593 -0
- numdaplot/statistics/__init__.py +5 -0
- numdaplot/statistics/count.py +71 -0
- numdaplot/statistics/count_distinct.py +27 -0
- numdaplot/statistics/counted_missing.py +46 -0
- numdaplot/statistics/maximum.py +27 -0
- numdaplot/statistics/mean.py +27 -0
- numdaplot/statistics/median.py +27 -0
- numdaplot/statistics/minimum.py +27 -0
- numdaplot/statistics/most_frequent.py +27 -0
- numdaplot/statistics/most_frequent_count.py +27 -0
- numdaplot/statistics/quantile.py +61 -0
- numdaplot/statistics/standard_deviation.py +29 -0
- numdaplot/statistics/statistic.py +63 -0
- numdaplot/statistics/sum.py +27 -0
- numdaplot/tables/__init__.py +5 -0
- numdaplot/tables/aggregation/__init__.py +5 -0
- numdaplot/tables/aggregation/aggregated_frame.py +189 -0
- numdaplot/tables/aggregation/aggregation.py +97 -0
- numdaplot/tables/aggregation/calculation.py +123 -0
- numdaplot/tables/aggregation/result_column.py +108 -0
- numdaplot/tables/aggregation/row_groups.py +96 -0
- numdaplot/tables/aggregation/statistic_name.py +122 -0
- numdaplot/tables/columns/__init__.py +5 -0
- numdaplot/tables/columns/added_column.py +89 -0
- numdaplot/tables/columns/boolean_conversion.py +144 -0
- numdaplot/tables/columns/boolean_rule.py +59 -0
- numdaplot/tables/columns/bracket_end.py +50 -0
- numdaplot/tables/columns/bracket_names.py +346 -0
- numdaplot/tables/columns/bracketed_column.py +179 -0
- numdaplot/tables/columns/brackets.py +234 -0
- numdaplot/tables/columns/chosen_columns.py +55 -0
- numdaplot/tables/columns/column_choice.py +84 -0
- numdaplot/tables/columns/column_mode.py +64 -0
- numdaplot/tables/columns/column_names.py +186 -0
- numdaplot/tables/columns/conversion.py +103 -0
- numdaplot/tables/columns/converted_column.py +669 -0
- numdaplot/tables/columns/date_conversion.py +526 -0
- numdaplot/tables/columns/date_range.py +135 -0
- numdaplot/tables/columns/name_change.py +67 -0
- numdaplot/tables/columns/new_column.py +79 -0
- numdaplot/tables/columns/number_conversion.py +281 -0
- numdaplot/tables/columns/renamed_columns.py +60 -0
- numdaplot/tables/columns/renaming.py +81 -0
- numdaplot/tables/columns/text_conversion.py +70 -0
- numdaplot/tables/columns/time_conversion.py +313 -0
- numdaplot/tables/columns/time_zone_conversion.py +128 -0
- numdaplot/tables/conflict.py +68 -0
- numdaplot/tables/description/__init__.py +5 -0
- numdaplot/tables/description/described_frame.py +335 -0
- numdaplot/tables/description/description.py +155 -0
- numdaplot/tables/duplicates/__init__.py +5 -0
- numdaplot/tables/duplicates/deduplicated_frame.py +66 -0
- numdaplot/tables/duplicates/deduplication.py +88 -0
- numdaplot/tables/duplicates/keep.py +81 -0
- numdaplot/tables/files/__init__.py +5 -0
- numdaplot/tables/files/column_names.py +60 -0
- numdaplot/tables/files/csv_file.py +265 -0
- numdaplot/tables/files/csv_read_options.py +89 -0
- numdaplot/tables/files/csv_separator.py +41 -0
- numdaplot/tables/files/csv_write_options.py +79 -0
- numdaplot/tables/files/decimal_count.py +42 -0
- numdaplot/tables/files/encoding.py +82 -0
- numdaplot/tables/files/excel_file.py +171 -0
- numdaplot/tables/files/excel_read_options.py +79 -0
- numdaplot/tables/files/excel_sheet.py +50 -0
- numdaplot/tables/files/excel_time_cells.py +146 -0
- numdaplot/tables/files/excel_write_options.py +63 -0
- numdaplot/tables/files/file_access.py +152 -0
- numdaplot/tables/files/file_paths.py +106 -0
- numdaplot/tables/files/json_decimals.py +387 -0
- numdaplot/tables/files/json_file.py +203 -0
- numdaplot/tables/files/json_layout.py +63 -0
- numdaplot/tables/files/json_read_options.py +64 -0
- numdaplot/tables/files/json_write_options.py +71 -0
- numdaplot/tables/files/missing_texts.py +63 -0
- numdaplot/tables/files/optional_package.py +42 -0
- numdaplot/tables/files/pandas_backend.py +11 -0
- numdaplot/tables/files/parquet_file.py +91 -0
- numdaplot/tables/files/parquet_read_options.py +56 -0
- numdaplot/tables/files/sas_file.py +94 -0
- numdaplot/tables/files/sas_read_options.py +67 -0
- numdaplot/tables/files/stata_file.py +83 -0
- numdaplot/tables/files/stata_read_options.py +56 -0
- numdaplot/tables/files/xpt_read_options.py +65 -0
- numdaplot/tables/filtering/__init__.py +5 -0
- numdaplot/tables/filtering/checked_frame.py +60 -0
- numdaplot/tables/filtering/column_mask.py +71 -0
- numdaplot/tables/filtering/column_match.py +62 -0
- numdaplot/tables/filtering/condition.py +94 -0
- numdaplot/tables/filtering/filter.py +74 -0
- numdaplot/tables/filtering/filter_mode.py +67 -0
- numdaplot/tables/filtering/row_mask.py +152 -0
- numdaplot/tables/filtering/rule_moments.py +164 -0
- numdaplot/tables/frames/__init__.py +5 -0
- numdaplot/tables/frames/array_frame.py +95 -0
- numdaplot/tables/frames/cleaned_names.py +132 -0
- numdaplot/tables/frames/column.py +15 -0
- numdaplot/tables/frames/column_values.py +273 -0
- numdaplot/tables/frames/frame_equality.py +130 -0
- numdaplot/tables/frames/frame_normalization.py +459 -0
- numdaplot/tables/frames/named_column_errors.py +85 -0
- numdaplot/tables/frames/pandas_decimals.py +113 -0
- numdaplot/tables/frames/region_positions.py +113 -0
- numdaplot/tables/frames/table_text.py +222 -0
- numdaplot/tables/frames/time_columns.py +345 -0
- numdaplot/tables/frames/time_range_errors.py +117 -0
- numdaplot/tables/frames/time_zones.py +271 -0
- numdaplot/tables/joining/__init__.py +5 -0
- numdaplot/tables/joining/join.py +110 -0
- numdaplot/tables/joining/join_keys.py +367 -0
- numdaplot/tables/joining/join_mode.py +93 -0
- numdaplot/tables/joining/join_relation.py +149 -0
- numdaplot/tables/joining/join_suffixes.py +71 -0
- numdaplot/tables/joining/joined_frame.py +166 -0
- numdaplot/tables/joining/joined_names.py +107 -0
- numdaplot/tables/joining/joined_rows.py +235 -0
- numdaplot/tables/joining/key_types.py +57 -0
- numdaplot/tables/joining/relation.py +78 -0
- numdaplot/tables/missing/__init__.py +5 -0
- numdaplot/tables/missing/missing_count.py +59 -0
- numdaplot/tables/missing/missing_counts.py +214 -0
- numdaplot/tables/missing/missing_drop.py +98 -0
- numdaplot/tables/missing/missing_mode.py +63 -0
- numdaplot/tables/missing/missing_ratio.py +71 -0
- numdaplot/tables/missing/missing_removal.py +257 -0
- numdaplot/tables/missing/missing_summary.py +174 -0
- numdaplot/tables/missing/ratio_comparison.py +70 -0
- numdaplot/tables/pivot/__init__.py +5 -0
- numdaplot/tables/pivot/pivot_table.py +104 -0
- numdaplot/tables/pivot/pivoted_frame.py +244 -0
- numdaplot/tables/preview/__init__.py +5 -0
- numdaplot/tables/preview/notebook_display.py +238 -0
- numdaplot/tables/preview/preview.py +100 -0
- numdaplot/tables/preview/preview_rows.py +55 -0
- numdaplot/tables/preview/shown_columns.py +62 -0
- numdaplot/tables/preview/side.py +82 -0
- numdaplot/tables/sorting/__init__.py +5 -0
- numdaplot/tables/sorting/sort_key.py +71 -0
- numdaplot/tables/sorting/sorted_frame.py +81 -0
- numdaplot/tables/sorting/sorting.py +82 -0
- numdaplot/tables/table.py +71 -0
- numdaplot/tables/table_calculation.py +172 -0
- numdaplot/tables/table_columns.py +214 -0
- numdaplot/tables/table_conversion.py +351 -0
- numdaplot/tables/table_data.py +321 -0
- numdaplot/tables/table_display.py +56 -0
- numdaplot/tables/table_joining.py +80 -0
- numdaplot/tables/table_layout.py +105 -0
- numdaplot/tables/table_missing.py +146 -0
- numdaplot/tables/table_reading.py +451 -0
- numdaplot/tables/table_refusals.py +295 -0
- numdaplot/tables/table_selection.py +163 -0
- numdaplot/tables/table_writing.py +269 -0
- numdaplot-0.1.0.dist-info/METADATA +176 -0
- numdaplot-0.1.0.dist-info/RECORD +474 -0
- numdaplot-0.1.0.dist-info/WHEEL +4 -0
- numdaplot-0.1.0.dist-info/licenses/LICENSE +28 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Conversion of Python values to numpy values of a numdaplot type.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 0.1.0
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import numpy
|
|
10
|
+
from numpy.typing import NDArray
|
|
11
|
+
|
|
12
|
+
from numdaplot.arrays.creation.list_shape import find_list_shape, flatten_list
|
|
13
|
+
from numdaplot.arrays.operations.time_bounds import require_stored_times_fit
|
|
14
|
+
from numdaplot.data_types.numpy_mapping import to_numpy_dtype
|
|
15
|
+
from numdaplot.data_types.time_of_day import MISSING_TIME, store_times
|
|
16
|
+
from numdaplot.data_types.type import Type
|
|
17
|
+
from numdaplot.data_types.value_type import find_common_type, find_value_type
|
|
18
|
+
from numdaplot.errors.missing_type_error import MissingTypeError
|
|
19
|
+
from numdaplot.errors.unsupported_missing_error import UnsupportedMissingError
|
|
20
|
+
from numdaplot.errors.value_conversion_error import ValueConversionError
|
|
21
|
+
|
|
22
|
+
FROM_LIST_OPERATION = "from_list"
|
|
23
|
+
SAFE_CASTING = "same_kind"
|
|
24
|
+
WHOLE_NUMBER_KINDS = frozenset({"i", "u"})
|
|
25
|
+
NOT_A_TIME = "NaT"
|
|
26
|
+
NANOSECOND_UNIT = "ns"
|
|
27
|
+
MISSING_MARKERS = {
|
|
28
|
+
Type.FLOAT32: numpy.nan,
|
|
29
|
+
Type.FLOAT64: numpy.nan,
|
|
30
|
+
Type.TEXT: numpy.nan,
|
|
31
|
+
Type.DATE: numpy.datetime64(NOT_A_TIME, NANOSECOND_UNIT),
|
|
32
|
+
Type.DATETIME: numpy.datetime64(NOT_A_TIME, NANOSECOND_UNIT),
|
|
33
|
+
Type.DURATION: numpy.timedelta64(NOT_A_TIME, NANOSECOND_UNIT),
|
|
34
|
+
Type.TIME: MISSING_TIME,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def convert_list(values: list[object], dtype: Type | None) -> NDArray[Any]:
|
|
39
|
+
"""
|
|
40
|
+
Return the numpy values of nested Python lists, stored as a numdaplot type.
|
|
41
|
+
|
|
42
|
+
.. versionadded:: 0.1.0
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
values
|
|
47
|
+
A list of single values or of nested lists. ``None`` is a missing value.
|
|
48
|
+
dtype
|
|
49
|
+
The type to store the values as, guessed from the values when ``None``.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
NDArray
|
|
54
|
+
The values, with one dimension per nesting level.
|
|
55
|
+
|
|
56
|
+
Raises
|
|
57
|
+
------
|
|
58
|
+
IrregularListError
|
|
59
|
+
When nested lists do not form a regular block.
|
|
60
|
+
IncompatibleTypesError
|
|
61
|
+
When the values mix several families of types, such as numbers and texts.
|
|
62
|
+
MissingTypeError
|
|
63
|
+
When ``dtype`` is ``None`` and there is no present value to guess the type from.
|
|
64
|
+
UnsupportedMissingError
|
|
65
|
+
When a value is missing and the type cannot hold missing values.
|
|
66
|
+
ValueConversionError
|
|
67
|
+
When the values cannot be stored as ``dtype`` without losing information.
|
|
68
|
+
TimeOverflowError
|
|
69
|
+
When a value stored as ``DATETIME`` or ``DURATION`` is outside the range of nanoseconds.
|
|
70
|
+
|
|
71
|
+
Examples
|
|
72
|
+
--------
|
|
73
|
+
>>> from numdaplot.arrays.creation.list_conversion import convert_list
|
|
74
|
+
>>> convert_list([[1, 2], [3, 4.5]], None)
|
|
75
|
+
array([[1. , 2. ],
|
|
76
|
+
[3. , 4.5]])
|
|
77
|
+
"""
|
|
78
|
+
dimensions = find_list_shape(values)
|
|
79
|
+
single_values = flatten_list(values)
|
|
80
|
+
guessed_type = guess_list_type(single_values)
|
|
81
|
+
stored_type = choose_stored_type(guessed_type, dtype)
|
|
82
|
+
require_stored_times_fit(single_values, stored_type, FROM_LIST_OPERATION)
|
|
83
|
+
marked_values = mark_missing_values(single_values, stored_type)
|
|
84
|
+
stored_values = store_values(marked_values, guessed_type, stored_type)
|
|
85
|
+
shaped_values = stored_values.reshape(dimensions)
|
|
86
|
+
|
|
87
|
+
return shaped_values
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def guess_list_type(single_values: list[object]) -> Type | None:
|
|
91
|
+
"""
|
|
92
|
+
Return the type holding every present value of a flat list.
|
|
93
|
+
|
|
94
|
+
.. versionadded:: 0.1.0
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
single_values
|
|
99
|
+
Single values, ``None`` being a missing value.
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
Type or None
|
|
104
|
+
The common type of the present values, or ``None`` when no value is present.
|
|
105
|
+
|
|
106
|
+
Raises
|
|
107
|
+
------
|
|
108
|
+
IncompatibleTypesError
|
|
109
|
+
When the values mix several families of types.
|
|
110
|
+
|
|
111
|
+
Examples
|
|
112
|
+
--------
|
|
113
|
+
>>> from numdaplot.arrays.creation.list_conversion import guess_list_type
|
|
114
|
+
>>> guess_list_type([1, None, 2.5])
|
|
115
|
+
<Type.FLOAT64: 10>
|
|
116
|
+
"""
|
|
117
|
+
value_types = [find_value_type(value) for value in single_values if value is not None]
|
|
118
|
+
type_count = len(value_types)
|
|
119
|
+
if type_count == 0:
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
common_type = find_common_type(value_types, FROM_LIST_OPERATION)
|
|
123
|
+
|
|
124
|
+
return common_type
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def choose_stored_type(guessed_type: Type | None, dtype: Type | None) -> Type:
|
|
128
|
+
"""
|
|
129
|
+
Return the type the values are stored as: the given one, or else the guessed one.
|
|
130
|
+
|
|
131
|
+
.. versionadded:: 0.1.0
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
guessed_type
|
|
136
|
+
The type guessed from the present values, ``None`` when no value is present.
|
|
137
|
+
dtype
|
|
138
|
+
The type given by the user, ``None`` when omitted.
|
|
139
|
+
|
|
140
|
+
Returns
|
|
141
|
+
-------
|
|
142
|
+
Type
|
|
143
|
+
``dtype`` when given, otherwise ``guessed_type``.
|
|
144
|
+
|
|
145
|
+
Raises
|
|
146
|
+
------
|
|
147
|
+
MissingTypeError
|
|
148
|
+
When both types are ``None``.
|
|
149
|
+
|
|
150
|
+
Examples
|
|
151
|
+
--------
|
|
152
|
+
>>> import numdaplot as ndp
|
|
153
|
+
>>> from numdaplot.arrays.creation.list_conversion import choose_stored_type
|
|
154
|
+
>>> choose_stored_type(ndp.Type.INT64, ndp.Type.FLOAT32)
|
|
155
|
+
<Type.FLOAT32: 9>
|
|
156
|
+
"""
|
|
157
|
+
if dtype is not None:
|
|
158
|
+
return dtype
|
|
159
|
+
|
|
160
|
+
if guessed_type is None:
|
|
161
|
+
raise MissingTypeError()
|
|
162
|
+
|
|
163
|
+
return guessed_type
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def mark_missing_values(single_values: list[object], stored_type: Type) -> list[object]:
|
|
167
|
+
"""
|
|
168
|
+
Replace each ``None`` with the missing value marker of a type.
|
|
169
|
+
|
|
170
|
+
.. versionadded:: 0.1.0
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
single_values
|
|
175
|
+
Single values, ``None`` being a missing value.
|
|
176
|
+
stored_type
|
|
177
|
+
The type the values are stored as.
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
list[object]
|
|
182
|
+
The values, with NaN for decimals and NaT for dates and durations instead of ``None``.
|
|
183
|
+
|
|
184
|
+
Raises
|
|
185
|
+
------
|
|
186
|
+
UnsupportedMissingError
|
|
187
|
+
When a value is missing and the type has no missing value marker.
|
|
188
|
+
|
|
189
|
+
Examples
|
|
190
|
+
--------
|
|
191
|
+
>>> import numdaplot as ndp
|
|
192
|
+
>>> from numdaplot.arrays.creation.list_conversion import mark_missing_values
|
|
193
|
+
>>> mark_missing_values([1.5, None], ndp.Type.FLOAT64)
|
|
194
|
+
[1.5, nan]
|
|
195
|
+
"""
|
|
196
|
+
has_missing_value = None in single_values
|
|
197
|
+
if not has_missing_value:
|
|
198
|
+
return single_values
|
|
199
|
+
|
|
200
|
+
if stored_type not in MISSING_MARKERS:
|
|
201
|
+
raise UnsupportedMissingError(stored_type.name)
|
|
202
|
+
|
|
203
|
+
missing_marker = MISSING_MARKERS[stored_type]
|
|
204
|
+
marked_values = [missing_marker if value is None else value for value in single_values]
|
|
205
|
+
|
|
206
|
+
return marked_values
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def store_values(marked_values: list[object], guessed_type: Type | None, stored_type: Type) -> NDArray[Any]:
|
|
210
|
+
"""
|
|
211
|
+
Return the values as a flat numpy array of the stored type.
|
|
212
|
+
|
|
213
|
+
.. versionadded:: 0.1.0
|
|
214
|
+
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
marked_values
|
|
218
|
+
Single values whose missing values are already replaced with markers.
|
|
219
|
+
guessed_type
|
|
220
|
+
The type guessed from the present values, ``None`` when no value is present.
|
|
221
|
+
stored_type
|
|
222
|
+
The type the values are stored as.
|
|
223
|
+
|
|
224
|
+
Returns
|
|
225
|
+
-------
|
|
226
|
+
NDArray
|
|
227
|
+
A one-dimensional array of the stored type.
|
|
228
|
+
|
|
229
|
+
Raises
|
|
230
|
+
------
|
|
231
|
+
UnsupportedTypeError
|
|
232
|
+
When the stored type has no numpy equivalent, which is the case of ``CATEGORY``.
|
|
233
|
+
ValueConversionError
|
|
234
|
+
When the guessed type cannot be stored as the stored type without losing information,
|
|
235
|
+
or when a value exceeds the range of the stored type, such as -1 stored as ``UINT8``.
|
|
236
|
+
|
|
237
|
+
Examples
|
|
238
|
+
--------
|
|
239
|
+
>>> import numdaplot as ndp
|
|
240
|
+
>>> from numdaplot.arrays.creation.list_conversion import store_values
|
|
241
|
+
>>> store_values([1, 2], ndp.Type.INT64, ndp.Type.FLOAT64)
|
|
242
|
+
array([1., 2.])
|
|
243
|
+
>>> store_values([1, 2], ndp.Type.INT64, ndp.Type.UINT8)
|
|
244
|
+
array([1, 2], dtype=uint8)
|
|
245
|
+
"""
|
|
246
|
+
if Type.TIME in (guessed_type, stored_type):
|
|
247
|
+
time_values = store_time_values(marked_values, guessed_type, stored_type)
|
|
248
|
+
return time_values
|
|
249
|
+
|
|
250
|
+
stored_dtype = to_numpy_dtype(stored_type)
|
|
251
|
+
if guessed_type is None:
|
|
252
|
+
values_without_present_value = numpy.array(marked_values, dtype=stored_dtype)
|
|
253
|
+
return values_without_present_value
|
|
254
|
+
|
|
255
|
+
guessed_dtype = to_numpy_dtype(guessed_type)
|
|
256
|
+
is_safe = numpy.can_cast(guessed_dtype, stored_dtype, casting=SAFE_CASTING)
|
|
257
|
+
# Integers may be stored as unsigned integers: numpy then rejects each value out of range.
|
|
258
|
+
is_whole_number_storage = guessed_dtype.kind in WHOLE_NUMBER_KINDS and stored_dtype.kind in WHOLE_NUMBER_KINDS
|
|
259
|
+
is_storable = is_safe or is_whole_number_storage
|
|
260
|
+
if not is_storable:
|
|
261
|
+
raise ValueConversionError(guessed_type.name, stored_type.name)
|
|
262
|
+
|
|
263
|
+
try:
|
|
264
|
+
stored_values = numpy.array(marked_values, dtype=stored_dtype)
|
|
265
|
+
except OverflowError as error:
|
|
266
|
+
raise ValueConversionError(guessed_type.name, stored_type.name) from error
|
|
267
|
+
|
|
268
|
+
return stored_values
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def store_time_values(marked_values: list[object], guessed_type: Type | None, stored_type: Type) -> NDArray[Any]:
|
|
272
|
+
"""
|
|
273
|
+
Return times of day stored as ``TIME``, refusing to store them as another type or other values as ``TIME``.
|
|
274
|
+
|
|
275
|
+
.. versionadded:: 0.1.0
|
|
276
|
+
|
|
277
|
+
Parameters
|
|
278
|
+
----------
|
|
279
|
+
marked_values
|
|
280
|
+
The values, missing ones already replaced by NaT.
|
|
281
|
+
guessed_type
|
|
282
|
+
The type of the present values, ``None`` when no value is present.
|
|
283
|
+
stored_type
|
|
284
|
+
The type to store the values as.
|
|
285
|
+
|
|
286
|
+
Returns
|
|
287
|
+
-------
|
|
288
|
+
NDArray
|
|
289
|
+
The times since midnight in ``timedelta64[us]``.
|
|
290
|
+
|
|
291
|
+
Raises
|
|
292
|
+
------
|
|
293
|
+
ValueConversionError
|
|
294
|
+
When times of day are stored as another type, or other values as ``TIME``.
|
|
295
|
+
|
|
296
|
+
Examples
|
|
297
|
+
--------
|
|
298
|
+
>>> from datetime import time
|
|
299
|
+
>>> import numdaplot as ndp
|
|
300
|
+
>>> from numdaplot.arrays.creation.list_conversion import store_time_values
|
|
301
|
+
>>> store_time_values([time(0, 1)], ndp.Type.TIME, ndp.Type.TIME)
|
|
302
|
+
array([60000000], dtype='timedelta64[us]')
|
|
303
|
+
"""
|
|
304
|
+
is_time_storage = stored_type == Type.TIME and guessed_type in (Type.TIME, None)
|
|
305
|
+
if not is_time_storage:
|
|
306
|
+
guessed_name = stored_type.name if guessed_type is None else guessed_type.name
|
|
307
|
+
raise ValueConversionError(guessed_name, stored_type.name)
|
|
308
|
+
|
|
309
|
+
time_values = store_times(marked_values)
|
|
310
|
+
|
|
311
|
+
return time_values
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Shape and values of nested Python lists.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 0.1.0
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import cast
|
|
8
|
+
|
|
9
|
+
from numdaplot.errors.irregular_list_error import IrregularListError
|
|
10
|
+
|
|
11
|
+
EMPTY_LIST_DIMENSIONS = (0,)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def find_list_shape(values: list[object]) -> tuple[int, ...]:
|
|
15
|
+
"""
|
|
16
|
+
Return the dimensions of nested lists forming a regular block.
|
|
17
|
+
|
|
18
|
+
.. versionadded:: 0.1.0
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
values
|
|
23
|
+
A list of single values, or a list of lists nested to any depth.
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
tuple[int, ...]
|
|
28
|
+
The number of elements at each nesting level.
|
|
29
|
+
|
|
30
|
+
Raises
|
|
31
|
+
------
|
|
32
|
+
IrregularListError
|
|
33
|
+
When the lists at one level have different lengths, or mix lists and single values.
|
|
34
|
+
|
|
35
|
+
Examples
|
|
36
|
+
--------
|
|
37
|
+
>>> from numdaplot.arrays.creation.list_shape import find_list_shape
|
|
38
|
+
>>> find_list_shape([[1, 2, 3], [4, 5, 6]])
|
|
39
|
+
(2, 3)
|
|
40
|
+
"""
|
|
41
|
+
value_count = len(values)
|
|
42
|
+
if value_count == 0:
|
|
43
|
+
return EMPTY_LIST_DIMENSIONS
|
|
44
|
+
|
|
45
|
+
nested_lists = [cast(list[object], value) for value in values if isinstance(value, list)]
|
|
46
|
+
nested_list_count = len(nested_lists)
|
|
47
|
+
if nested_list_count == 0:
|
|
48
|
+
return (value_count,)
|
|
49
|
+
|
|
50
|
+
if nested_list_count != value_count:
|
|
51
|
+
raise IrregularListError()
|
|
52
|
+
|
|
53
|
+
nested_shapes = {find_list_shape(nested_list) for nested_list in nested_lists}
|
|
54
|
+
shape_count = len(nested_shapes)
|
|
55
|
+
if shape_count != 1:
|
|
56
|
+
raise IrregularListError()
|
|
57
|
+
|
|
58
|
+
nested_shape = nested_shapes.pop()
|
|
59
|
+
dimensions = (value_count, *nested_shape)
|
|
60
|
+
|
|
61
|
+
return dimensions
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def flatten_list(values: list[object]) -> list[object]:
|
|
65
|
+
"""
|
|
66
|
+
Return the single values of nested lists, row after row.
|
|
67
|
+
|
|
68
|
+
.. versionadded:: 0.1.0
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
values
|
|
73
|
+
A list of single values, or a list of lists nested to any depth.
|
|
74
|
+
|
|
75
|
+
Returns
|
|
76
|
+
-------
|
|
77
|
+
list[object]
|
|
78
|
+
Every single value, in reading order.
|
|
79
|
+
|
|
80
|
+
Examples
|
|
81
|
+
--------
|
|
82
|
+
>>> from numdaplot.arrays.creation.list_shape import flatten_list
|
|
83
|
+
>>> flatten_list([[1, 2], [3, 4]])
|
|
84
|
+
[1, 2, 3, 4]
|
|
85
|
+
"""
|
|
86
|
+
single_values = list[object]()
|
|
87
|
+
|
|
88
|
+
for value in values:
|
|
89
|
+
if isinstance(value, list):
|
|
90
|
+
nested_list = cast(list[object], value)
|
|
91
|
+
nested_values = flatten_list(nested_list)
|
|
92
|
+
single_values.extend(nested_values)
|
|
93
|
+
continue
|
|
94
|
+
|
|
95
|
+
single_values.append(value)
|
|
96
|
+
|
|
97
|
+
return single_values
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Normal distribution of decimals.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 0.1.0
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
|
|
9
|
+
from numdaplot.arrays.creation.distribution import Distribution
|
|
10
|
+
from numdaplot.errors.invalid_deviation_error import InvalidDeviationError
|
|
11
|
+
from numdaplot.settings.field_types import require_field_types
|
|
12
|
+
|
|
13
|
+
LOWEST_DEVIATION = 0
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class Normal(Distribution):
|
|
18
|
+
"""
|
|
19
|
+
Decimals drawn around a mean, following a bell curve.
|
|
20
|
+
|
|
21
|
+
About 68 % of the values fall within one standard deviation of the mean.
|
|
22
|
+
|
|
23
|
+
.. versionadded:: 0.1.0
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
mean
|
|
28
|
+
Center of the bell curve.
|
|
29
|
+
deviation
|
|
30
|
+
Standard deviation, how far the values spread around the mean, at least 0.
|
|
31
|
+
|
|
32
|
+
Raises
|
|
33
|
+
------
|
|
34
|
+
InvalidTypeError
|
|
35
|
+
When a setting is not of the type its annotation names.
|
|
36
|
+
InvalidDeviationError
|
|
37
|
+
When ``deviation`` is lower than 0.
|
|
38
|
+
|
|
39
|
+
Examples
|
|
40
|
+
--------
|
|
41
|
+
>>> import numdaplot as ndp
|
|
42
|
+
>>> ndp.Array.random(ndp.Normal(mean=170, deviation=10), shape=ndp.Shape([3]), seed=0)
|
|
43
|
+
Array([171.25730221, 168.67895137, 176.4042265 ], dtype=FLOAT64)
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
mean: float
|
|
47
|
+
deviation: float
|
|
48
|
+
|
|
49
|
+
def __post_init__(self) -> None:
|
|
50
|
+
"""
|
|
51
|
+
Check that the standard deviation is not negative.
|
|
52
|
+
|
|
53
|
+
.. versionadded:: 0.1.0
|
|
54
|
+
|
|
55
|
+
Raises
|
|
56
|
+
------
|
|
57
|
+
InvalidTypeError
|
|
58
|
+
When a setting is not of the type its annotation names.
|
|
59
|
+
InvalidDeviationError
|
|
60
|
+
When ``deviation`` is lower than 0.
|
|
61
|
+
"""
|
|
62
|
+
require_field_types(self)
|
|
63
|
+
|
|
64
|
+
if self.deviation < LOWEST_DEVIATION:
|
|
65
|
+
raise InvalidDeviationError(self.deviation)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Conversion of numpy arrays to the values stored by an Array.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 0.1.0
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import numpy
|
|
10
|
+
from numpy.typing import NDArray
|
|
11
|
+
|
|
12
|
+
from numdaplot.data_types.numpy_mapping import from_numpy_dtype, to_numpy_dtype
|
|
13
|
+
from numdaplot.data_types.time_of_day import TIME_DTYPE, holds_only_times, store_time_objects
|
|
14
|
+
from numdaplot.data_types.type import Type
|
|
15
|
+
from numdaplot.errors.time_overflow_error import TimeOverflowError
|
|
16
|
+
|
|
17
|
+
TEXT_KINDS = frozenset({"U", "T"})
|
|
18
|
+
NANOSECOND_DURATION_DTYPE = numpy.dtype("timedelta64[ns]")
|
|
19
|
+
FROM_NUMPY_OPERATION = "from_numpy"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def copy_numpy_values(values: NDArray[Any]) -> NDArray[Any]:
|
|
23
|
+
"""
|
|
24
|
+
Return a copy of a numpy array that an Array can store.
|
|
25
|
+
|
|
26
|
+
.. versionadded:: 0.1.0
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
values
|
|
31
|
+
A numpy array of a type numdaplot supports.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
NDArray
|
|
36
|
+
An independent copy, with texts stored as variable-length texts with NaN as missing value. An object
|
|
37
|
+
array of Python times of day gives times of day, and durations in microseconds give nanoseconds, as
|
|
38
|
+
microseconds store the times of day.
|
|
39
|
+
|
|
40
|
+
Raises
|
|
41
|
+
------
|
|
42
|
+
UnsupportedTypeError
|
|
43
|
+
When numdaplot has no equivalent type, for example complex numbers or other Python objects.
|
|
44
|
+
TimeOverflowError
|
|
45
|
+
When a duration in microseconds is beyond about 292 years, which nanoseconds cannot hold.
|
|
46
|
+
|
|
47
|
+
Examples
|
|
48
|
+
--------
|
|
49
|
+
>>> import numpy
|
|
50
|
+
>>> from numdaplot.arrays.creation.numpy_conversion import copy_numpy_values
|
|
51
|
+
>>> copy_numpy_values(numpy.array(["a", "bc"])).dtype
|
|
52
|
+
StringDType(na_object=nan)
|
|
53
|
+
"""
|
|
54
|
+
if holds_only_times(values):
|
|
55
|
+
time_values = store_time_objects(values)
|
|
56
|
+
return time_values
|
|
57
|
+
|
|
58
|
+
from_numpy_dtype(values.dtype)
|
|
59
|
+
copied_values = values.copy()
|
|
60
|
+
duration_values = normalize_durations(copied_values)
|
|
61
|
+
normalized_values = normalize_text(duration_values)
|
|
62
|
+
|
|
63
|
+
return normalized_values
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def normalize_text(values: NDArray[Any]) -> NDArray[Any]:
|
|
67
|
+
"""
|
|
68
|
+
Return values whose texts are stored with the numpy type of every ``TEXT`` Array.
|
|
69
|
+
|
|
70
|
+
Fixed-length texts become variable-length texts, and any other marker of a missing text becomes NaN.
|
|
71
|
+
|
|
72
|
+
.. versionadded:: 0.1.0
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
values
|
|
77
|
+
A numpy array of any type.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
NDArray
|
|
82
|
+
The same array when it holds no text or already has this type, otherwise a converted copy.
|
|
83
|
+
|
|
84
|
+
Examples
|
|
85
|
+
--------
|
|
86
|
+
>>> import numpy
|
|
87
|
+
>>> from numdaplot.arrays.creation.numpy_conversion import normalize_text
|
|
88
|
+
>>> normalize_text(numpy.array(["a"])).dtype
|
|
89
|
+
StringDType(na_object=nan)
|
|
90
|
+
>>> marked_with_none = numpy.dtypes.StringDType(na_object=None)
|
|
91
|
+
>>> normalize_text(numpy.array(["a", None], dtype=marked_with_none))
|
|
92
|
+
array(['a', nan], dtype=StringDType(na_object=nan))
|
|
93
|
+
"""
|
|
94
|
+
if values.dtype.kind not in TEXT_KINDS:
|
|
95
|
+
return values
|
|
96
|
+
|
|
97
|
+
text_dtype = to_numpy_dtype(Type.TEXT)
|
|
98
|
+
if values.dtype == text_dtype:
|
|
99
|
+
return values
|
|
100
|
+
|
|
101
|
+
text_values = values.astype(text_dtype)
|
|
102
|
+
|
|
103
|
+
return text_values
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def normalize_durations(values: NDArray[Any]) -> NDArray[Any]:
|
|
107
|
+
"""
|
|
108
|
+
Return durations in microseconds as nanoseconds, since microseconds store the times of day.
|
|
109
|
+
|
|
110
|
+
.. versionadded:: 0.1.0
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
values
|
|
115
|
+
A numpy array of any type.
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
NDArray
|
|
120
|
+
The same array unless it holds durations in microseconds, which become nanoseconds.
|
|
121
|
+
|
|
122
|
+
Raises
|
|
123
|
+
------
|
|
124
|
+
TimeOverflowError
|
|
125
|
+
When a duration is beyond about 292 years, which nanoseconds cannot hold.
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
>>> import numpy
|
|
130
|
+
>>> from numdaplot.arrays.creation.numpy_conversion import normalize_durations
|
|
131
|
+
>>> normalize_durations(numpy.array([1, "NaT"], dtype="timedelta64[us]"))
|
|
132
|
+
array([ 1000, 'NaT'], dtype='timedelta64[ns]')
|
|
133
|
+
"""
|
|
134
|
+
if values.dtype != TIME_DTYPE:
|
|
135
|
+
return values
|
|
136
|
+
|
|
137
|
+
try:
|
|
138
|
+
nanosecond_values = values.astype(NANOSECOND_DURATION_DTYPE)
|
|
139
|
+
except OverflowError as error:
|
|
140
|
+
raise TimeOverflowError(FROM_NUMPY_OPERATION, Type.DURATION.name) from error
|
|
141
|
+
|
|
142
|
+
# Some versions of numpy wrap a value beyond the range of nanoseconds instead of raising.
|
|
143
|
+
microsecond_values = nanosecond_values.astype(TIME_DTYPE)
|
|
144
|
+
is_kept = (microsecond_values == values) | numpy.isnat(values)
|
|
145
|
+
is_exact = bool(is_kept.all())
|
|
146
|
+
if not is_exact:
|
|
147
|
+
raise TimeOverflowError(FROM_NUMPY_OPERATION, Type.DURATION.name)
|
|
148
|
+
|
|
149
|
+
return nanosecond_values
|