Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lint #415

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
24 changes: 24 additions & 0 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run isort

on:
push:
pull_request:
merge_group:

jobs:
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
poetry install --with dev
- name: Check code with isort
run: |
poetry run isort . -c
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- repo: local
hooks:
- id: black
name: black
entry: black
language: system
types: [ python ]
- repo: local
hooks:
- id: isort
name: isort (python)
entry: isort
language: system
types: [ python ]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ pip install -e ".[dev]"
Either way will give you the very latest copy of the code, update the installed version if you git pull or modify scripts
yourself, and still enable you to import flarestack.

Finally, install the pre-commit hooks:

```shell
pre-commit install
```

If you do want to contribute to _flarestack_, you can check out some guidelines [here](https://github.com/icecube/flarestack/blob/master/CONTRIBUTING.md).


Expand Down
5 changes: 3 additions & 2 deletions examples/create_scrambled_dataset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from flarestack.data.icecube import gfu_v002_p04
from flarestack.utils import ps_catalogue_name, load_catalogue
import logging

from flarestack.data.icecube import gfu_v002_p04
from flarestack.utils import load_catalogue, ps_catalogue_name

logging.getLogger().setLevel("INFO")

# Initialise Injectors/LLHs
Expand Down
6 changes: 3 additions & 3 deletions flarestack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flarestack.core.minimisation import MinimisationHandler
from flarestack.core.results import ResultsHandler, OverfluctuationError
from flarestack.cluster import analyse, wait_cluster
from flarestack.core.unblinding import create_unblinder
from flarestack.core.energy_pdf import EnergyPDF
from flarestack.core.minimisation import MinimisationHandler
from flarestack.core.results import OverfluctuationError, ResultsHandler
from flarestack.core.unblinding import create_unblinder
from flarestack.shared import *
19 changes: 10 additions & 9 deletions flarestack/analyses/agn_cores/create_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
remaining 30% weight distributed across many sources. As integer numbers of
sources are used, the closest percentage to 70% is used for splitting.
"""
from __future__ import print_function
from __future__ import absolute_import

from __future__ import absolute_import, print_function

import os
from builtins import zip

import astropy.io.fits as pyfits
import numpy as np
from astropy.table import Table

from flarestack.analyses.agn_cores.shared_agncores import (
raw_cat_dir,
agn_catalogue_name,
agn_cores_output_dir,
)
from flarestack.analyses.agn_cores.shared_agncores import (
create_random_src,
plot_catalogue,
raw_cat_dir,
)
from flarestack.utils.prepare_catalogue import cat_dtype
import astropy.io.fits as pyfits
from astropy.table import Table
import numpy as np
import os


def select_nrandom_sources(cat, n_random=100):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,45 @@
Sensitivities are given as the total integrated fluence across all sources,
and as the corresponding standard-candle-luminosity.
"""
from __future__ import print_function
from __future__ import division

from __future__ import division, print_function

import logging
import math
import os
import resource
import time

import matplotlib.pyplot as plt
import numpy as np
import psutil # to get memory usage info
from matplotlib.ticker import ScalarFormatter

from flarestack.analyses.agn_cores.shared_agncores import (
agn_catalogue_name,
agn_subset_catalogue,
agn_subset_catalogue_north,
complete_cats,
)
from flarestack.cluster import analyse, wait_for_cluster
from flarestack.core.minimisation import MinimisationHandler
from flarestack.core.results import ResultsHandler
from flarestack.data.icecube import diffuse_8_year

# # from flarestack.data.icecube.ps_tracks.ps_v002_p01 import ps_7year
# from flarestack.data.icecube.ps_tracks.ps_v003_p02 import ps_10year
# from flarestack.data.icecube.northern_tracks.nt_v002_p05 import diffuse_8year
# from flarestack.data.icecube.gfu.gfu_v002_p01 import txs_sample_v1
from flarestack.shared import (
plot_output_dir,
flux_to_k,
make_analysis_pickle,
k_to_flux,
make_analysis_pickle,
plot_output_dir,
)

from flarestack.data.icecube import diffuse_8_year
from flarestack.utils.catalogue_loader import load_catalogue
from flarestack.analyses.agn_cores.shared_agncores import (
agn_subset_catalogue,
complete_cats,
agn_catalogue_name,
agn_subset_catalogue_north,
)
from flarestack.core.minimisation import MinimisationHandler

from flarestack.cluster import analyse, wait_for_cluster
import math
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter

import matplotlib.pyplot as plt

# plt.style.use('~/scratch/phdthesis.mpltstyle')

import time

import logging

import os
import psutil, resource # to get memory usage info

analyses = dict()

Expand Down Expand Up @@ -691,9 +689,8 @@ def generate_name(cat_key, n_sources, gamma):
frame2.set_ylabel("Stacked\nsources")
frame2.set_yticks([10, 1000, 10000])

from matplotlib.ticker import AutoMinorLocator
from matplotlib.ticker import StrMethodFormatter
from matplotlib import ticker
from matplotlib.ticker import AutoMinorLocator, StrMethodFormatter

minorLocator = AutoMinorLocator()
# frame2.xaxis.set_minor_locator(minorLocator)
Expand Down Expand Up @@ -819,9 +816,8 @@ def generate_name(cat_key, n_sources, gamma):
frame2.set_yticks([10, 1000, 10000])
frame2.set_ylabel("Stacked\nsources")

from matplotlib.ticker import AutoMinorLocator
from matplotlib.ticker import StrMethodFormatter
from matplotlib import ticker
from matplotlib.ticker import AutoMinorLocator, StrMethodFormatter

minorLocator = AutoMinorLocator()
# frame2.xaxis.set_minor_locator(minorLocator)
Expand Down
15 changes: 9 additions & 6 deletions flarestack/analyses/agn_cores/loop_over_catalogues.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
Sensitivities are given as the total integrated fluence across all sources,
and as the corresponding standard-candle-luminosity.
"""

import math
from builtins import str

import matplotlib.pyplot as plt
import numpy as np

from flarestack.analyses.tde.shared_TDE import tde_catalogue_name, tde_catalogues
from flarestack.cluster import run_desy_cluster as rd
from flarestack.core.results import ResultsHandler
from flarestack.data.icecube.gfu.gfu_v002_p01 import txs_sample_v1
from flarestack.shared import plot_output_dir, flux_to_k, make_analysis_pickle
from flarestack.utils.reference_sensitivity import reference_sensitivity
from flarestack.analyses.tde.shared_TDE import tde_catalogues, tde_catalogue_name
from flarestack.cluster import run_desy_cluster as rd
import math
import matplotlib.pyplot as plt
from flarestack.shared import flux_to_k, make_analysis_pickle, plot_output_dir
from flarestack.utils.custom_dataset import custom_dataset
from flarestack.utils.reference_sensitivity import reference_sensitivity

analyses = dict()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
and XMMSL2 and NVSS. From the two subsamples 3LAC blazars have been removed.
Also double X-Ray sources and double radio sources have been removed.
"""

import os

import astropy.io.fits as pyfits
import numpy as np
import pandas as pd
from astropy.table import Table
from shared_agncores import create_random_src, plot_catalogue

from flarestack.analyses.agn_cores.shared_agncores import (
raw_cat_dir,
agn_catalogue_name,
agn_cores_output_dir,
raw_cat_dir,
)
from shared_agncores import create_random_src, plot_catalogue
from flarestack.utils.prepare_catalogue import cat_dtype
import astropy.io.fits as pyfits
from astropy.table import Table
import numpy as np
import pandas as pd
import os


def select_nrandom_sources(cat, n_random=100):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
and XMMSL2 and NVSS. From the two subsamples 3LAC blazars have been removed.
Also double X-Ray sources and double radio sources have been removed.
"""

import os

import astropy.io.fits as pyfits
import numpy as np
import pandas as pd
from astropy.table import Table
from shared_agncores import create_random_src, plot_catalogue

from flarestack.analyses.agn_cores.shared_agncores import (
raw_cat_dir,
agn_catalogue_name,
agn_cores_output_dir,
raw_cat_dir,
)
from shared_agncores import create_random_src, plot_catalogue
from flarestack.utils.prepare_catalogue import cat_dtype
import astropy.io.fits as pyfits
from astropy.table import Table
import numpy as np
import pandas as pd
import os


def select_nrandom_sources(cat, n_random=100):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
and XMMSL2 and NVSS. From the two subsamples 3LAC blazars have been removed.
Also double X-Ray sources and double radio sources have been removed.
"""

import os

import astropy.io.fits as pyfits
import numpy as np
import pandas as pd
from astropy.table import Table
from shared_agncores import create_random_src, plot_catalogue

from flarestack.analyses.agn_cores.shared_agncores import (
raw_cat_dir,
agn_catalogue_name,
agn_cores_output_dir,
raw_cat_dir,
)
from shared_agncores import create_random_src, plot_catalogue
from flarestack.utils.prepare_catalogue import cat_dtype
import astropy.io.fits as pyfits
from astropy.table import Table
import numpy as np
import pandas as pd
import os


def select_nrandom_sources(cat, n_random=100):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
and XMMSL2 and NVSS. From the two subsamples 3LAC blazars have been removed.
Also double X-Ray sources and double radio sources have been removed.
"""

import os

import astropy.io.fits as pyfits
import numpy as np
import pandas as pd
from astropy.table import Table
from shared_agncores import create_random_src, plot_catalogue

from flarestack.analyses.agn_cores.shared_agncores import (
raw_cat_dir,
agn_catalogue_name,
agn_cores_output_dir,
raw_cat_dir,
)
from shared_agncores import create_random_src, plot_catalogue
from flarestack.utils.prepare_catalogue import cat_dtype
import astropy.io.fits as pyfits
from astropy.table import Table
import numpy as np
import pandas as pd
import os


def select_nrandom_sources(cat, n_random=100):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
and removing the 3LAC blazars. A Seyferntess PDF is assigned and only sources with
Seyfertness larger than 0.5 are selected in the final sample.
"""

import os

import astropy.io.fits as pyfits
import numpy as np
import pandas as pd
from astropy.table import Table
from shared_agncores import create_random_src, plot_catalogue

from flarestack.analyses.agn_cores.shared_agncores import (
raw_cat_dir,
agn_catalogue_name,
agn_cores_output_dir,
raw_cat_dir,
)
from shared_agncores import create_random_src, plot_catalogue
from flarestack.utils.prepare_catalogue import cat_dtype
import astropy.io.fits as pyfits
from astropy.table import Table
import numpy as np
import pandas as pd
import os


def select_nrandom_sources(cat, n_random=100):
Expand Down
Loading
Loading