DOC/MAINT: Add copyright notice to qmc.primes_from_2_to#13927
Merged
rgommers merged 3 commits intoscipy:masterfrom Apr 24, 2021
Merged
DOC/MAINT: Add copyright notice to qmc.primes_from_2_to#13927rgommers merged 3 commits intoscipy:masterfrom
rgommers merged 3 commits intoscipy:masterfrom
Conversation
rkern
reviewed
Apr 23, 2021
Member
|
Not to steal any credit, (the core is left intact) but because previously having bitten by it, def primesfrom2to(n):
""" Input n>=6, Returns a array of primes, 2 <= p < n """
sieve = np.ones(n//3 + (n % 6 == 2), dtype=bool)
for i in range(1, int(sqrt(n))//3+1):
if sieve[i]:
k = 3*i+1 | 1
sieve[k*k//3::2*k] = False
sieve[k*(k-2*(i & 1)+4)//3::2*k] = False
t = (3*np.nonzero(sieve)[0][1:]+1) | 1
res = np.empty(len(t)+2, dtype=int)
res[:2] = [2, 3]
res[2:] = t
return resThere are some more places to gain some more speed with bit manipulations etc. but I don't think it's worth it to klingonize it. |
Member
Author
|
@ilayn Great if you can improve it. I thing though it should be another PR. Here it's just about properly crediting something I copied. But feel free to commit on the branch. If you would rewrite it, I would also propose to add a method parameter as to propose things like sieve of Atkin. And as the current implementation is quite fast, it would make then sense to go to compiled code. |
[ci skip]
patnr
added a commit
to patnr/scipy
that referenced
this pull request
May 3, 2021
* master: (164 commits) DOC: Add Karl Pearson's reference to chi-square test (scipy#13971) BLD: fix build warnings for causal/anticausal pointers in ndimage MAINT: stats: Fix unused imports and a few other issues related to imports. DOC: fix typo MAINT: Remove duplicate calculations in sokalmichener BUG: spatial: fix weight handling of `distance.sokalmichener`. DOC: update Readme (scipy#13910) MAINT: QMCEngine d input validation (scipy#13940) MAINT: forward port 1.6.3 relnotes REL: add PEP 621 (project metadata in pyproject.toml) support EHN: signal: make `get_window` supports `general_cosine` and `general_hamming` window functions. (scipy#13934) ENH/DOC: pydata sphinx theme polishing (scipy#13814) DOC/MAINT: Add copyright notice to qmc.primes_from_2_to (scipy#13927) BUG: DOC: signal: fix need argument config and add missing doc link for `signal.get_window` DOC: fix subsets docstring (scipy#13926) BUG: signal: fix get_window argument handling and add tests. (scipy#13879) ENH: stats: add 'alternative' parameter to ansari (scipy#13650) BUG: Reactivate conda environment in init MAINT: use dict built-in rather than OrderedDict Revert "CI: Add nightly release of NumPy in linux workflows (scipy#13876)" (scipy#13909) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code from
scipy.stats._qmc.from_2_towas taken from StackOverflow under a CC-BY-SA license. I contacted the author and got his permission to use his code under our 3-clause BSD license.I also added a slight note in the licensing section of the doc about code from StackOverflow.
Raw Email