Skip to content

[DCP - SigFigs] Modifies the preprocessor to stop conversion to int/double - #724

Open
gmechali wants to merge 5 commits into
datacommonsorg:masterfrom
gmechali:sigfig
Open

[DCP - SigFigs] Modifies the preprocessor to stop conversion to int/double#724
gmechali wants to merge 5 commits into
datacommonsorg:masterfrom
gmechali:sigfig

Conversation

@gmechali

@gmechali gmechali commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Ensures observation values are preserved as raw strings throughout the simple importer pipeline to prevent loss of significant figures (SigFigs) and precision degradation from floating-point conversions.

  • CSV Ingestion: Read all CSV columns with dtype=str to prevent pandas from coercing observation values to float64/int64 and stripping trailing zeroes.
  • JSON-LD Sharding: Export observation values directly as raw strings ("dcid:value": str(value)) rather than casting via _parse_numeric().
  • Validation: Enforce non-destructive numeric validation (validate_numeric_values) that validates number syntax and errors on malformed inputs without modifying the string representation.
  • Tests: Added unit tests in data_test.py and observations_importer_test.py; updated runner test goldens.

Testing

  • Unit Tests: All 185/185 tests passing (pytest tests/).
  • Sample Verification: Generated JSON-LD shards for samples/sigfig_test and verified that trailing zeroes ("12.50", "12.5000"), micro decimals ("0.0000001230"), and large integer counters ("100000000000000001") are preserved exactly.

…tring throughout. Validation of numbers is preserved, but we never convert to it

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the ObservationsImporter to read all CSV columns as strings (dtype=str) to preserve significant figures, removing redundant type conversions. It also adds unit tests to verify significant figure preservation and the validation/filtering of numeric values, and updates SQL test expectations to reflect the preserved decimal precision (e.g., '0.50' instead of '0.5'). There are no review comments, so no feedback is provided.

@codacy-production

codacy-production Bot commented Aug 14, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 minor

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
CodeStyle 1 minor

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gmechali

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the CSV importing and JSON-LD exporting logic to read and store observation values as strings instead of converting them to numeric types. This change ensures that significant figures (such as trailing zeros) are preserved throughout the data pipeline. Unit tests and expected test outputs have been updated to reflect this change. I have no feedback to provide as there are no review comments.

@@ -71,9 +71,10 @@ def _process_chunks(self) -> None:
debug_dfs = []

with self.input_file.open_stream() as stream:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this wohle file. Still need to delete. Modifying because before deleting this, I want to make a better testing story, so I want to keep it working until I migrate the tests

@clincoln8 clincoln8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants