-
Notifications
You must be signed in to change notification settings - Fork 34
Introduce submodules into python-flint #61
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
Closed
Closed
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
aade052
update imports to include utils
GiacomoPope 5ffb83e
refactor out some util functions from pyflint
GiacomoPope a4511c9
Refactor out context class from pyflint
GiacomoPope 304dd67
remove some globals from pyflint
GiacomoPope b5b1831
include DS_Store to gitignore
GiacomoPope 06064b0
EOF
GiacomoPope f36b681
Add submodule
GiacomoPope 7b7d2d2
EOF
GiacomoPope 622c671
Reverse old formatting
GiacomoPope 2dee3db
Fix relative imports and now get a proper error
GiacomoPope 0f5d236
Factor out into submodule
GiacomoPope 726a699
ensure submodule c files are skipped
GiacomoPope b3e5ec9
Refactor out more conversions
GiacomoPope b8be99b
move away from depreciated properties
GiacomoPope f7c3bfc
Refactor set up for inclusion of submodules
GiacomoPope 4e5310b
move context into new submodule
GiacomoPope 4d7ad87
Import thectx from module and set ctx
GiacomoPope 039e687
Import precision / cap inline functions previously defined as global
GiacomoPope e76daf4
Global context need not be an extension, as its not defining a new class
GiacomoPope f09b791
remove template classes
GiacomoPope 522c50a
Add templates as a submodule
GiacomoPope 8b1190f
delete unneeded file
GiacomoPope 718b1fc
Include needed classes for each flint type
GiacomoPope 38c9ffd
Actually include the new files
GiacomoPope 3ab97f6
Make flint_poly a global until issue #62 is resolved
GiacomoPope a4d3a85
Remove imports until they're ready
GiacomoPope 9a3fd0b
remove old pxd
GiacomoPope 457f429
remove old pxd
GiacomoPope 4a16f0e
Update imports
GiacomoPope 644b5bb
Add all global context into this file
GiacomoPope da48588
Merge pull request #61 from GiacomoPope/introduce-submodules
oscarbenjamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,15 @@ | |
| library_dirs=default_lib_dirs, | ||
| include_dirs=default_include_dirs, | ||
| define_macros=define_macros, | ||
| ) | ||
| ), | ||
| Extension( | ||
| "flint.flint_base.flint_context", | ||
| ["src/flint/flint_base/flint_context.pyx"], | ||
| libraries=libraries, | ||
| library_dirs=default_lib_dirs, | ||
| include_dirs=default_include_dirs, | ||
| define_macros=define_macros, | ||
| ), | ||
| ] | ||
|
|
||
| for e in ext_modules: | ||
|
|
@@ -86,9 +94,10 @@ | |
| description='Bindings for FLINT and Arb', | ||
| long_description=open('README.md').read(), | ||
| long_description_content_type='text/markdown', | ||
| version='0.4.1', | ||
| url='https://github.com/python-flint/python-flint', | ||
| version='0.4.2', | ||
| url='https://github.com/flintlib/python-flint', | ||
| author='Fredrik Johansson', | ||
| author_email='[email protected]', | ||
| license='MIT', | ||
| classifiers=['Topic :: Scientific/Engineering :: Mathematics']) | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| from .utils.conversion cimport prec_to_dps | ||
|
|
||
| cdef class arf: | ||
|
|
||
| cdef arf_t val | ||
|
|
||
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from flint._flint cimport ( | ||
| arf_rnd_t, | ||
| ) | ||
|
|
||
| cdef class FlintContext: | ||
| cdef public bint pretty | ||
| cdef public long _prec | ||
| cdef public long _dps | ||
| cdef arf_rnd_t rnd | ||
| cdef public bint unicode | ||
| cdef public long _cap |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| from flint._flint cimport ( | ||
| ARF_RND_DOWN, | ||
| flint_cleanup, | ||
| flint_get_num_threads, | ||
| flint_set_num_threads | ||
| ) | ||
| from flint.utils.conversion cimport prec_to_dps, dps_to_prec | ||
|
|
||
| cdef class FlintContext: | ||
| def __init__(self): | ||
| self.default() | ||
|
|
||
| def default(self): | ||
| self.pretty = True | ||
| self.rnd = ARF_RND_DOWN | ||
| self.prec = 53 | ||
| self.unicode = False | ||
| self.threads = 1 | ||
| self.cap = 10 | ||
|
|
||
| @property | ||
| def prec(self): | ||
| return self._prec | ||
|
|
||
| @prec.setter | ||
| def prec(self, prec): | ||
| cdef long cprec = prec | ||
| if cprec < 2: | ||
| raise ValueError("prec must be >= 2") | ||
| self._prec = cprec | ||
| self._dps = prec_to_dps(cprec) | ||
|
|
||
| @property | ||
| def dps(self): | ||
| return self._dps | ||
|
|
||
| @dps.setter | ||
| def dps(self, prec): | ||
| self.prec = dps_to_prec(prec) | ||
|
|
||
| @property | ||
| def cap(self): | ||
| return self._cap | ||
|
|
||
| @cap.setter | ||
| def cap(self, long cap): | ||
| if cap < 0: | ||
| raise ValueError("cap must be >= 0") | ||
| self._cap = cap | ||
|
|
||
| @property | ||
| def threads(self): | ||
| return flint_get_num_threads() | ||
|
|
||
| @threads.setter | ||
| def threads(self, long num): | ||
| assert num >= 1 and num <= 64 | ||
| flint_set_num_threads(num) | ||
|
|
||
| def __repr__(self): | ||
| return "pretty = %-8s # pretty-print repr() output\n" \ | ||
| "unicode = %-8s # use unicode characters in output\n" \ | ||
| "prec = %-8s # real/complex precision (in bits)\n" \ | ||
| "dps = %-8s # real/complex precision (in digits)\n" \ | ||
| "cap = %-8s # power series precision\n" \ | ||
| "threads = %-8s # max number of threads used internally\n" % \ | ||
| (self.pretty, self.unicode, self.prec, self.dps, self.cap, self.threads) | ||
|
|
||
| def cleanup(self): | ||
| flint_cleanup() |
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
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
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
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
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
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
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from cpython.version cimport PY_MAJOR_VERSION | ||
|
|
||
| cdef inline long prec_to_dps(n): | ||
| return max(1, int(round(int(n)/3.3219280948873626)-1)) | ||
|
|
||
| cdef inline long dps_to_prec(n): | ||
| return max(1, int(round((int(n)+1)*3.3219280948873626))) | ||
|
|
||
| cdef inline chars_from_str(s): | ||
| if PY_MAJOR_VERSION < 3: | ||
| return s | ||
| else: | ||
| return s.encode('ascii') | ||
|
|
||
| cdef inline str_from_chars(s): | ||
| if PY_MAJOR_VERSION < 3: | ||
| return str(s) | ||
| else: | ||
| return bytes(s).decode('ascii') | ||
|
|
||
| cdef inline matrix_to_str(tab): | ||
| if len(tab) == 0 or len(tab[0]) == 0: | ||
| return "[]" | ||
| tab = [[str(c) for c in row] for row in tab] | ||
| widths = [] | ||
| for i in xrange(len(tab[0])): | ||
| w = max([len(row[i]) for row in tab]) | ||
| widths.append(w) | ||
| for i in xrange(len(tab)): | ||
| tab[i] = [s.rjust(widths[j]) for j, s in enumerate(tab[i])] | ||
| tab[i] = "[" + (", ".join(tab[i])) + "]" | ||
| return "\n".join(tab) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to factor this out like:
Then it is easier to add to the
ext_fileslist to make more extension modules and we don't need to duplicate the arguments inext_options.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, addressed in commit f7c3bfc