Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Sampling Potentials Architecture #17

Merged
merged 50 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
44026cd
sampling galpy utilities
nstarman Nov 20, 2020
047828d
update UnitType to also FunctionUnitBase
nstarman Dec 25, 2020
ca59c82
move stuff around
nstarman Dec 25, 2020
df42511
small fixes
nstarman Dec 25, 2020
d772194
changelog
nstarman Dec 25, 2020
6d591b4
fixes from rename
nstarman Dec 25, 2020
412438d
isolate 3rd party package
nstarman Dec 25, 2020
61745ee
meeting Jan 8, 2021
nstarman Jan 8, 2021
05bd8ab
style fixes
nstarman Jan 8, 2021
b3374cd
start tests
nstarman Jan 9, 2021
082997e
style
nstarman Jan 9, 2021
1290113
test collection
nstarman Jan 10, 2021
854c3e2
notebook label
nstarman Jan 10, 2021
6a71cc4
need to pin to beta for metadata reasons
nstarman Jan 10, 2021
2643d23
try again
nstarman Jan 10, 2021
5384efb
backtrack
nstarman Jan 10, 2021
f81858a
to 1.0b
nstarman Jan 10, 2021
691299c
try to get old pip resolver
nstarman Jan 10, 2021
a4c0ef1
limit pip?
nstarman Jan 10, 2021
8ecd9f5
can’t test agama until sort this out
nstarman Jan 10, 2021
e759d9b
change extern to plugin
nstarman Jan 10, 2021
01730e7
ignore glob
nstarman Jan 10, 2021
b2ff792
further protect plugins from pytest
nstarman Jan 10, 2021
7619efc
collect ignore
nstarman Jan 10, 2021
ca28c00
more tests and add agama
nstarman Jan 10, 2021
4fd51c8
skip agama again, until fix
nstarman Jan 10, 2021
5e84474
plugin tests
nstarman Jan 10, 2021
3393bd9
style
nstarman Jan 10, 2021
d7c7daf
non-kw
nstarman Jan 10, 2021
851dc7d
kwargs to absorb
nstarman Jan 10, 2021
6cb79a7
style
nstarman Jan 10, 2021
acf779a
more codecov
nstarman Jan 10, 2021
49d7b68
fix tests
nstarman Jan 14, 2021
59bcc80
test sample
nstarman Jan 14, 2021
70e8c7d
galpy branch
nstarman Jan 14, 2021
368adbc
force units
nstarman Jan 14, 2021
47d178c
flake8
nstarman Jan 14, 2021
3d58661
try again
nstarman Jan 14, 2021
cbfcf2c
add mailmap
nstarman Jan 15, 2021
007bcbe
pre-commit hooks
nstarman Jan 15, 2021
ecfdd47
cleanup
nstarman Jan 15, 2021
2a264a0
fix mailmap
nstarman Jan 15, 2021
291033e
see error
nstarman Jan 15, 2021
fefaba3
ignore test for now
nstarman Jan 15, 2021
3438706
don’t need to do all deps in windows
nstarman Jan 15, 2021
215aaf3
black
nstarman Jan 15, 2021
12c9712
coverage
nstarman Jan 15, 2021
a7b452a
pre-commit
nstarman Jan 15, 2021
498c373
closer clean
nstarman Jan 15, 2021
7e6d18f
merge sample and resample
nstarman Jan 15, 2021
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
17 changes: 8 additions & 9 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ name: CI

on:
push:
# only build on select branches
branches:
tags:
branches: # only build on select branches
- main
- master # TODO delete when transition
- release/*

pull_request:
# only build on PRs against main
branches:
branches: # only build on PRs against main
- main
- master # TODO delete when transition

Expand Down Expand Up @@ -56,13 +55,12 @@ jobs:
python: 3.8
toxenv: py38-test-cov

# Done with pre-commit
# - name: code style
# - name: code style. # Done with pre-commit
# os: ubuntu-latest
# python: 3.x
# toxenv: codestyle

# - name: Documentation Build # Done with RTD
# - name: Documentation Build # Done with RTD on public repos.
# os: ubuntu-latest
# python: 3.x
# toxenv: build_docs
Expand Down Expand Up @@ -147,10 +145,10 @@ jobs:
python: 3.8
toxenv: py38-test-alldeps

- name: py3.8 - all deps (Windows)
- name: py3.8 - min deps (Windows)
os: windows-latest
python: 3.8
toxenv: py38-test-alldeps
toxenv: py38-test

steps:
- name: Checkout code
Expand All @@ -177,6 +175,7 @@ jobs:

# ---------------------------------------------
# Many Versions
# Comment out for private repos

versions:
needs: further
Expand Down
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
###############################################################################
# Project-Specific

# Big Data Files
/discO/data/sim_CC_100

# scratch folder
scratch/
notes/

# _old
**/_old


# scripts
scripts/**/output

Expand Down Expand Up @@ -77,6 +80,7 @@ sdist
develop-eggs
.installed.cfg
distribute-*.tar.gz
*.dev*

# Other
.cache
Expand Down Expand Up @@ -109,9 +113,3 @@ pip-wheel-metadata/
*.sublime-project
/sftp-config-alt.json
/sftp-config.json

# R stuff
.Rproj.use
/.Rproj.user
/.Rhistory
/.RData
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Nathaniel Starkman <nstarman@users.noreply.github.com> Nathaniel Starkman <nstarkman@protonmail.com>
Nathaniel Starkman <nstarman@users.noreply.github.com> Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Nathaniel Starkman <nstarman@users.noreply.github.com> nstarman <nstarman@users.noreply.github.com>
91 changes: 78 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -9,11 +9,64 @@ repos:
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.0.2
hooks:
- id: add-trailing-comma

- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: master
hooks:
- id: check-mailmap
- id: forbid-binary
- id: script-must-have-extension
- id: script-must-not-have-extension
- id: shellcheck
- id: shfmt

- repo: https://github.com/mgedmin/check-manifest
rev: master
hooks:
- id: check-manifest

- repo: https://github.com/pre-commit/mirrors-autopep8
rev: master
hooks:
- id: autopep8

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort
additional_dependencies: ["toml"]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
args: # arguments to configure flake8
# making isort line length compatible with black
Expand All @@ -26,17 +79,29 @@ repos:
# https://flake8.pycqa.org/en/latest/user/error-codes.html
- "--ignore=F405,W503"
- "--exclude=*/_astropy_init.py docs/conf.py"
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
additional_dependencies: ["toml"]

- repo: https://github.com/psf/black
rev: stable
rev: 20.8b1
hooks:
- id: black
additional_dependencies: ["toml"]
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.1
hooks:
- id: black
additional_dependencies: ["toml"]
- id: blacken-docs
additional_dependencies: [black==20.8b1]
- repo: https://github.com/nbQA-dev/nbQA
rev: 0.5.6
hooks:
- id: nbqa-black
additional_dependencies: [black==20.8b1]
args: [--nbqa-mutate]
- id: nbqa-flake8
additional_dependencies: [flake8==3.8.4]
args: [--nbqa-mutate]
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==2.7.3]
args: [--nbqa-mutate, --py36-plus]
- id: nbqa-isort
additional_dependencies: [isort==5.6.4]
args: [--nbqa-mutate]
129 changes: 126 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,119 @@ Adopt Project-template from @nstarman
New Features
------------

discO.common
^^^^^^^^^^^^

Code that can be used all over the package. It's not core, it's common.

- Add types for type hinting: [#17]

+ EllipsisType : ``type(Ellipsis)`` b/c ellipsis fails.
+ UnitType : the type of astropy's ``UnitBase`` and ``FunctionUnitBasse``
+ QuantityType : the type of astropy's ``Quantity``
+ FrameType : the type of astropy's ``BaseCoordinateFrame``
+ SkyCoordType : the type of astropy's ``SkyCoord``
+ CoordinateType : the union of FrameType & SkyCoordType
+ FrameLikeType : the union of CoordinateType & str

* anything that can be used in ``frame=`` in ``Skycoord(...,frame=)``


discO.config
^^^^^^^^^^^^

- Add configuration for default frame. Defaults to "icrs". [#17]


discO.core
^^^^^^^^^^

Where the unified architecture is defined.

Modules:

- ``core`` : the base class. [#17]
- ``sample`` : for sampling from a Potential. [#17]
- ``measurement`` : for resampling, given observational errors. [#17]


**discO.core.core**

The base class samplers, fitters, and most everything else.
If a ``package`` is defined as a class argument, it parses the package and
stores it in the class. This is used for registering classes into registry
classes.

subclasses must override the ``_registry`` and ``__call__`` methods.


**discO.core.sample**

PotentialSampler : base class for sampling potentials [#17]

+ registers subclasses. Each subclass is for sampling from potentials from
a different package. Eg. ``GalpyPotentialSampler`` for sampling ``galpy``
potentials.
+ PotentialSampler can be used to initialize & wrap any of its subclasses.
This is controlled by the argument ``return_specific_class``. If False,
it returns the subclass itself.
+ Takes a ``potential`` and a ``frame`` (astropy CoordinateFrame). The
potential is used for sampling, but the resultant points are not located
in any reference frame, which we assign with ``frame``.
+ ``__call__`` and ``sample`` are used to sample the potential
+ ``resample`` (and ``resampler``) sample the potential many times. This can
be done for many iterations and different sample number points.


**discO.core.measurement**

- MeasurementErrorSampler : abstract base class for resampling a potential given measurement errors [#17]

+ registers subclasses. Each subclass is for resampling in a different way.
+ MeasurementErrorSampler can be used to wrap any of its subclasses.

- GaussianMeasurementErrorSampler : apply uncorrelated Gaussian errors [#17]


discO.data
^^^^^^^^^^

- Add Milky_Way_Sim_100 data [#10]


discO.extern
^^^^^^^^^^^^

Where classes for external packages are held.


discO.extern.agama
^^^^^^^^^^^^^^^^^^

- AGAMAPotentialSampler [#17]

+ Sample from ``agama`` potentials.
+ stores the mass and potential as attributes on the returned ``SkyCoord``


discO.extern.galpy
^^^^^^^^^^^^^^^^^^

- GalpyPotentialSampler [#17]

+ Sample from ``galpy`` potentials with a corresponding distribution function.
+ stores the mass and potential as attributes on the returned ``SkyCoord``


discO.utils
^^^^^^^^^^^

- resolve_framelike [#17]

Determine the frame and return a blank instance for anything that can be
used in ``frame=`` in ``Skycoord(...,frame=)``


API Changes
-----------

Expand All @@ -25,6 +132,17 @@ Bug Fixes
N/A


Docs
----

- Added glossary [#17]

+ 'frame-like'
+ 'coord-like'
+ 'coord scalar' and 'coord-like scalar'
+ 'coord array' and 'coord-like array'


Other Changes and Additions
---------------------------

Expand All @@ -36,12 +154,16 @@ Other Changes and Additions

- Use GitHub for CI [#12]

+ On tag [#17]

- Dependabot yml [#13]

- Issues Templates [#14]

- Update from project template [#18]

- Add ``.mailmap`` [#17]


Actions
^^^^^^^
Expand All @@ -50,6 +172,7 @@ Actions

- Pre-commit [#18]

(`isort <https://pypi.org/project/isort/>`_
-> `black <https://pypi.org/project/black/>`_
-> `flake8 <https://pypi.org/project/flake8/>`_)
- `isort <https://pypi.org/project/isort/>`_
- `black <https://pypi.org/project/black/>`_
- `flake8 <https://pypi.org/project/flake8/>`_
- many others from `precommit <https://pre-commit.com/hooks.html>`__ [#17]
Loading