Skip to content

[ENH] Add units for stored properties - #239

Merged
lmmentel merged 14 commits into
masterfrom
enh/units-mixin
Sep 16, 2025
Merged

[ENH] Add units for stored properties#239
lmmentel merged 14 commits into
masterfrom
enh/units-mixin

Conversation

@lmmentel

@lmmentel lmmentel commented Jun 6, 2025

Copy link
Copy Markdown
Owner

See discussion #162

TODO

  • update documentation with guide on accessing properties with units

Comment thread tasks.py Dismissed
@lmmentel lmmentel added the enhancement New feature or request label Jun 6, 2025
@lmmentel
lmmentel requested a review from Copilot June 14, 2025 08:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

Adds pint-based unit support for stored ORM properties and related tests

  • Introduces UnitMixin and a global UnitRegistry in models.py to enable <attribute>_u accessors returning pint.Quantity
  • Updates element, isotope, ionic radius, ionization energy, phase transition, and scattering factor classes to mix in UnitMixin
  • Adds unit tests in tests/test_units.py, updates dependencies (pint) and CI (POETRY_VERSION), and a new timeimport dev task

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_units.py Added tests for _u-suffixed unit accessors
tasks.py Added timeimport task to measure import performance
pyproject.toml Added pint dependency
mendeleev/models.py Introduced UnitRegistry, UnitMixin, and updated ORM classes
.github/workflows/main.yml Bumped Poetry version in CI environment
Comments suppressed due to low confidence (5)

.github/workflows/main.yml:4

  • The env section should define a mapping rather than a list item; ensure correct indentation and remove any leading - so CI reads this variable.
POETRY_VERSION: 2.1.3

tasks.py:137

  • [nitpick] The new timeimport task lacks a docstring. Consider adding one to describe its purpose and usage.
@task

tests/test_units.py:174

  • Tests cover stored properties but omit computed unit properties such as boiling_point_u and melting_point_u. Consider adding tests for these _u accessors.
# methods

mendeleev/models.py:1200

  • Typo in half_life_u: using self.half_file instead of self.half_life will raise an AttributeError. Change to self.half_life.
return self.half_file * ureg(self.half_life_unit)

mendeleev/models.py:88

  • The code uses enum.Enum but enum is not imported. Add import enum at the top of the file.
class ValueOrigin(enum.Enum):

@lmmentel
lmmentel enabled auto-merge (squash) September 16, 2025 18:28
@lmmentel
lmmentel disabled auto-merge September 16, 2025 18:39
@lmmentel
lmmentel merged commit 4e02078 into master Sep 16, 2025
20 checks passed
@lmmentel
lmmentel deleted the enh/units-mixin branch September 16, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants