Skip to content

Conversation

@robertdstein
Copy link
Member

Bump black version, add isort for prettifying dependencies, add option for pre-commit.

Nearly every file is affected by this PR, but the changes in almost all files are cosmetic.

@robertdstein robertdstein requested a review from JannisNe January 29, 2025 15:34
@JannisNe
Copy link
Collaborator

JannisNe commented Jan 29, 2025

I think we should do this. However, this could be a potential nightmare for people doing analyses right now and have modified their flarestack. In that case merging the these changes into main will result in many, many conflicts. As far as I am aware, this could affect @sathanas31, @TeresaPernice and also @mlincett. I will check that any potential PRs are done in the next couple of days before we proceed with this, if there is no urgency, @robertdstein.

@robertdstein
Copy link
Member Author

Sure, no urgency and you can also just close this PR if it's not helpful.

@mlincett
Copy link
Collaborator

No blockers from my side.

(If we need to touch this again in the future, I would suggest looking at ruff that I have used in other situations to replace black and flake8).

@JannisNe JannisNe merged commit 7beb9ec into master Feb 20, 2025
19 of 25 checks passed
@JannisNe JannisNe deleted the lint branch February 20, 2025 14:09
jvansanten added a commit to jvansanten/flarestack that referenced this pull request Jul 8, 2025
jvansanten added a commit that referenced this pull request Sep 5, 2025
* Use astropy Tables for data everywhere

* Load npz file if present

* Improve cache coherence in NTSeason.simulate_background

Cuts time in Injector.create_dataset() from ~1500 ms to ~600 ms

* CircularGaussian: do not attempt to modify data in-place

* Blacken/isorten following #415

* Use Table for EffectiveAreaInjector

* Annotate factory functions

* Avoid modifying columns in place

* Use instance variables in NorthernTracksKDE

* Normalize KDE PDF to region of interest

* Speed up TableInjector

by a factor ~2 when drawing ~175 events from 11.5e6 MC events across 1000 sources

* Speed up StaticFloor

numpy broadcasting is much faster than a list comprehension

* Cache effective injection time for steady sources

There's no point in calculating this tens of thousands of times, since it's independent of the source for a steady time pdf

* Remove upper bound on n_s

* Squeeze the last bits of fluff out of StdMatrixKDEEnabledLLH.get_spatially_coincident_indices

Unexpected bottlenecks:
- Repeatedly slicing into astropy Tables (overhead from copying units)
- Temporary arrays in ra_dist and angular_distance

* Evaluate SoB for different gammas lazily

Keys appear as before, but values are only evaluated when accessed. Speeds up initialization when gamma is not being fitted.

* Use less accurate (but much faster) angular distance calculation in NorthernTracksKDE

* Annotate PDF factory functions

* HACK: allow StdMatrixKDEEnabledLLH to use CircularGaussian pdf

* Revert "Annotate PDF factory functions"

This reverts commit 9afa53e13556e783a73909fa2751ed98bad35f27.

* Normalize gaussian PDF

* WIP: King function PSF

* chore: annotate BaseInjector

* Allow Season to simulate background only in the source box

* Evaluate energy SoB lazily

* Add log of King PDF

* Add an option to disable energy S/B interpolation

The 2nd-order spline interpolation does not necessarily reflect the normalization of the underyling signal or background energy PDFs

* Use splines for King PDF parameters

* Speed up make_season_weight 10x

180 ms -> 11 ms for 22k sources

* Microoptimization: sparse matrix projection 25% faster

* Microoptimization: slice result of background pdf calculation instead of inputs

* mypy cleanup

* Guard annotation-only imports

* Cosmetic: raw string for latex

* Return excluded events from create_dataset in unblinded injectors

* Consider excluded events in flare likelihoods (but require ==0)

* Handle unbounded n_s in 1D llh scan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants