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

Create error field script #61

Draft
wants to merge 74 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
af78241
Create healpix_gaia_query.ipynb
CCAstro35 Aug 23, 2021
4cf86a3
start script
nstarman Sep 3, 2021
2b15415
move notebook
nstarman Sep 3, 2021
bc7052d
add script entry point
nstarman Sep 3, 2021
6fe5619
update script
nstarman Sep 5, 2021
02efbd3
update known packages
nstarman Sep 5, 2021
82f65cf
and requirements
nstarman Sep 5, 2021
9c8b574
functional
nstarman Sep 10, 2021
efd6452
fixup mypy
nstarman Oct 7, 2021
785af9a
sky distributed pixels
nstarman Oct 8, 2021
6dda8a3
add to setup
nstarman Oct 8, 2021
9bb1005
fix passing arg
nstarman Oct 9, 2021
22a6989
update random index
nstarman Oct 9, 2021
6a06ce1
username
nstarman Oct 9, 2021
3d88227
debug
nstarman Oct 9, 2021
39ffa23
respace query
nstarman Oct 9, 2021
f0c0c28
debug
nstarman Oct 9, 2021
6916da1
fix string sub
nstarman Oct 9, 2021
b172e31
update user default
nstarman Oct 9, 2021
7018341
local query
nstarman Oct 9, 2021
68b8c1b
str subs
nstarman Oct 9, 2021
f837577
pass opts through
nstarman Oct 9, 2021
cabfb7b
cleanup
nstarman Oct 9, 2021
bd90be6
there's no GAIA_HEALPIX_INDEX
nstarman Oct 21, 2021
2cb9bd7
fix type
nstarman Oct 21, 2021
4e187db
fix healpix id integer division
nstarman Oct 27, 2021
74bc648
use known SQL
nstarman Oct 28, 2021
a7985e7
use shortened name
nstarman Nov 4, 2021
f27091f
verbosity
nstarman Nov 4, 2021
0ac562d
fix
nstarman Nov 4, 2021
3bc46c3
oops
nstarman Nov 4, 2021
6ea5936
Add order to plot func
nstarman Nov 4, 2021
5b59cb7
add patchids to plot func
nstarman Nov 4, 2021
95eebd2
correct type casting
nstarman Nov 4, 2021
b70dd19
add verbose to main script
nstarman Nov 4, 2021
7b0bec6
write mode
nstarman Nov 4, 2021
8615a25
str contents
nstarman Nov 4, 2021
c8d3aa7
fix
nstarman Nov 4, 2021
ad71760
ensure QTable
nstarman Nov 4, 2021
b07e264
Quantities
nstarman Nov 4, 2021
6b3bcc0
remove extraneous
nstarman Nov 18, 2021
bb58d04
fix UnboundLocalError:
nstarman Nov 18, 2021
d18e9c2
ibid
nstarman Nov 18, 2021
094b169
ibid
nstarman Nov 18, 2021
b2a1c30
no plot arg
nstarman Nov 18, 2021
81b9e4c
ykr
nstarman Nov 18, 2021
994b4a5
test
nstarman Nov 18, 2021
efacf7e
lots of small fixes
nstarman Nov 30, 2021
f5ffacb
correct import name
nstarman Nov 30, 2021
264140f
ibid
nstarman Nov 30, 2021
5ee4624
get type of Axes
nstarman Nov 30, 2021
1183141
path should exist
nstarman Nov 30, 2021
afe52d4
expand user
nstarman Nov 30, 2021
680391f
add utils
nstarman Nov 30, 2021
4b18d80
add import
nstarman Nov 30, 2021
f4f6bf0
relax make_X input
nstarman Dec 1, 2021
a24711f
don't use healpy compat
nstarman Dec 1, 2021
acb990b
fix arg reference
nstarman Dec 1, 2021
1f90301
easier interpolation class
nstarman Dec 2, 2021
dfed73b
switch to table per set
nstarman Dec 9, 2021
a3eca42
proper parent folder
nstarman Dec 9, 2021
33840d4
correct number of columns
nstarman Dec 9, 2021
04f7b26
actually save table separately
nstarman Dec 9, 2021
daba307
make table for all fits
nstarman Dec 9, 2021
9d58dd5
fix reference
nstarman Dec 9, 2021
ff3fe9e
plot dir
nstarman Dec 9, 2021
8e8c0b4
fix verbosity flag and save loc
nstarman Dec 9, 2021
070e435
incremental saves
nstarman Dec 9, 2021
bd96bdb
differently limit background depth
nstarman Dec 20, 2021
a6149a1
fix imports
nstarman Dec 20, 2021
c3d95ee
folder suffix
nstarman Dec 20, 2021
6be6470
actully fix
nstarman Dec 20, 2021
a836f7f
resume from last go
nstarman Jan 21, 2022
083f291
fix typo
nstarman Jan 28, 2022
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
22 changes: 11 additions & 11 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: v3.4.0
rev: v4.0.1
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -17,7 +17,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
Expand All @@ -29,12 +29,12 @@ repos:
- id: text-unicode-replacement-char

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

- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
rev: 2.1.5
hooks:
- id: check-mailmap
- id: forbid-binary
Expand All @@ -43,12 +43,12 @@ repos:
- id: shfmt

- repo: https://github.com/mgedmin/check-manifest
rev: "0.46"
rev: '0.46'
hooks:
- id: check-manifest

- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
rev: v1.5.7
hooks:
- id: autopep8

Expand All @@ -57,13 +57,13 @@ repos:
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
rev: v5.9.3
hooks:
- id: isort
additional_dependencies: ["toml"]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8
args: # arguments to configure flake8
Expand All @@ -79,17 +79,17 @@ repos:
- "--exclude=*/_astropy_init.py docs/conf.py"

- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.8b0
hooks:
- id: black
additional_dependencies: ["toml"]
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.1
rev: v1.11.0
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
- repo: https://github.com/nbQA-dev/nbQA
rev: 0.5.6
rev: 1.1.0
hooks:
- id: nbqa-black
additional_dependencies: [black==20.8b1]
Expand Down
3 changes: 1 addition & 2 deletions discO/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
update_default_config(__package__, config_dir)
except ConfigurationDefaultMissingError as e:
wmsg = (
e.args[0]
+ " Cannot install default profile. If you are "
e.args[0] + " Cannot install default profile. If you are "
"importing from source, this is expected."
)
warn(ConfigurationDefaultMissingWarning(wmsg))
Expand Down
5 changes: 1 addition & 4 deletions discO/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@

try:
# THIRD PARTY
from pytest_astropy_header.display import (
PYTEST_HEADER_MODULES,
TESTED_VERSIONS,
)
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS

ASTROPY_HEADER = True
except ImportError:
Expand Down
6 changes: 1 addition & 5 deletions discO/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ def registry(cls) -> T.Mapping:

# else, filter registry by subclass
return MappingProxyType(
{
k: v
for k, v in cls._registry.items()
if issubclass(v, cls) and v is not cls
},
{k: v for k, v in cls._registry.items() if issubclass(v, cls) and v is not cls},
)

# /def
Expand Down
12 changes: 3 additions & 9 deletions discO/core/fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
# PROJECT-SPECIFIC
import discO.type_hints as TH
from .common import CommonBase
from discO.utils.coordinates import (
resolve_framelike,
resolve_representationlike,
)
from discO.utils.coordinates import resolve_framelike, resolve_representationlike
from discO.utils.pbar import get_progress_bar

##############################################################################
Expand Down Expand Up @@ -114,16 +111,13 @@ def __new__(

if key not in cls._registry:
raise ValueError(
"PotentialFitter has no registered fitter for key: "
f"{key}",
"PotentialFitter has no registered fitter for key: " f"{key}",
)

# from registry. Registered in __init_subclass__
kls = cls._registry[key]
kwargs.pop("key", None) # it's already used.
return kls.__new__(
kls, potential_cls=potential_cls, key=None, **kwargs
)
return kls.__new__(kls, potential_cls=potential_cls, key=None, **kwargs)

elif key is not None:
raise ValueError(
Expand Down
30 changes: 7 additions & 23 deletions discO/core/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
import astropy.units as u
import numpy as np
import scipy.stats
from astropy.coordinates import (
BaseCoordinateFrame,
BaseRepresentation,
SkyCoord,
concatenate,
)
from astropy.coordinates import BaseCoordinateFrame, BaseRepresentation, SkyCoord, concatenate
from astropy.utils.decorators import classproperty

# PROJECT-SPECIFIC
Expand Down Expand Up @@ -173,8 +168,7 @@ def __new__(

elif method is not None:
raise ValueError(
f"Can't specify 'method' on {cls},"
" only on MeasurementErrorSampler.",
f"Can't specify 'method' on {cls}," " only on MeasurementErrorSampler.",
)

return super().__new__(cls)
Expand Down Expand Up @@ -398,9 +392,7 @@ def _run_batch(
else: # (Nsamples, Niter)

samples = list(
self._run_iter(
c, c_err=c_err, random=random, progress=progress, **kwargs
),
self._run_iter(c, c_err=c_err, random=random, progress=progress, **kwargs),
)

sample = concatenate(samples).reshape(c.shape)
Expand Down Expand Up @@ -457,9 +449,7 @@ def run(
if not isinstance(random, np.random.RandomState):
random = np.random.RandomState(random)

return run_func(
c, c_err=c_err, random=random, progress=progress, **kwargs
)
return run_func(c, c_err=c_err, random=random, progress=progress, **kwargs)

# /def

Expand Down Expand Up @@ -698,15 +688,12 @@ def __new__(
# a cleaner error than KeyError on the actual registry
if not cls._in_registry(method):
raise ValueError(
"RVS_Continuous has no registered "
f"measurement resampler '{method}'",
"RVS_Continuous has no registered " f"measurement resampler '{method}'",
)

# from registry. Registered in __init_subclass__
# don't pass rvs, b/c not all subclasses take it
return super().__new__(
cls[method], c_err=c_err, method=None, **kwargs
)
return super().__new__(cls[method], c_err=c_err, method=None, **kwargs)

elif method is not None:
raise ValueError(
Expand Down Expand Up @@ -846,10 +833,7 @@ def __call__(

# re-build representation
new_rep = rep.__class__(
**{
n: attr_classes[n](p * unit)
for p, (n, unit) in zip(new_posT, units.items())
}
**{n: attr_classes[n](p * unit) for p, (n, unit) in zip(new_posT, units.items())}
)
# make coordinate
new_cc = self.frame.realize_frame(
Expand Down
16 changes: 4 additions & 12 deletions discO/core/residual.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
import discO.type_hints as TH
from .common import CommonBase
from .wrapper import PotentialWrapper
from discO.utils.coordinates import (
resolve_framelike,
resolve_representationlike,
)
from discO.utils.coordinates import resolve_framelike, resolve_representationlike
from discO.utils.pbar import get_progress_bar

##############################################################################
Expand Down Expand Up @@ -113,8 +110,7 @@ def __new__(cls, *args, method: T.Optional[str] = None, **kwargs):

elif method is not None:
raise ValueError(
f"Can't specify 'method' on {cls.__name__}, "
"only on ResidualMethod.",
f"Can't specify 'method' on {cls.__name__}, " "only on ResidualMethod.",
)

return super().__new__(cls)
Expand All @@ -140,9 +136,7 @@ def __init__(
# representation type
representation_type = (
resolve_representationlike(representation_type)
if not (
representation_type is None or representation_type is Ellipsis
)
if not (representation_type is None or representation_type is Ellipsis)
else representation_type
)

Expand Down Expand Up @@ -270,9 +264,7 @@ def evaluate_potential(
evaluator: T.Callable = getattr(evaluator_cls, observable)

# evaluate
value = evaluator(
points, representation_type=representation_type, **kwargs
)
value = evaluator(points, representation_type=representation_type, **kwargs)

# -----------------------
# Return
Expand Down
15 changes: 5 additions & 10 deletions discO/core/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ def __new__(

if key not in cls._registry:
raise ValueError(
"PotentialSampler has no registered sampler for key: "
f"{key}",
"PotentialSampler has no registered sampler for key: " f"{key}",
)

# from registry. Registered in __init_subclass__
Expand Down Expand Up @@ -195,8 +194,7 @@ def __init__(
mtot = potential.total_mass() if total_mass is None else total_mass
if not np.isfinite(mtot): # divergent
raise ValueError(
"The potential`s mass is divergent, "
"the argument `total_mass` cannot be None.",
"The potential`s mass is divergent, " "the argument `total_mass` cannot be None.",
)

# potential is checked in __new__ as a PotentialWrapper
Expand Down Expand Up @@ -642,19 +640,16 @@ def _get_dimensions(meshgrid):
def _imapper(self):
@frompyfunc(nin=1, nout=1)
def imapper(uniform_draw):
iflat = np.where(
uniform_draw * self._normalization <= self._index_partition,
)[0][0]
iflat = np.where(uniform_draw * self._normalization <= self._index_partition)
iflat = iflat[0][0]
i = np.unravel_index(iflat, self._gridshape)
return i

return imapper

# /def

def __call__(
self, n: int, rng: T.Optional[np.random.Generator] = None, **kw
):
def __call__(self, n: int, rng: T.Optional[np.random.Generator] = None, **kw):
"""Sample.

.. todo::
Expand Down
10 changes: 2 additions & 8 deletions discO/core/tests/test_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,7 @@ def test_representation_type(self):
def test_potential_kwargs(self):
"""Test attribute ``potential_kwargs``."""
if hasattr(self.inst, "_instance"):
assert (
self.inst.potential_kwargs
== self.inst._instance.potential_kwargs
)
assert self.inst.potential_kwargs == self.inst._instance.potential_kwargs
else:
assert self.inst.potential_kwargs == MappingProxyType(
self.inst._kwargs,
Expand Down Expand Up @@ -388,10 +385,7 @@ def test_run(self, sample, mass, batch):
assert isinstance(pots, np.ndarray)
assert len(pots) == sample.shape[1]
assert all(
[
isinstance(p.__wrapped__, sample.cache["potential"])
for p in pots
],
[isinstance(p.__wrapped__, sample.cache["potential"]) for p in pots],
)

# and then cleanup
Expand Down
Loading