keflavich / imf

Simple tools to work with the Initial Mass Function
MIT License
44 stars 17 forks source link

Fixes #26

Closed segasai closed 3 years ago

segasai commented 3 years ago

Several fixes addressing #21, #19, #18 Also run the code through yapf formatter.

I.e now when specifying invalid mmin for kroupa a proper error is raised

In [5]: cl = imf.make_cluster(1000,massfunc='kroupa',mmin=1)
ValueError: Power law break-points must be monotonic

also the global imf objects are not modified since get_massfunc() returns new instances

Also mmin is supported now for chabrier

In [13]: imf.make_cluster(1000,massfunc='chabrier',mmin=10).mean()
Total cluster mass is 1002.2 (limit was 1000)
Out[13]: 16.70338008453732

In [14]: imf.make_cluster(1000,massfunc='chabrier',mmin=1).mean()
Total cluster mass is 1000.38 (limit was 1000)
Out[14]: 2.2684320853833024
segasai commented 3 years ago

I didn't remove the global objects -- I've groupped them. (see lines ~ 300). The reason to separate the definition of the classes from the creation of global objects. And get_massfunc works after the change (if I understood your question)

keflavich commented 3 years ago

Sorry, that's my bad! I was looking for exactly https://github.com/keflavich/imf/pull/26/files#diff-1e13df7a25dad73166b0f0e1e9909d2829360f05f1077e4a0d60d64e24bfc7c2R340-R344 but didn't find them. That's the problem with including style fixes in with others.