overfloat 0.1.2__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {overfloat-0.1.2 → overfloat-0.1.3}/PKG-INFO +4 -4
  2. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/Overfloat.csproj +1 -1
  3. overfloat-0.1.3/native-src/VERSION +1 -0
  4. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/include/overfloat.h +1 -0
  5. {overfloat-0.1.2 → overfloat-0.1.3}/overfloat/__init__.py +39 -2
  6. {overfloat-0.1.2 → overfloat-0.1.3}/overfloat.egg-info/PKG-INFO +4 -4
  7. {overfloat-0.1.2 → overfloat-0.1.3}/pyproject.toml +3 -3
  8. overfloat-0.1.2/native-src/VERSION +0 -1
  9. {overfloat-0.1.2 → overfloat-0.1.3}/LICENSE +0 -0
  10. {overfloat-0.1.2 → overfloat-0.1.3}/README.md +0 -0
  11. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/BigIntegerExtensions.cs +0 -0
  12. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/Native/OverfloatExports.cs +0 -0
  13. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatBitConverter.cs +0 -0
  14. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatClassification.cs +0 -0
  15. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatEnvironment.cs +0 -0
  16. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatExceptionFlags.cs +0 -0
  17. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatFormatting.cs +0 -0
  18. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatHandleHelpers.cs +0 -0
  19. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatInfo.cs +0 -0
  20. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatMath.cs +0 -0
  21. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatNumber.cs +0 -0
  22. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatParsing.cs +0 -0
  23. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatRoundingMode.cs +0 -0
  24. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatSpecification.cs +0 -0
  25. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatStatus.cs +0 -0
  26. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/OverfloatValidation.cs +0 -0
  27. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/Rational.cs +0 -0
  28. {overfloat-0.1.2 → overfloat-0.1.3}/native-src/src/Overfloat/Utf8Helpers.cs +0 -0
  29. {overfloat-0.1.2 → overfloat-0.1.3}/overfloat.egg-info/SOURCES.txt +0 -0
  30. {overfloat-0.1.2 → overfloat-0.1.3}/overfloat.egg-info/dependency_links.txt +0 -0
  31. {overfloat-0.1.2 → overfloat-0.1.3}/overfloat.egg-info/top_level.txt +0 -0
  32. {overfloat-0.1.2 → overfloat-0.1.3}/setup.cfg +0 -0
  33. {overfloat-0.1.2 → overfloat-0.1.3}/setup.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: overfloat
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Python bindings for the Overfloat native floating-point runtime
5
5
  Author: Overfloat Contributors
6
6
  License-Expression: Apache-2.0
7
- Project-URL: Homepage, https://github.com/overfloat/overfloat
8
- Project-URL: Repository, https://github.com/overfloat/overfloat
9
- Project-URL: Issues, https://github.com/overfloat/overfloat/issues
7
+ Project-URL: Homepage, https://github.com/MontyChan/Overfloat
8
+ Project-URL: Repository, https://github.com/MontyChan/Overfloat
9
+ Project-URL: Issues, https://github.com/MontyChan/Overfloat/issues
10
10
  Keywords: floating-point,ieee-754,native,ctypes,arbitrary-precision
11
11
  Classifier: Development Status :: 3 - Alpha
12
12
  Classifier: Intended Audience :: Developers
@@ -21,7 +21,7 @@
21
21
  <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
22
22
  <PackageReadmeFile>README.md</PackageReadmeFile>
23
23
  <RepositoryType>git</RepositoryType>
24
- <RepositoryUrl>https://github.com/overfloat/overfloat</RepositoryUrl>
24
+ <RepositoryUrl>https://github.com/MontyChan/Overfloat</RepositoryUrl>
25
25
  <Company>Overfloat</Company>
26
26
  <Product>Overfloat</Product>
27
27
  </PropertyGroup>
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -14,6 +14,7 @@ extern "C" {
14
14
 
15
15
  OVERFLOAT_API int overfloat_version_major(void);
16
16
  OVERFLOAT_API int overfloat_version_minor(void);
17
+ OVERFLOAT_API int overfloat_version_patch(void);
17
18
  OVERFLOAT_API int overfloat_exception_flags_get(void);
18
19
  OVERFLOAT_API void overfloat_exception_flags_clear(void);
19
20
  OVERFLOAT_API void* overfloat_spec_create(int exponent_bits, int mantissa_bits, int rounding_mode);
@@ -39,35 +39,46 @@ class OverfloatNumber:
39
39
  self._handle = handle
40
40
  self._specification = specification
41
41
 
42
+ def _ensure_open(self) -> None:
43
+ if not self._handle:
44
+ raise OverfloatError("Cannot use a closed OverfloatNumber.")
45
+
42
46
  @property
43
47
  def specification(self) -> "OverfloatSpec":
44
48
  return self._specification
45
49
 
46
50
  @property
47
51
  def classification(self) -> int:
52
+ self._ensure_open()
48
53
  return int(self._library._lib.overfloat_number_classification(self._handle))
49
54
 
50
55
  @property
51
56
  def is_negative(self) -> bool:
57
+ self._ensure_open()
52
58
  return bool(self._library._lib.overfloat_number_is_negative(self._handle))
53
59
 
54
60
  @property
55
61
  def binary_exponent(self) -> int:
62
+ self._ensure_open()
56
63
  return int(self._library._lib.overfloat_number_binary_exponent(self._handle))
57
64
 
58
65
  @property
59
66
  def is_signaling_nan(self) -> bool:
67
+ self._ensure_open()
60
68
  return bool(self._library._lib.overfloat_number_is_signaling_nan(self._handle))
61
69
 
62
70
  @property
63
71
  def nan_payload(self) -> int:
72
+ self._ensure_open()
64
73
  payload = self._library._call_string_function(self._library._lib.overfloat_number_nan_payload_format, self._handle)
65
74
  return int(payload) if payload else 0
66
75
 
67
76
  def to_bits_hex(self) -> str:
77
+ self._ensure_open()
68
78
  return self._library._call_string_function(self._library._lib.overfloat_number_to_bits_hex, self._handle)
69
79
 
70
80
  def compare(self, other: NumberLike) -> int:
81
+ self._ensure_open()
71
82
  coerced = self._coerce_other(other)
72
83
  result = int(self._library._lib.overfloat_number_compare(self._handle, coerced._handle))
73
84
  if result == 2:
@@ -77,6 +88,7 @@ class OverfloatNumber:
77
88
  return result
78
89
 
79
90
  def compare_total(self, other: NumberLike) -> int:
91
+ self._ensure_open()
80
92
  coerced = self._coerce_other(other)
81
93
  result = int(self._library._lib.overfloat_number_compare_total(self._handle, coerced._handle))
82
94
  if result == -2147483648:
@@ -87,6 +99,7 @@ class OverfloatNumber:
87
99
  return self._specification.number(other)
88
100
 
89
101
  def add(self, other: NumberLike) -> "OverfloatNumber":
102
+ self._ensure_open()
90
103
  coerced = self._coerce_other(other)
91
104
  return self._library._wrap_number(
92
105
  self._library._lib.overfloat_number_add(self._handle, coerced._handle),
@@ -94,6 +107,7 @@ class OverfloatNumber:
94
107
  )
95
108
 
96
109
  def subtract(self, other: NumberLike) -> "OverfloatNumber":
110
+ self._ensure_open()
97
111
  coerced = self._coerce_other(other)
98
112
  return self._library._wrap_number(
99
113
  self._library._lib.overfloat_number_subtract(self._handle, coerced._handle),
@@ -101,6 +115,7 @@ class OverfloatNumber:
101
115
  )
102
116
 
103
117
  def multiply(self, other: NumberLike) -> "OverfloatNumber":
118
+ self._ensure_open()
104
119
  coerced = self._coerce_other(other)
105
120
  return self._library._wrap_number(
106
121
  self._library._lib.overfloat_number_multiply(self._handle, coerced._handle),
@@ -108,6 +123,7 @@ class OverfloatNumber:
108
123
  )
109
124
 
110
125
  def divide(self, other: NumberLike) -> "OverfloatNumber":
126
+ self._ensure_open()
111
127
  coerced = self._coerce_other(other)
112
128
  return self._library._wrap_number(
113
129
  self._library._lib.overfloat_number_divide(self._handle, coerced._handle),
@@ -126,6 +142,7 @@ class OverfloatNumber:
126
142
  self.close()
127
143
 
128
144
  def __str__(self) -> str:
145
+ self._ensure_open()
129
146
  required = int(self._library._lib.overfloat_number_format(self._handle, None, 0))
130
147
  if required <= 0:
131
148
  raise OverfloatError("Unable to format number.")
@@ -209,28 +226,39 @@ class OverfloatSpec:
209
226
  self._library = library
210
227
  self._handle = handle
211
228
 
229
+ def _ensure_open(self) -> None:
230
+ if not self._handle:
231
+ raise OverfloatError("Cannot use a closed OverfloatSpec.")
232
+
212
233
  @property
213
234
  def exponent_bits(self) -> int:
235
+ self._ensure_open()
214
236
  return int(self._library._lib.overfloat_spec_exponent_bits(self._handle))
215
237
 
216
238
  @property
217
239
  def mantissa_bits(self) -> int:
240
+ self._ensure_open()
218
241
  return int(self._library._lib.overfloat_spec_mantissa_bits(self._handle))
219
242
 
220
243
  @property
221
244
  def rounding_mode(self) -> int:
245
+ self._ensure_open()
222
246
  return int(self._library._lib.overfloat_spec_rounding_mode(self._handle))
223
247
 
224
248
  def parse(self, text: str) -> OverfloatNumber:
249
+ self._ensure_open()
225
250
  handle = self._library._lib.overfloat_number_parse(self._handle, text.encode("utf-8"))
226
251
  return self._library._wrap_number(handle, self)
227
252
 
228
253
  def from_bits_hex(self, hex_text: str) -> OverfloatNumber:
254
+ self._ensure_open()
229
255
  handle = self._library._lib.overfloat_number_from_bits_hex(self._handle, hex_text.encode("utf-8"))
230
256
  return self._library._wrap_number(handle, self)
231
257
 
232
258
  def number(self, value: NumberLike) -> OverfloatNumber:
259
+ self._ensure_open()
233
260
  if isinstance(value, OverfloatNumber):
261
+ value._ensure_open()
234
262
  if value.specification._handle != self._handle:
235
263
  raise OverfloatError("Cannot mix numbers from different specifications.")
236
264
  return value
@@ -270,7 +298,8 @@ class OverfloatLibrary:
270
298
  def __init__(self, library_path: str | Path | None = None) -> None:
271
299
  if library_path is None:
272
300
  library_path = self._default_library_path()
273
- self._lib = CDLL(str(library_path))
301
+ self._library_path = Path(library_path)
302
+ self._lib = CDLL(str(self._library_path))
274
303
  self._configure()
275
304
 
276
305
  def _configure(self) -> None:
@@ -348,7 +377,11 @@ class OverfloatLibrary:
348
377
  for candidate in candidates:
349
378
  if candidate.exists():
350
379
  return candidate
351
- raise FileNotFoundError("Could not locate the bundled Overfloat native library.")
380
+ searched = ", ".join(str(candidate) for candidate in candidates)
381
+ raise FileNotFoundError(
382
+ "Could not locate the bundled Overfloat native library. "
383
+ f"Searched: {searched}. Pass an explicit library path to OverfloatLibrary(...)."
384
+ )
352
385
 
353
386
  def _wrap_number(self, handle: int, specification: OverfloatSpec) -> OverfloatNumber:
354
387
  if not handle:
@@ -381,3 +414,7 @@ class OverfloatLibrary:
381
414
  if not handle:
382
415
  raise OverfloatError("Unable to create specification from total bit width.")
383
416
  return OverfloatSpec(self, int(handle))
417
+
418
+ def __repr__(self) -> str:
419
+ version = ".".join(str(part) for part in self.version)
420
+ return f"OverfloatLibrary(version={version!r}, path={str(self._library_path)!r})"
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: overfloat
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Python bindings for the Overfloat native floating-point runtime
5
5
  Author: Overfloat Contributors
6
6
  License-Expression: Apache-2.0
7
- Project-URL: Homepage, https://github.com/overfloat/overfloat
8
- Project-URL: Repository, https://github.com/overfloat/overfloat
9
- Project-URL: Issues, https://github.com/overfloat/overfloat/issues
7
+ Project-URL: Homepage, https://github.com/MontyChan/Overfloat
8
+ Project-URL: Repository, https://github.com/MontyChan/Overfloat
9
+ Project-URL: Issues, https://github.com/MontyChan/Overfloat/issues
10
10
  Keywords: floating-point,ieee-754,native,ctypes,arbitrary-precision
11
11
  Classifier: Development Status :: 3 - Alpha
12
12
  Classifier: Intended Audience :: Developers
@@ -28,9 +28,9 @@ classifiers = [
28
28
  ]
29
29
 
30
30
  [project.urls]
31
- Homepage = "https://github.com/overfloat/overfloat"
32
- Repository = "https://github.com/overfloat/overfloat"
33
- Issues = "https://github.com/overfloat/overfloat/issues"
31
+ Homepage = "https://github.com/MontyChan/Overfloat"
32
+ Repository = "https://github.com/MontyChan/Overfloat"
33
+ Issues = "https://github.com/MontyChan/Overfloat/issues"
34
34
 
35
35
  [tool.setuptools]
36
36
  packages = ["overfloat"]
@@ -1 +0,0 @@
1
- 0.1.2
File without changes
File without changes
File without changes
File without changes