Skip to content

Commit

Permalink
Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
bencevans committed Mar 26, 2024
1 parent 0ad19ea commit cc99bda
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 32 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install ruff pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
- name: Lint with Ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
ruff check
- name: Test with pytest
run: |
pytest
2 changes: 1 addition & 1 deletion camtrapdp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .deployment import Deployment

__all__ = ["Deployment"]
__all__ = ["Deployment"]
126 changes: 101 additions & 25 deletions camtrapdp/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Camtrap Data Package
"""

# flake8: N815

from dataclasses import dataclass
from typing import Optional, List
from enum import Enum
Expand All @@ -12,67 +14,126 @@
@dataclass
class Deployment:
"""
A deployment is a period of time during which a camera trap is active at a specific location.
A deployment is a period of time during which a camera trap is active at a
specific location.
"""

deploymentID: str
"""Unique identifier of the deployment."""
"""
Unique identifier of the deployment.
"""

locationID: Optional[str]
"""Identifier of the deployment location."""
"""
Identifier of the deployment location.
"""

locationName: Optional[str]
"""Name given to the deployment location."""
"""
Name given to the deployment location.
"""

latitude: float
"""Latitude of the deployment location in decimal degrees, using the WGS84 datum."""
"""
Latitude of the deployment location in decimal degrees, using the WGS84
datum.
"""

longitude: float
"""Longitude of the deployment location in decimal degrees, using the WGS84 datum."""
"""
Longitude of the deployment location in decimal degrees, using the WGS84
datum.
"""

coordinateUncertainty: Optional[float]
"""Horizontal distance from the given latitude and longitude describing the smallest circle containing the deployment location. Expressed in meters. Especially relevant when coordinates are rounded to protect sensitive species."""
"""
Horizontal distance from the given latitude and longitude describing the
smallest circle containing the deployment location. Expressed in meters.
Especially relevant when coordinates are rounded to protect sensitive
species.
"""

deploymentStart: str
"""Date and time at which the deployment was started. Formatted as an ISO 8601 string with timezone designator (YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DDThh:mm:ss±hh:mm)."""
"""
Date and time at which the deployment was started. Formatted as an ISO
8601 string with timezone designator (YYYY-MM-DDThh:mm:ssZ or
YYYY-MM-DDThh:mm:ss±hh:mm).
"""
# TODO: Add datetime type

deploymentEnd: str
"""Date and time at which the deployment was ended. Formatted as an ISO 8601 string with timezone designator (YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DDThh:mm:ss±hh:mm)."""
"""
Date and time at which the deployment was ended. Formatted as an ISO 8601
string with timezone designator (YYYY-MM-DDThh:mm:ssZ or
YYYY-MM-DDThh:mm:ss±hh:mm).
"""
# TODO: Add datetime type

setupBy: Optional[str]
"""Name or identifier of the person or organization that deployed the camera."""
"""
Name or identifier of the person or organization that deployed the camera.
"""

cameraID: Optional[str]
"""Identifier of the camera used for the deployment (e.g. the camera device serial number)."""
"""
Identifier of the camera used for the deployment (e.g. the camera device
serial number).
"""

cameraModel: Optional[str]
"""Manufacturer and model of the camera. Formatted as `manufacturer-model`."""
"""
Manufacturer and model of the camera. Formatted as `manufacturer-model`.
"""

cameraDelay: Optional[int]
"""Predefined duration after detection when further activity is ignored. Expressed in seconds."""
"""
Predefined duration after detection when further activity is ignored.
Expressed in seconds.
"""

cameraHeight: Optional[float]
"""Height at which the camera was deployed. Expressed in meters. Not to be combined with cameraDepth."""
"""
Height at which the camera was deployed. Expressed in meters. Not to be
combined with cameraDepth.
"""

cameraDepth: Optional[float]
"""Depth at which the camera was deployed. Expressed in meters. Not to be combined with cameraHeight."""
"""
Depth at which the camera was deployed. Expressed in meters. Not to be
combined with cameraHeight.
"""

cameraTilt: Optional[int]
"""Angle at which the camera was deployed in the vertical plane. Expressed in degrees, with -90 facing down, 0 horizontal and 90 facing up."""
"""
Angle at which the camera was deployed in the vertical plane. Expressed in
degrees, with -90 facing down, 0 horizontal and 90 facing up.
"""

cameraHeading: Optional[int]
"""Angle at which the camera was deployed in the horizontal plane. Expressed in decimal degrees clockwise from north, with values ranging from 0 to 360: 0 = north, 90 = east, 180 = south, 270 = west."""
"""
Angle at which the camera was deployed in the horizontal plane. Expressed
in decimal degrees clockwise from north, with values ranging from 0 to 360:
0 = north, 90 = east, 180 = south, 270 = west.
"""

detectionDistance: Optional[float]
"""Maximum distance at which the camera can reliably detect activity. Expressed in meters. Typically measured by having a human move in front of the camera."""
"""
Maximum distance at which the camera can reliably detect activity.
Expressed in meters. Typically measured by having a human move in front of
the camera.
"""

timestampIssues: Optional[bool]
"""true if timestamps in the media resource for the deployment are known to have (unsolvable) issues (e.g. unknown timezone, am/pm switch)."""
"""
true if timestamps in the media resource for the deployment are known to
have (unsolvable) issues (e.g. unknown timezone, am/pm switch).
"""

baitUse: Optional[bool]
"""true if bait was used for the deployment. More information can be provided in tags or comments."""
"""
true if bait was used for the deployment. More information can be provided
in tags or comments.
"""

class FeatureType(str, Enum):
"""
Expand All @@ -94,19 +155,34 @@ class FeatureType(str, Enum):
FRUITING_TREE = "fruitingTree"

featureType: Optional[FeatureType]
"""Type of the feature (if any) associated with the deployment."""
"""
Type of the feature (if any) associated with the deployment.
"""

habitat: Optional[str]
"""Short characterization of the habitat at the deployment location."""
"""
Short characterization of the habitat at the deployment location.
"""

deploymentGroups: Optional[str]
"""Deployment group(s) associated with the deployment. Deployment groups can have a spatial (arrays, grids, clusters), temporal (sessions, seasons, months, years) or other context. Formatted as a pipe (|) separated list for multiple values, with values preferably formatted as key:value pairs."""
"""
Deployment group(s) associated with the deployment. Deployment groups can
have a spatial (arrays, grids, clusters), temporal (sessions, seasons,
months, years) or other context. Formatted as a pipe (|) separated list
for multiple values, with values preferably formatted as key:value pairs.
"""

deploymentTags: Optional[str]
"""Tag(s) associated with the deployment. Formatted as a pipe (|) separated list for multiple values, with values optionally formatted as key:value pairs."""
"""
Tag(s) associated with the deployment. Formatted as a pipe (|) separated
list for multiple values, with values optionally formatted as key:value
pairs.
"""

deploymentComments: Optional[str]
"""Comments or notes about the deployment."""
"""
Comments or notes about the deployment.
"""

@staticmethod
def from_csv(file_path: str) -> List["Deployment"]:
Expand Down

0 comments on commit cc99bda

Please sign in to comment.