Skip to content
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

test failures when using numpy==1.17.5 #2581

Closed
jvesely opened this issue Jan 14, 2023 · 5 comments
Closed

test failures when using numpy==1.17.5 #2581

jvesely opened this issue Jan 14, 2023 · 5 comments

Comments

@jvesely
Copy link
Collaborator

jvesely commented Jan 14, 2023

pnl sets minimum numpy requirements as >=1.17.0, but the test suite fails with 18 errors:

FAILED tests/composition/test_composition.py::TestExecutionOrder::test_exact_time - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_no_dependencies[conditions0-termination_conds0] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions4-termination_conds4] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_no_dependencies[conditions2-termination_conds2] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions1-termination_conds1] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions2-termination_conds2] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions0-termination_conds0] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions5-termination_conds5] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions3-termination_conds3] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_condition.py::TestAbsolute::test_TimeInterval_linear_everynms[conditions6-termination_conds6] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions3-interval3] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions1-interval1] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions6-interval6] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions0-interval0] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions7-interval7] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions5-interval5] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions4-interval4] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd
FAILED tests/scheduling/test_scheduler.py::TestAbsoluteTime::test_absolute_interval_linear[conditions2-interval2] - TypeError: No loop matching the specified signature and casting was found for ufunc gcd

the backtrace is similar:

_______________________ TestAbsoluteTime.test_absolute_interval_linear[conditions2-interval2] ________________________
[gw4] linux -- Python 3.8.10 /common/home/jv356/py38-venv/bin/python3

self = <test_scheduler.TestAbsoluteTime object at 0x7fd51e35f6a0>
three_node_linear_composition = ([(TransferMechanism A), (TransferMechanism B), (TransferMechanism C)], (Composition Composition-0))
conditions = {'A': <psyneulink.core.scheduling.condition.Any object at 0x7fd51e3cd820>}
interval = <Quantity(1/3, 'millisecond')>

    @pytest.mark.parametrize(
        'conditions, interval',
        [
            ({'A': TimeInterval(repeat=8), 'B': TimeInterval(repeat=4)}, fractions.Fraction(4, 3) * _unit_registry.ms),
            ({'A': TimeInterval(repeat=1), 'B': TimeInterval(repeat=3)}, fractions.Fraction(1, 3) * _unit_registry.ms),
            ({'A': Any(TimeInterval(repeat=2), TimeInterval(repeat=3))}, fractions.Fraction(1, 3) * _unit_registry.ms),
            ({'A': TimeInterval(repeat=6), 'B': TimeInterval(repeat=3)}, 1 * _unit_registry.ms),
            ({'A': TimeInterval(repeat=100 * _unit_registry.us), 'B': TimeInterval(repeat=2)}, fractions.Fraction(100, 3) * _unit_registry.us),
            ({'A': Any(TimeInterval(repeat=1000 * _unit_registry.us), TimeInterval(repeat=2))}, fractions.Fraction(1, 3) * _unit_registry.ms),
            ({'A': TimeInterval(repeat=1000 * _unit_registry.us), 'B': TimeInterval(repeat=2)}, fractions.Fraction(1, 3) * _unit_registry.ms),
            ({'A': Any(TimeInterval(repeat=1000), TimeInterval(repeat=1500)), 'B': TimeInterval(repeat=2000)}, fractions.Fraction(500, 3) * _unit_registry.ms),
        ]
    )
    def test_absolute_interval_linear(self, three_node_linear_composition, conditions, interval):
        [A, B, C], comp = three_node_linear_composition
    
        for node in conditions:
            comp.scheduler.add_condition(eval(node), conditions[node])
    
>       assert comp.scheduler._get_absolute_consideration_set_execution_unit() == interval

tests/scheduling/test_scheduler.py:1690: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <psyneulink.core.scheduling.scheduler.Scheduler object at 0x7fd51d08a100>
termination_conds = {<TimeScale.ENVIRONMENT_STATE_UPDATE: 2>: <psyneulink.core.scheduling.condition.AllHaveRun object at 0x7fd51d08a1c0>, <TimeScale.ENVIRONMENT_SEQUENCE: 3>: <psyneulink.core.scheduling.condition.Never object at 0x7fd51d08af40>}

    def _get_absolute_consideration_set_execution_unit(self, termination_conds=None):
        """Computes the time length of the gap between two consideration set executions
        """
        if termination_conds is None:
            termination_conds = self.termination_conds
    
        # all of the units of time that must occur on a consideration set execution
        intervals = []
        for c in self.get_absolute_conditions(termination_conds).values():
            intervals.extend(c.absolute_intervals)
            if self.mode is SchedulingMode.EXACT_TIME:
                intervals.extend(c.absolute_fixed_points)
    
        if len(intervals) == 0:
            return self.default_absolute_time_unit
        else:
            min_time_unit = min(intervals, key=lambda x: x.u).u
    
            # convert all intervals into the same unit
            for i, a in enumerate(intervals):
                unit_conversion = round(np.log10((1 * a.u).to(min_time_unit).m))
                intervals[i] = (int(a.m) * 10 ** unit_conversion) * min_time_unit
    
            # numerator is the largest possible length of a pass
            # denominator evenly divides this length by number of consideration set executions
>           numerator = np.gcd.reduce([interval.m for interval in intervals])
E           TypeError: No loop matching the specified signature and casting was found for ufunc gcd

../py38-venv/lib/python3.8/site-packages/graph_scheduler/scheduler.py:874: TypeError
@jvesely
Copy link
Collaborator Author

jvesely commented Jan 14, 2023

This is mostly for documentation purposes, I think we should bump minimum requirements until the tests pass.

@jvesely
Copy link
Collaborator Author

jvesely commented Jan 14, 2023

same failures with 1.18.5

@jvesely
Copy link
Collaborator Author

jvesely commented Jan 14, 2023

tests pass with numpy==1.19.5

jvesely added a commit to jvesely/PsyNeuLink that referenced this issue Jan 14, 2023
Calling gcd on list comprehension fails on <1.19.0

Closes: PrincetonUniversity#2581

Signed-off-by: Jan Vesely <[email protected]>
@jvesely
Copy link
Collaborator Author

jvesely commented Jan 14, 2023

numpy==1.19.0 pass

jvesely added a commit that referenced this issue Jan 14, 2023
Calling gcd on list comprehension fails on <1.19.0

Closes: #2581

Signed-off-by: Jan Vesely <[email protected]>
@jvesely
Copy link
Collaborator Author

jvesely commented Apr 7, 2023

this was addressed in c1592c1

@jvesely jvesely closed this as completed Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant