Visual Acuity
Bases: BaseModel
The visual_acuity
module contains methods in handling visual acuity measurements.
Input for this class can be provided as keyword arguments. However, a string such as '6/6' can be parsed as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
numerator |
int
|
The test distance. |
required |
denominator |
int
|
This distance required to subtend 5 minutes of arc. |
required |
unit |
Literal[ft, m]
|
Takes feet or metres/meters only. Defaults to 'm', but please check examples for nuances. |
required |
Examples:
Typical use:
>>> va = VisualAcuity(numerator=6, denominator=6)
>>> str(va)
'6/6'
If you want to explicitly mention the units:
>>> va_feet = VisualAcuity(numerator=20, numerator=20, unit="ft")
>>> str(va_feet)
'20/20'
Parsing more familiar input:
>>> va_familiar = VisualAcuity('6/120')
>>> va_familiar
VisualAcuity(numerator=6.0, denominator=120.0, unit='m')
If the numerator is greater 6
, then the unit is assumed to be feet.
>>> va_familiar_ft = VisualAcuity('20/200')
>>> va_familiar_ft
VisualAcuity(numerator=20.0, denominator=200.0, unit='ft')
m()
property
Return snellen fraction in metres/meters.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Snellen Fraction in meters/metres. |
Examples:
Typical use:
>>> va = VisualAcuity('20/20')
>>> va.m
'6/6'
ft()
property
Return snellen fraction representation in feet.
Returns:
Type | Description |
---|---|
str
|
Snellen Fraction in feet. |
Examples:
Typical use:
>>> va = VisualAcuity('6/6')
>>> va.ft
'20/20'
snellen_fraction()
property
Return snellen fraction representation of visual acuity.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
snellen fraction. |
Examples:
Typical use:
>>> VisualAcuity("6 / 12").snellen_fraction
"6/6"
parse(va)
Parse a string into a visual acuity.
Note: if the test distance (numerator) is greater than 6, then the unit is assumed to be in feet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
va |
str
|
A visual acuity. |
required |
Examples:
Parsing a visual acuity:
>>> va = VisualAcuity().parse('6/120')
>>> str(va)
'6/120'
Parsing a visual acuity, automatically turning into a feet:
>>> va = VisualAcuity().parse('20/20')
>>> va.unit
'ft'
decimal()
property
Return decimal form of visual acuity.
Returns:
Name | Type | Description |
---|---|---|
Decimal |
Decimal
|
Decimal form of visual acuity. |
Examples:
Typical use:
>>> VisualAcuity("6/12").decimal
0.5
logmar()
property
Return logmar value of the visual acuity.
Returns:
Name | Type | Description |
---|---|---|
Decimal |
Decimal
|
Logmar value of the visual acuity. |
Examples:
Typical use:
>>> VisualAcuity("6/6").logmar
0.0