ascl_id
stringclasses
752 values
repo_url
stringclasses
737 values
file_path
stringlengths
4
194
content
large_stringlengths
1
1M
language
stringclasses
29 values
license_type
stringclasses
24 values
size
int64
1
1M
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/__main__.py
if __name__ == '__main__': print('You have installed the resonances package. Check please the documentation!')
Python
MIT
115
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/logger.py
import logging from pathlib import Path import resonances.config def static_init(cls): if getattr(cls, "static_init", None): cls.static_init() return cls @static_init class logger: # pragma: no cover @classmethod def static_init(cls): log_file_path = resonances.config.get('LOG_FILE'...
Python
MIT
1,397
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/body.py
import numpy as np from resonances.resonance import Resonance, MMR, SecularResonance from .logger import logger from typing import List, Union class Body: def __init__(self, type='particle'): self.type = type self.initial_data = None self.name = '' self.mass = 0.0 # Inte...
Python
MIT
6,406
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/matrix/matrix.py
import resonances import pandas as pd from pathlib import Path import os class Matrix: catalog_file = '' matrix = None planets = None @classmethod def dump(cls): if cls.matrix is None: cls.build() cls.matrix.to_csv(cls.catalog_full_filename()) @classmethod de...
Python
MIT
1,104
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/matrix/secular_resonances.py
""" Secular resonance definitions and helper functions. This module contains the comprehensive list of secular resonance formulas from the literature and helper functions for working with them. """ from typing import Dict from resonances.config import config # Complete list of secular resonance formulas from the li...
Python
MIT
5,365
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/matrix/secular_matrix.py
from typing import List, Optional, Union from resonances.matrix.secular_resonances import SECULAR_RESONANCES from resonances.resonance.factory import create_secular_resonance from resonances.resonance.secular import SecularResonance, GeneralSecularResonance class SecularMatrix: """ A class for building and ma...
Python
MIT
3,087
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/matrix/two_body_matrix.py
import numpy as np import pandas as pd import resonances from resonances.matrix.matrix import Matrix class TwoBodyMatrix(Matrix): catalog_file = 'MATRIX_2BODY_FILE' @classmethod def build(cls): primary_max = int(resonances.config.get('MATRIX_2BODY_PRIMARY_MAX')) m_max = int(resonances.co...
Python
MIT
1,966
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/matrix/three_body_matrix.py
from typing import List import numpy as np import pandas as pd import itertools import resonances from resonances.matrix.matrix import Matrix class ThreeBodyMatrix(Matrix): catalog_file = 'MATRIX_3BODY_FILE' @classmethod def build(cls): primary_max = int(resonances.config.get('MATRIX_3BODY_PRIM...
Python
MIT
2,386
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/simulation/__init__.py
from .config import SimulationConfig from .body_manager import BodyManager from .integration import IntegrationEngine from .data_manager import DataManager from .simulation import Simulation __all__ = ['SimulationConfig', 'BodyManager', 'IntegrationEngine', 'DataManager', 'Simulation']
Python
MIT
288
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/simulation/body_manager.py
from typing import List, Union import resonances import astdys import resonances.horizons from .config import SimulationConfig class BodyManager: """Manages addition and setup of celestial bodies.""" def __init__(self, config: SimulationConfig): self.config = config self.bodies: List[resonan...
Python
MIT
3,119
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/simulation/data_manager.py
import pandas as pd from pathlib import Path import resonances from .config import SimulationConfig class DataManager: """Manages data saving and export functionality.""" def __init__(self, config: SimulationConfig): self.config = config def should_save_body(self, body: resonances.Body, resonan...
Python
MIT
11,033
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/simulation/config.py
import datetime import numpy as np import resonances import astdys import resonances.data.util from resonances.config import config as c class SimulationConfig: """Handles simulation configuration and setup parameters.""" def __init__(self, **kwargs): """Initialize simulation configuration.""" ...
Python
MIT
4,758
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/simulation/simulation.py
import numpy as np from typing import List, Union import resonances from .config import SimulationConfig from .body_manager import BodyManager from .integration import IntegrationEngine from .data_manager import DataManager class Simulation: """ Main Simulation class with component-based architecture. T...
Python
MIT
2,405
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/simulation/integration.py
import os from pathlib import Path from typing import List import tqdm import rebound import resonances from resonances.config import config as c from .config import SimulationConfig class IntegrationEngine: """Handles the actual numerical integration logic.""" def __init__(self, config: SimulationConfig): ...
Python
MIT
3,694
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/libration.py
import numpy as np from scipy import signal from astropy.timeseries import LombScargle import resonances.config class libration: @classmethod def shift(cls, angle, distance=0): tmp = np.array(angle, copy=True) for i, elem in enumerate(tmp): if elem > np.pi: tmp[i] ...
Python
MIT
19,813
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/plot.py
import matplotlib.pyplot as plt import numpy as np import math from pathlib import Path import resonances.config import resonances def body(sim, body: resonances.Body, resonance, image_type='png'): # noqa: C901 plt.style.use('default') fig, axs = plt.subplots(7, 1, figsize=(10, 12)) resonance_key = re...
Python
MIT
7,021
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/two_body.py
import numpy as np import re from resonances.resonance.mmr import MMR from resonances.data import const import rebound class TwoBody(MMR): def __init__(self, coeff, planets_names=None): if isinstance(coeff, str): coeff, planets_names = self.init_from_short_notation(coeff) super().__in...
Python
MIT
2,386
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/secular.py
import rebound from resonances.resonance.resonance import Resonance class SecularResonance(Resonance): """ Base class for secular resonances. Secular resonances occur when the precession frequency of an asteroid's orbital elements (perihelion or node) matches the precession frequency of a planet'...
Python
MIT
14,901
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/factory.py
import re from typing import Union from resonances.resonance.mmr import MMR from resonances.resonance.resonance import Resonance from resonances.resonance.secular import Nu16Resonance, Nu5Resonance, Nu6Resonance, SecularResonance, GeneralSecularResonance from resonances.resonance.three_body import ThreeBody from reson...
Python
MIT
7,448
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/mmr.py
import numpy as np from resonances.resonance.resonance import Resonance class MMR(Resonance): def __init__(self, coeff, planets_names=None, index_of_planets=None): self.coeff = np.array(coeff) if self.coeff[0] <= 0: raise Exception("The primary coefficient of the resonance should be g...
Python
MIT
2,248
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/__init__.py
from .mmr import MMR from .secular import SecularResonance, GeneralSecularResonance, Nu6Resonance, Nu5Resonance, Nu16Resonance from .resonance import Resonance from .three_body import ThreeBody from .two_body import TwoBody from .factory import create_secular_resonance, detect_resonance_type, create_resonance
Python
MIT
311
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/three_body.py
import numpy as np import re from resonances.resonance.mmr import MMR import resonances.data.util as util from resonances.data import const import rebound class ThreeBody(MMR): def __init__(self, coeff, planets_names=None): if isinstance(coeff, str): coeff, planets_names = self.init_from_short...
Python
MIT
6,488
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/resonance/resonance.py
from abc import ABC, abstractmethod class Resonance(ABC): @property @abstractmethod def type(self) -> str: pass @abstractmethod def to_s(self): pass @abstractmethod def to_short(self): pass
Python
MIT
246
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/finder/__init__.py
# Universal finder interface from .finder import check, find, find_asteroids_in_mmr, find_mmrs # Direct access to specific finders from . import mmr_finder from . import secular_finder __all__ = ['check', 'find', 'find_asteroids_in_mmr', 'find_mmrs', 'mmr_finder', 'secular_finder']
Python
MIT
285
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/finder/mmr_finder.py
import resonances import astdys from typing import Union, List from datetime import datetime from resonances.data.util import convert_input_to_list import resonances.horizons def find( asteroids: Union[int, str, List[Union[int, str]]], planets=None, name: str = None, sigma2: float = 0.1, sigma3: ...
Python
MIT
4,998
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/finder/secular_finder.py
import resonances import numpy as np from typing import Union, List from resonances.data.util import convert_input_to_list from resonances.matrix.secular_matrix import SecularMatrix def check( asteroids: Union[int, str, List[Union[int, str]]], resonance: str | list[str] | resonances.SecularResonance | list[r...
Python
MIT
5,307
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/finder/finder.py
import resonances from typing import Union, List from resonances.data.util import convert_input_to_list from . import mmr_finder, secular_finder def _categorize_resonances(resonance_list): """Helper function to categorize resonances by type.""" mmr_resonances = [] secular_resonances = [] for res in ...
Python
MIT
8,218
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/data/util.py
from typing import Union, List from resonances.data import const import datetime def convert_input_to_list(asteroids: Union[int, str, List[Union[int, str]]]) -> List[str]: if isinstance(asteroids, str) or isinstance(asteroids, int): asteroids = [asteroids] elif asteroids is None: asteroids = [...
Python
MIT
1,960
[ascl:2409.009]
https://github.com/smirik/resonances
resonances/data/const.py
import rebound # PLANETS_LONGITUDE = { # "Mercury": 0.0, # "Venus": 7.452, # "Earth": 17.368, # "Mars": 17.916, # "Jupiter": 4.257, # "Saturn": 28.243, # "Uranus": 0.0, # "Neptune": 0.0, # } PLANETS_AXIS = { "Mercury": 0.38709843, "Venus": 0.72332102, "Earth": 1.00000018, ...
Python
MIT
1,120
[ascl:2409.009]
https://github.com/smirik/resonances
.github/workflows/ci.yml
name: Resonances App on: push: branches: [main] pull_request: branches: [main] jobs: build: strategy: fail-fast: false matrix: python-version: [3.11.1] poetry-version: [1.3.2] runs-on: ubuntu-latest steps: ...
YAML
MIT
1,254
[ascl:2409.009]
https://github.com/smirik/resonances
.github/ISSUE_TEMPLATE/feature_request.md
--- name: Feature request about: Suggest an idea for this project title: '' labels: '' assignees: '' --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and con...
Markdown
MIT
595
[ascl:2409.009]
https://github.com/smirik/resonances
.github/ISSUE_TEMPLATE/bug_report.md
--- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behaviour: 1. Go to '...' 2. Write the code '....' 3. Scroll down to '....' 4. See an error **Expecte...
Markdown
MIT
676
[ascl:2409.009]
https://github.com/smirik/resonances
docs/about.md
# About ## License This package is available under MIT License. The text of the license is available on [GitHub](https://github.com/smirik/resonances/blob/main/LICENSE). ## Authors The authors of the package: - [Evgeny Smirnov](https://github.com/smirik) ([FB](https://facebook.com/smirik), [Telegram](https://t.m...
Markdown
MIT
1,358
[ascl:2409.009]
https://github.com/smirik/resonances
docs/index.md
# Mean-Motion Resonances on steroids `resonances` is an open-source package dedicated to the identification of mean-motion and secularresonances of small bodies. Many examples are for the Solar system; however, you might use the package for any possible planetary system, including exoplanets. For now, the package supp...
Markdown
MIT
6,781
[ascl:2409.009]
https://github.com/smirik/resonances
docs/secular.md
# Secular Resonances This guide shows how to work with secular resonances in the resonances library. Examples assume familiarity with secular resonance theory and asteroid dynamics. ## Quick Start ### Creating Individual Secular Resonances ```python import resonances # Create specific secular resonances nu6 = reso...
Markdown
MIT
3,662
[ascl:2409.009]
https://github.com/smirik/resonances
docs/matrix.md
# Resonance Matrices The Resonance Matrices allows us to find the preliminary (theoretical) value of a resonant semi-major axis for the resonance. While for a two-body mean motion resonance the calculation follows obviously from the Third Kepler Law, it is not so straightforward for three-body mean motion resonances. ...
Markdown
MIT
4,124
[ascl:2409.009]
https://github.com/smirik/resonances
docs/libration.md
# Libration There is no obvious algorithm how to identify whether or not the asteroid is in the resonance. While there are simple cases (such as 463 Lola in `4J-2S-1`, see [Example](quick-start.ipynb)), there are many asteroids whose resonant angles are librating but not the whole time. Moreover, it might be the case ...
Markdown
MIT
7,626
[ascl:2409.009]
https://github.com/smirik/resonances
docs/quick-start.ipynb
{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Quick Start\n", "\n", "The easiest way to start is to use a Jupyter notebook and review the results as you get them.\n", "\n", "Let us start with a very first example:\n", "\n", "1. Creat...
Jupyter Notebook
MIT
428,874
[ascl:2409.009]
https://github.com/smirik/resonances
docs/install.md
# Installation The fastest way: ```bash pip install resonances ``` ## Poetry The _best_ way to install `resonances` package is through [poetry](https://python-poetry.org), which is the dependency manager for python. In this case, you only need to write: ```bash poetry add resonances ``` It will install the packag...
Markdown
MIT
3,929
[ascl:2409.009]
https://github.com/smirik/resonances
docs/examples.ipynb
{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Examples \n", "\n", "Below are some examples of how the package could be used in astronomical studies. While there are more use cases, the most common are outlined below." ] }, { "cell_type": "...
Jupyter Notebook
MIT
245,045
[ascl:2409.009]
https://github.com/smirik/resonances
docs/config.md
# Config All default config values are stored in a file called .env.dist in the source code. It is not recommended to change anything in that file directly. If you need to change a specific config value, you can do it in the following way: If you need to change a specific config value, you have several options: 1. ...
Markdown
MIT
10,263
[ascl:2409.009]
https://github.com/smirik/resonances
docs/dev.md
# Development Documentation ## To release a new version 1. Set a new version in `pyproject.toml`. 2. Set the production token: ```bash poetry config pypi-token.pypi TOKEN ``` 3. Run tests ```bash make test ``` 4. Publish ```bash make publish ``` 5. Update docs if necessary ...
Markdown
MIT
477
[ascl:2409.009]
https://github.com/smirik/resonances
docs/core.ipynb
{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The core objects you deal with in resonances are `Simulation`, `Body`, `MMR` (either `ThreeBody` or `TwoBody`), and `SecularResonance` (`GeneralSecularResonance`, `Nu6Resonance`, `Nu5Resonance`, `Nu16Resonance`). ...
Jupyter Notebook
MIT
53,831
[ascl:2409.009]
https://github.com/smirik/resonances
tests/test_backward.py
import pytest import resonances from tests import tools @pytest.fixture(autouse=True) def setup_test_config(): """Setup test configuration before each test and restore after.""" original_save_path = resonances.config.get('SAVE_PATH') original_plot_path = resonances.config.get('PLOT_PATH') resonances....
Python
MIT
1,580
[ascl:2409.009]
https://github.com/smirik/resonances
tests/tools.py
import datetime import astdys.util import pytest import resonances import astdys # 463 Lola def get_3body_elements_sample(): return { "a": 2.398473292330785, "e": 0.22009324739445424, "inc": 0.23634522279656767, "Omega": 0.63690730765078, "omega": 5.753528892504344, ...
Python
MIT
3,011
[ascl:2409.009]
https://github.com/smirik/resonances
tests/test_real_mmrs.py
import resonances import astdys from resonances.matrix.three_body_matrix import ThreeBodyMatrix from .tools import set_fast_integrator, reset_fast_integrator def test_find(): set_fast_integrator() sim = resonances.find(463, ['Jupiter', 'Saturn']) sim.run() summary = sim.data_manager.get_simulation_s...
Python
MIT
2,182
[ascl:2409.009]
https://github.com/smirik/resonances
tests/test_nasa.py
import pytest import resonances import resonances.horizons import tests.tools as tools from astroquery.jplhorizons import Horizons from astropy.table import Table def test_astroquery(): obj = Horizons(id='Hektor', location='500@10', epochs=2458133.33546) elems = obj.elements() assert isinstance(elems, Tab...
Python
MIT
1,104
[ascl:2409.009]
https://github.com/smirik/resonances
tests/test_finder.py
import resonances from .tools import set_fast_integrator, reset_fast_integrator def test_find(): asteroids = [463, 490] planets = ['Jupiter', 'Saturn'] set_fast_integrator() sim = resonances.find(asteroids, planets) sim.config.tmax = 200000 # enough for 463 and 490 assert isinstance(sim, r...
Python
MIT
1,264
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/__init__.py
""" Tests for Resonances Package ============================ This package contains tests for the resonances package components. """
Python
MIT
134
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/test_config.py
import resonances import pytest def test_get_and_has(): assert resonances.config.has('SAVE_PATH') is True assert 'cache' == resonances.config.get('SAVE_PATH') assert resonances.config.has('PLOT_PATH') is True assert 'cache' == resonances.config.get('PLOT_PATH') assert resonances.config.has('SAVE...
Python
MIT
3,026
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/test_body.py
import resonances import numpy as np def test_checkers(): body = resonances.Body() mmr = resonances.create_mmr('4J-2S-1') body.mmrs = [mmr] body.statuses[mmr.to_s()] = 2 assert body.status(mmr) == 2 assert body.in_resonance(mmr) is True assert body.in_pure_resonance(mmr) is True body...
Python
MIT
3,399
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/data/test_util.py
import pytest import resonances import datetime from resonances.data.util import convert_input_to_list, datetime_from_string def test_convert_input_to_list(): asteroids = 1 expected_output = [1] assert convert_input_to_list(asteroids) == expected_output asteroids = '2' expected_output = ['2'] ...
Python
MIT
2,116
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/plot/__init__.py
""" Tests for the plot module. """
Python
MIT
35
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/plot/test_plot_round.py
from resonances.resonance.plot import round_to_nice_value class TestRoundToNiceValue: """Test suite for the round_to_nice_value function.""" def test_round_to_nice_value_basic_cases(self): """Test round_to_nice_value with the provided test cases.""" assert round_to_nice_value(20000) == 20000 ...
Python
MIT
1,952
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/secular/__init__.py
# Secular resonance tests BASIC_CONFIG = { 'plot': 'all', 'save': 'all', 'integration_years': 200000, 'oscillations_cutoff': 0.0005, 'libration_period_min': 10000, 'libration_period_critical': 200000 * 0.2, 'dt': 1.0, 'integrator': 'whfast', }
Python
MIT
276
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/secular/test_secular_finder_check.py
import resonances.finder.secular_finder import numpy as np class TestSecularFinderCheck: """Test the secular_finder.check function parameter propagation.""" def test_check_function_kwargs_propagation(self): """Test that old parameters passed via kwargs are correctly set up in simulation object.""" ...
Python
MIT
5,111
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/secular/test_secular_calculations.py
#!/usr/bin/env python3 """ Simple test to verify secular resonance coefficient parsing and angle calculations for g-g6+s-s6 and 2g-2g6+s-s6 cases. """ import math from resonances.resonance.secular import GeneralSecularResonance class SimpleBody: """Simple body class with orbital elements.""" def __init__(se...
Python
MIT
4,318
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/secular/test_secular_finder_find.py
import resonances.finder.secular_finder import resonances import numpy as np import pytest from resonances.matrix.secular_matrix import SecularMatrix from tests.resonances.secular import BASIC_CONFIG @pytest.fixture(autouse=True) def setup_test_config(): """Setup test configuration before each test and restore a...
Python
MIT
7,250
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/secular/test_secular_check.py
from resonances.resonance.secular import GeneralSecularResonance import resonances.finder.secular_finder import resonances import numpy as np import pytest from tests.resonances.secular import BASIC_CONFIG @pytest.fixture(autouse=True) def setup_test_config(): """Setup test configuration before each test and res...
Python
MIT
4,929
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/matrix/test_secular_matrix.py
import pytest from resonances.matrix.secular_matrix import SecularMatrix from resonances.matrix.secular_resonances import SECULAR_RESONANCES, get_available_secular_resonance_formulas, get_available_orders from resonances.resonance.secular import SecularResonance, Nu5Resonance, Nu6Resonance, Nu16Resonance, GeneralSecula...
Python
MIT
8,686
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/matrix/test_two_body_matrix.py
import pytest import pandas as pd from pathlib import Path import shutil import resonances from resonances.matrix.two_body_matrix import TwoBodyMatrix @pytest.fixture(autouse=True) def run_around_tests(): resonances.config.set(TwoBodyMatrix.catalog_file, 'cache/tests/mmr-2body-test.csv') Path('cache/tests')....
Python
MIT
2,727
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/matrix/test_three_body_matrix.py
import pytest import pandas as pd from pathlib import Path import shutil import resonances from resonances.matrix.three_body_matrix import ThreeBodyMatrix @pytest.fixture(autouse=True) def run_around_tests(): resonances.config.set(ThreeBodyMatrix.catalog_file, 'cache/tests/mmr-3body-test.csv') Path('cache/te...
Python
MIT
3,210
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/matrix/test_factory_integration.py
import pytest from resonances.resonance.factory import create_secular_resonance from resonances.resonance.secular import Nu5Resonance, Nu6Resonance, Nu16Resonance, GeneralSecularResonance class TestFactoryIntegration: """Test that the factory method works with the new secular matrix functionality.""" def tes...
Python
MIT
2,362
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_factory.py
import pytest from resonances.resonance.three_body import ThreeBody from resonances.resonance.two_body import TwoBody from resonances.resonance.mmr import MMR from resonances.resonance.secular import Nu6Resonance, Nu5Resonance, Nu16Resonance, GeneralSecularResonance from resonances.resonance.factory import create_mmr,...
Python
MIT
7,865
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_plot.py
from pathlib import Path import resonances import os import tests.tools as tools def test_simple_run(): sim = tools.create_test_simulation_for_solar_system() sim.add_body(tools.get_3body_elements_sample(), resonances.ThreeBody('4J-2S-1')) sim.add_body(tools.get_2body_elements_sample(), resonances.TwoBody(...
Python
MIT
1,315
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_mmr.py
import resonances import pytest def test_get_letter_from_planet_name(): mmr = resonances.TwoBody([2, -1, 0, -1]) assert 'E' == mmr.get_letter_from_planet_name('Earth') assert 'J' == mmr.get_letter_from_planet_name('Jupiter') assert 'R' == mmr.get_letter_from_planet_name('Mercury') assert 'M' == mm...
Python
MIT
2,096
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_circulation.py
import resonances def test_find_breaks(): x = [1, 2, 3] y = [1, 2, 5] breaks = resonances.libration.find_breaks(x, y) assert 0 == len(breaks[0]) # no breaks breaks = resonances.libration.find_breaks(x, y, break_value=2) assert 1 == len(breaks[0]) assert 3 == breaks[0][0] # break at x=3...
Python
MIT
4,690
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_three_body.py
import resonances import pytest def test_order(): mmr = resonances.ThreeBody('4J-2S-1') assert 1 == mmr.order() mmr = resonances.ThreeBody('3J-2S-1') assert 0 == mmr.order() mmr = resonances.ThreeBody('6J-1S-1') assert 4 == mmr.order() def test_full_create(): mmr = resonances.ThreeBody...
Python
MIT
4,874
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_filtering.py
import resonances import numpy as np import pytest def test_periodogram(): t = np.linspace(0, 10, 101) y = np.sin(np.pi * t) (frequency, power) = resonances.libration.periodogram(t, y, minimum_frequency=0.0, maximum_frequency=2.0) key = 0 for i, elem in enumerate(frequency): if elem == 0....
Python
MIT
1,829
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_two_body.py
import resonances import pytest def test_order(): mmr = resonances.TwoBody('4J-1') assert 3 == mmr.order() mmr = resonances.TwoBody('1J-1') assert 0 == mmr.order() mmr = resonances.TwoBody('1J+1') assert 2 == mmr.order() def test_full_create(): mmr = resonances.TwoBody([2, -1, 0, -1]) ...
Python
MIT
3,807
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/resonance/test_libration.py
import numpy as np import pytest import resonances def test_pure(): arr = [1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1] assert resonances.libration.pure(arr) is True arr = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6] assert resonances.libration.pure(arr) is False arr = [6, 0, 1, 0, 6, 5, 6, 0, 1, 2] assert r...
Python
MIT
4,152
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/__init__.py
""" Tests for Simulation Components ============================== This package contains tests for the refactored simulation architecture. """
Python
MIT
144
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_body_manager.py
#!/usr/bin/env python3 """ Tests for BodyManager Component ============================== This module tests the BodyManager class. """ import pytest from unittest.mock import Mock, patch from resonances.simulation import BodyManager, SimulationConfig class TestBodyManager: """Test the BodyManager component."""...
Python
MIT
4,016
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_config.py
#!/usr/bin/env python3 """ Tests for SimulationConfig Component =================================== This module tests the SimulationConfig class. """ import pytest import numpy as np from resonances.simulation import SimulationConfig class TestSimulationConfig: """Test the SimulationConfig component.""" d...
Python
MIT
1,976
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_config_propagation.py
#!/usr/bin/env python3 """ Tests for Configuration Parameter Propagation ============================================= This module tests that configuration parameters passed to Simulation are correctly propagated through the system components and actually used during integration. Tests cover: 1. Direct verification o...
Python
MIT
11,315
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_integration.py
#!/usr/bin/env python3 """ Tests for IntegrationEngine Component ==================================== This module tests the IntegrationEngine class. """ import pytest from unittest.mock import Mock, patch from resonances.simulation import SimulationConfig, IntegrationEngine class TestIntegrationEngine: """Test...
Python
MIT
2,965
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_simulation.py
#!/usr/bin/env python3 import datetime # noqa: F401 - used in patches import astdys # noqa: F401 - used in patches import rebound # noqa: F401 - used in patches import tests.tools as tools import shutil # noqa: F401 - used in fixtures from pathlib import Path import pytest from unittest.mock import Mock, patch imp...
Python
MIT
8,712
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_config_core_validation.py
#!/usr/bin/env python3 """ Core Configuration Validation Tests =================================== Focused tests to verify the core issue: whether configuration parameters passed to Simulation constructor are actually used by the integration engine. This addresses the specific concern about configuration parameter pr...
Python
MIT
9,147
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_simulation_integration.py
#!/usr/bin/env python3 """ Tests for Simulation Integration =============================== This module tests the integration between simulation components. """ import pytest from unittest.mock import Mock, patch from resonances.simulation import SimulationConfig, BodyManager, IntegrationEngine, DataManager @pytes...
Python
MIT
2,723
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_runtime_config_validation.py
#!/usr/bin/env python3 """ Runtime Configuration Validation Tests ====================================== This module performs deeper integration tests to verify that configuration parameters are actually applied and used during simulation runtime. These tests focus on: 1. Actual REBOUND integrator configuration 2. Ru...
Python
MIT
7,980
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/simulation/test_data_manager.py
#!/usr/bin/env python3 """ Tests for DataManager Component ============================== This module tests the DataManager class. """ import pytest from unittest.mock import Mock, patch from resonances.simulation import SimulationConfig, DataManager class TestDataManager: """Test the DataManager component."""...
Python
MIT
4,202
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/mmr/__init__.py
# MMR Tests
Python
MIT
12
[ascl:2409.009]
https://github.com/smirik/resonances
tests/resonances/mmr/test_finder_check.py
import resonances.finder.mmr_finder class TestFinderCheck: """Test the finder.check function parameter propagation.""" def test_check_function_kwargs_propagation(self): """Test that parameters passed via kwargs are correctly set up in simulation object.""" # Define parameters that should be ...
Python
MIT
5,144
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
LICENSE.md
The ReverseDiff.jl package is licensed under the MIT "Expat" License: > Copyright (c) 2016: Jarrett Revels, John Pearson > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal > in the Software without restriction...
Markdown
MIT
1,181
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
Project.toml
name = "ReverseDiff" uuid = "37e2e3b7-166d-5795-8a7a-e32c996b4267" version = "1.16.2" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" FunctionWrapp...
TOML
MIT
1,482
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
README.md
# ReverseDiff [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/ReverseDiff.jl/stable) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliadiff.org/ReverseDiff.jl/dev) [![Build status](https://github.com/JuliaDiff/ReverseDiff.jl/workflows/CI/badge.svg)](https://gith...
Markdown
MIT
5,057
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
benchmark/benchmark.jl
using ReverseDiff #################################################################### function grad_benchmark_driver!(out, f, x) println("benchmarking ∇$(f)...") cfg = ReverseDiff.GradientConfig(x) tp = ReverseDiff.GradientTape(f, x) # warmup ReverseDiff.gradient!(out, f, x, cfg) ReverseDif...
Julia
MIT
3,595
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
docs/Project.toml
[deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" [compat] Documenter = "1"
TOML
MIT
85
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
docs/make.jl
using Documenter, ReverseDiff makedocs(; modules=[ReverseDiff], sitename="ReverseDiff.jl", format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true", ), pages=[ "Home" => "index.md", "Limitation of ReverseDiff" => "limits.md", "API" => "api.md", ], ...
Julia
MIT
431
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
docs/src/api.md
# ReverseDiff API ```@meta CurrentModule = ReverseDiff ``` ## Gradients of `f(x::AbstractArray{<:Real}...)::Real` ```@docs ReverseDiff.gradient ReverseDiff.gradient! ``` ## Jacobians of `f(x::AbstractArray{<:Real}...)::AbstractArray{<:Real}` ```@docs ReverseDiff.jacobian ReverseDiff.jacobian! ``` ## Hessians of `...
Markdown
MIT
2,512
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
docs/src/limits.md
# Limitations of ReverseDiff ReverseDiff works by injecting user code with new number types that record all operations that occur on them, accumulating an execution trace of the target function which can be re-run forwards and backwards to propagate new input values and derivative information. Naturally, this techniqu...
Markdown
MIT
2,155
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
docs/src/index.md
# ReverseDiff.jl This documentation provides a specification of ReverseDiff's API, tips for usage, and details about the package's implementation. For a basic introduction to ReverseDiff, see [the package's README](https://github.com/JuliaDiff/ReverseDiff.jl). For usage examples, see [the examples directory](https:/...
Markdown
MIT
380
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
.github/dependabot.yml
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: "github-actions" directory: "/" # Location of package manifests schedule: interval: "monthly"
YAML
MIT
256
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
.github/workflows/TagBot.yml
name: TagBot on: issue_comment: types: - created workflow_dispatch: inputs: lookback: default: "3" permissions: actions: read checks: read contents: write deployments: read issues: read discussions: read packages: read pages: read pull-requests: read repository-projec...
YAML
MIT
650
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
.github/workflows/CompatHelper.yml
name: CompatHelper on: schedule: - cron: 0 0 * * * workflow_dispatch: permissions: contents: write pull-requests: write jobs: CompatHelper: runs-on: ubuntu-latest steps: - name: Check if Julia is already available in the PATH id: julia_in_path run: which julia continu...
YAML
MIT
1,282
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
.github/workflows/DocsPreviewCleanup.yml
name: Docs Preview Cleanup on: pull_request: types: [closed] # Ensure that only one "Doc Preview Cleanup" workflow is force pushing at a time concurrency: group: doc-preview-cleanup cancel-in-progress: false jobs: doc-preview-cleanup: runs-on: ubuntu-latest permissions: contents: write ...
YAML
MIT
995
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
.github/workflows/ci.yml
name: CI on: pull_request: branches: - master push: branches: - master tags: '*' concurrency: # Skip intermediate builds: always. # Cancel intermediate builds: only if it is a pull request build. group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ startsWith(git...
YAML
MIT
2,153
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
examples/jacobian.jl
using ReverseDiff: JacobianTape, JacobianConfig, jacobian, jacobian!, compile using LinearAlgebra: mul! ######### # setup # ######### # some objective functions to work with f(a, b) = (a + b) * (a * b)' g!(out, a, b) = mul!(out, a + b, a * b) # pre-record JacobianTapes for `f` and `g` using inputs of shape 10x10 wit...
Julia
MIT
2,005
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
examples/gradient.jl
using ReverseDiff: GradientTape, GradientConfig, gradient, gradient!, compile, DiffResults ######### # setup # ######### # some objective function to work with f(a, b) = sum(a' * b + a * b') # pre-record a GradientTape for `f` using inputs of shape 100x100 with Float64 elements const f_tape = GradientTape(f, (rand(1...
Julia
MIT
1,954
[ascl:2411.010]
https://github.com/JuliaDiff/ReverseDiff.jl
src/ReverseDiff.jl
module ReverseDiff using Base: RefValue using Random using LinearAlgebra using Statistics using FunctionWrappers: FunctionWrapper using DiffResults using DiffResults: DiffResult using DiffRules, SpecialFunctions, NaNMath using ForwardDiff using ForwardDiff: Dual, Partials using StaticArrays using LogExpFunctions: ...
Julia
MIT
1,971