Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/autoblack.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Ruff Lint and Format Check

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
args: "check"
src: "."
- uses: astral-sh/ruff-action@v3
with:
args: "format --check"
src: "."
20 changes: 3 additions & 17 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ on:
pull_request:
workflow_dispatch:
jobs:
lint_flake8:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Lint with flake8
run: |
pip install flake8
flake8 . --count --show-source --statistics --max-line-length=127 --ignore=E402,W503,E203

build:
runs-on: ubuntu-latest
permissions:
Expand All @@ -35,11 +21,11 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Search for severe code errors with flake8
- name: Search for severe code errors with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
pip install flake8
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --max-line-length=127
pip install ruff
ruff check . --select=E9,F63,F7,F82 --output-format=full
- name: provision-with-micromamba
uses: mamba-org/provision-with-micromamba@main
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
extensions = [
"sphinx.ext.autodoc", # for autodocs
"sphinx.ext.napoleon", # for numpy style documentation
"myst_parser" # for markdown support
"myst_parser", # for markdown support
# "sphinx.ext.viewcode",
# "sphinx.ext.imgmath",
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pandas as pd
import numpy as np
import pandas as pd


def get_known_actor_comms_status(values):
Expand Down
4 changes: 2 additions & 2 deletions examples/Learning_example/simple_neural_network.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import torch
import numpy as np
from torch.utils.data import Dataset, DataLoader
import torch
from sklearn.datasets import make_circles
from sklearn.model_selection import train_test_split
from torch.utils.data import DataLoader, Dataset


class SimpleNeuralNetwork(torch.nn.Module):
Expand Down
6 changes: 4 additions & 2 deletions examples/Learning_example/simple_node.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import asyncio

import numpy as np
import pykep as pk
import torch
import numpy as np
from simple_neural_network import SimpleNeuralNetwork

import paseos
from paseos import ActorBuilder, SpacecraftActor
from simple_neural_network import SimpleNeuralNetwork


class Node:
Expand Down
6 changes: 3 additions & 3 deletions examples/MPI_example/mpi_example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
""" This example showcases how you can run PASEOS on a high-performance computing infrastructure
"""This example showcases how you can run PASEOS on a high-performance computing infrastructure
using MPI (see also https://mpi4py.readthedocs.io/en/stable/tutorial.html).

Please run the example with mpiexec -n 4 python mpi_example.py

In the example, we model four satellites in low-Earth orbit that are only very infrequently in
line of sight of each other. For simplicity, the modelled task here will be to count the number of
window encounters for each satellite.
window encounters for each satellite.

N.B. There are some simplifications in this example. Running this on a compute cluster / supercomputer
you would want to minimize communications between ranks further. For clarity, we stay simple.
Expand Down Expand Up @@ -153,7 +153,7 @@ def constraint_func(verbose=SHOW_ALL_WINDOWS):
print()
print(f"########## Simulation completed ###########")
print(
f"Simulation ran {end-start:.2f}s to simulate {simulation_time:.2f}s. {simulation_time / (end-start):.2f}x real-time."
f"Simulation ran {end - start:.2f}s to simulate {simulation_time:.2f}s. {simulation_time / (end - start):.2f}x real-time."
)
sys.stdout.flush() # update prints to better see parallelism
comm.Barrier()
Expand Down
4 changes: 3 additions & 1 deletion examples/MPI_example/mpi_utility_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

Currently actors cannot be pickled, so we have a simple function to encode them.
"""
from paseos import ActorBuilder, SpacecraftActor

import pykep as pk

from paseos import ActorBuilder, SpacecraftActor

earth = pk.planet.jpl_lp("earth") # define our central body


Expand Down
19 changes: 8 additions & 11 deletions examples/Orekit_example/orekit_propagator.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from org.orekit.orbits import KeplerianOrbit, PositionAngle
from org.orekit.time import AbsoluteDate
from org.orekit.utils import Constants
from org.orekit.frames import FramesFactory
from org.orekit.orbits import OrbitType
from org.orekit.propagation.numerical import NumericalPropagator
from orekit import JArray_double
from org.hipparchus.ode.nonstiff import DormandPrince853Integrator
from org.orekit.propagation import SpacecraftState
from org.orekit.utils import IERSConventions
from org.orekit.forces.gravity.potential import GravityFieldFactory
from org.orekit.forces.gravity import HolmesFeatherstoneAttractionModel

from orekit import JArray_double
from org.orekit.forces.gravity.potential import GravityFieldFactory
from org.orekit.frames import FramesFactory
from org.orekit.orbits import KeplerianOrbit, OrbitType, PositionAngle
from org.orekit.propagation import SpacecraftState
from org.orekit.propagation.numerical import NumericalPropagator
from org.orekit.time import AbsoluteDate
from org.orekit.utils import Constants, IERSConventions


class OrekitPropagator:
Expand Down
2 changes: 1 addition & 1 deletion examples/Sentinel_2_example_notebook/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import scipy
import rasterio
import scipy
from skimage.measure import label, regionprops

# [1] Massimetti, Francesco, et al. ""Volcanic hot-spot detection using SENTINEL-2:
Expand Down
17 changes: 8 additions & 9 deletions paseos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from loguru import logger
from dotmap import DotMap
import pykep as pk
from dotmap import DotMap
from loguru import logger

from .utils.load_default_cfg import load_default_cfg
from .utils.check_cfg import check_cfg
from .paseos import PASEOS
from .actors.base_actor import BaseActor
from .actors.actor_builder import ActorBuilder
from .actors.base_actor import BaseActor
from .actors.ground_station_actor import GroundstationActor
from .actors.spacecraft_actor import SpacecraftActor
from .central_body.central_body import CentralBody
from .communication.get_communication_window import get_communication_window
from .communication.find_next_window import find_next_window
from .communication.get_communication_window import get_communication_window
from .paseos import PASEOS
from .power.power_device_type import PowerDeviceType
from .utils.check_cfg import check_cfg
from .utils.load_default_cfg import load_default_cfg
from .utils.reference_frame import ReferenceFrame
from .utils.set_log_level import set_log_level
from .visualization.plot import plot, PlotType

from .visualization.plot import PlotType, plot

set_log_level("WARNING")

Expand Down
29 changes: 14 additions & 15 deletions paseos/activities/activity_manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import types
import asyncio
import types

from loguru import logger
from dotmap import DotMap
from loguru import logger

from paseos.activities.activity_processor import ActivityProcessor
from paseos.activities.activity_runner import ActivityRunner
Expand All @@ -25,12 +25,12 @@ def __init__(
paseos_time_multiplier (float): Multiplier for the time. At 1, it is real time.
"""
logger.trace("Initializing ActivityManager")
assert (
paseos_update_interval > 1e-4
), f"Too small paseos update interval. Should not be less than 1e-4, was {paseos_update_interval}"
assert (
paseos_time_multiplier > 1e-4
), f"Too small paseos paseos_time_multiplier. Should not be less than 1e-4, was {paseos_time_multiplier}"
assert paseos_update_interval > 1e-4, (
f"Too small paseos update interval. Should not be less than 1e-4, was {paseos_update_interval}"
)
assert paseos_time_multiplier > 1e-4, (
f"Too small paseos paseos_time_multiplier. Should not be less than 1e-4, was {paseos_time_multiplier}"
)
self._activities = DotMap(_dynamic=False)
self._paseos_update_interval = paseos_update_interval
self._paseos_time_multiplier = paseos_time_multiplier
Expand Down Expand Up @@ -104,16 +104,15 @@ def perform_activity(
constraint_func_args (list, optional): Arguments for the constraint function. Defaults to None.
"""
# Check if activity exists and if it already had consumption specified
assert (
name in self._activities.keys()
), f"Activity not found. Declared activities are {self._activities.keys()}"
assert name in self._activities.keys(), (
f"Activity not found. Declared activities are {self._activities.keys()}"
)
activity = self._activities[name]
logger.debug(f"Performing activity {activity}")

assert (
activity.power_consumption_in_watt >= 0
), "Power consumption has to be positive but was specified as " + str(
activity.power_consumption_in_watt
assert activity.power_consumption_in_watt >= 0, (
"Power consumption has to be positive but was specified as "
+ str(activity.power_consumption_in_watt)
)

activity_runner = ActivityRunner(
Expand Down
7 changes: 3 additions & 4 deletions paseos/activities/activity_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ def __init__(
"""
logger.trace("Initalized ActivityProcessor.")
assert update_interval > 0, "Update update_interval has to be positive."
assert (
power_consumption_in_watt >= 0
), "Power consumption has to be positive but was specified as " + str(
power_consumption_in_watt
assert power_consumption_in_watt >= 0, (
"Power consumption has to be positive but was specified as "
+ str(power_consumption_in_watt)
)

self._power_consumption_in_watt = power_consumption_in_watt
Expand Down
2 changes: 1 addition & 1 deletion paseos/activities/activity_runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
from contextlib import suppress
import types
from contextlib import suppress

from loguru import logger

Expand Down
Loading
Loading