Skip to content

Commit

Permalink
Use 3.10 with cython
Browse files Browse the repository at this point in the history
3.11 seems to use to require more stringent cython.

While this is a good thing. Right now we should focus on one issue at a
time.

The issue here is TOM, not 3.11 Cython stringencies
  • Loading branch information
rocky committed Mar 11, 2024
1 parent 4dd2f0e commit ca74baf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-cython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.10']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 4 additions & 3 deletions mathics/core/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,9 @@ def __neg__(self) -> "PrecisionReal":
def do_copy(self) -> "PrecisionReal":
return PrecisionReal(self.value)

def get_precision(self) -> float:
def get_precision(self) -> int:
"""Returns the default specification for precision (in binary digits) in N and other numerical functions."""
return self.value._prec + 1.0
return self.value._prec + 1

@property
def is_zero(self) -> bool:
Expand Down Expand Up @@ -801,6 +801,7 @@ def is_machine_precision(self) -> bool:
return True
return False

# FIXME: funny name get_float_value returns complex?
def get_float_value(self, permit_complex=False) -> Optional[complex]:
if permit_complex:
real = self.real.get_float_value()
Expand All @@ -810,7 +811,7 @@ def get_float_value(self, permit_complex=False) -> Optional[complex]:
else:
return None

def get_precision(self) -> Optional[float]:
def get_precision(self) -> Optional[int]:
"""Returns the default specification for precision in N and other numerical functions.
When `None` is be returned no precision is has been defined and this object's value is
exact.
Expand Down
2 changes: 1 addition & 1 deletion mathics/core/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _get_float_inf(value, evaluation) -> Optional[float]:

def get_precision(
value: BaseElement, evaluation, show_messages: bool = True
) -> Optional[float]:
) -> Optional[int]:
"""
Returns the ``float`` in the interval [``$MinPrecision``, ``$MaxPrecision``] closest
to ``value``.
Expand Down
8 changes: 6 additions & 2 deletions mathics/core/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

import time
from typing import Any, FrozenSet, List, Optional
from typing import Any, FrozenSet, List, Optional, Union

from mathics.core.element import (
BaseElement,
Expand Down Expand Up @@ -830,7 +830,11 @@ def __floordiv__(self, other) -> BaseElement:
def __pow__(self, other) -> BaseElement:
return self.create_expression(SymbolPower, self, other)

def round_to_float(self, evaluation=None, permit_complex=False) -> Optional[float]:
# FIXME: The name "round_to_float" is misleading when
# permit_complex is True.
def round_to_float(
self, evaluation=None, permit_complex=False
) -> Optional[Union[complex | float]]:
"""
Round to a Python float. Return None if rounding is not possible.
This can happen if self or evaluation is NaN.
Expand Down

0 comments on commit ca74baf

Please sign in to comment.