Skip to content

Using Value.as_unit raises an import error if Pint is not installed (and Pint is not a requirement) #134

@alexhroom

Description

@alexhroom

Currently, if a user tries to perform unit conversion on a Value object and does not have pint installed, it raises an error:

from orsopy.fileio.model_language import Value

val = Value(5.0, 'nm')
val.as_unit("angstrom")

produces an import error for pint. This is a problem because pint is not an installation requirement for orsopy, but it seems orsopy depends on it. I think that either:

  • pint needs to be added to the requirements (and then the pint types can be used instead of the orsopy Value classes!)
  • or
  • a more descriptive error telling the user that they can only do unit conversions if they install pint should be added (and maybe popular unit conversions like nm <-> angstrom can be provided by orsopy itself)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions