PsyNeuLink icon indicating copy to clipboard operation
PsyNeuLink copied to clipboard

Failures in mdf test using numpy 1.25+

Open jvesely opened this issue 1 year ago • 1 comments

Probably related to 60a858a372b14b73547baacf4a472eccfade1073, similar to compiled failures addressed in 89f26a83c86b7a5333436b74186520ba2abc2b34.

Looking at the generated json structures there's a difference in the value of "combine_costs" parameter. numpy 1.24:

"combine_costs": "gASVEQAAAAAAAACMBW51bXB5lIwDc3VtlJOULg==\n",

numpy 1.25:

"combine_costs": "<function sum at 0x7fba7259df80>",

EDIT: which leads to failures when reconstructing the PNL model:

_ test_get_mdf_serialized_results_equivalence_pnl_only[model_with_control.py-comp-{Input: [0.5, 0.123], reward: [20, 20]}-False] _
[gw3] linux -- Python 3.9.18 /home/runner/work/_temp/_venv/bin/python
filename = 'model_with_control.py', composition_name = 'comp'
input_dict_str = '{Input: [0.5, 0.123], reward: [20, 20]}'
simple_edge_format = False

    @pytest.mark.parametrize(
        'filename, composition_name, input_dict_str, simple_edge_format',
        pnl_mdf_results_parametrization
    )
    def test_get_mdf_serialized_results_equivalence_pnl_only(
        filename,
        composition_name,
        input_dict_str,
        simple_edge_format,
    ):
        comp_inputs = {composition_name: input_dict_str}
    
        # Get python script from file and execute
        orig_script = read_defined_model_script(filename)
        orig_results, orig_globals, orig_locals = get_model_results_and_state(
            orig_script, comp_inputs
        )
    
        # reset random seed
        pnl.core.globals.utilities.set_global_seed(0)
        # Generate python script from MDF serialization of composition and execute
        mdf_data = pnl.get_mdf_serialized(
            eval(f'{composition_name}', orig_globals, orig_locals),
            simple_edge_format=simple_edge_format
        )
        new_script = pnl.generate_script_from_mdf(mdf_data)
>       new_results, _, _ = get_model_results_and_state(new_script, comp_inputs)

tests/mdf/test_mdf.py:179: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/mdf/test_mdf.py:135: in get_model_results_and_state
    _globals, _locals = get_loaded_model_state(model_input)
tests/mdf/test_mdf.py:115: in get_loaded_model_state
    exec(model_input, _globals, _locals)
<string>:16: in <module>
    ???
psyneulink/core/globals/context.py:742: in wrapper
    return func(*args, context=context, **kwargs)
psyneulink/core/compositions/composition.py:9320: in add_controller
    controller._deferred_init(context=context)
psyneulink/core/components/component.py:1822: in _deferred_init
    super(self.__class__,self).__init__(**self._init_args)
psyneulink/core/globals/parameters.py:486: in check_user_specified_wrapper
    return func(self, *args, **orig_kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

__beartype_object_140081829419264 = (<class 'NoneType'>, <class 'psyneulink.core.components.shellclasses.Mechanism'>, <class 'psyneulink.core.components.ports.outputport.OutputPort'>, <class 'collections.abc.Iterable'>)
__beartype_get_violation = <function get_func_pith_violation at 0x7f680bd7b040>
__beartype_conf = BeartypeConf()
__beartype_object_140085193782400 = <class 'NoneType'>
__beartype_object_140085135094320 = 'concatenate'
__beartype_object_140085149546096 = 'combine'
__beartype_object_140084851640752 = 'separate'
__beartype_object_14008498[91](https://github.com/PrincetonUniversity/PsyNeuLink/actions/runs/7833247864/job/21373857551?pr=2906#step:12:92)82176 = (<class 'int'>, <class 'list'>, <class 'NoneType'>, <class 'float'>, <class 'numpy.ndarray'>)
__beartype_object_1400818290864[96](https://github.com/PrincetonUniversity/PsyNeuLink/actions/runs/7833247864/job/21373857551?pr=2906#step:12:97) = (<class 'psyneulink.core.components.ports.parameterport.ParameterPort'>, <class 'NoneType'>, <class 'collections.abc.I...yneulink.core.components.ports.outputport.OutputPort'>, <class 'psyneulink.core.components.ports.inputport.InputPort'>)
__beartype_object_140085008303232 = (<class 'str'>, <class 'NoneType'>)
__beartype_object_1400848284[98](https://github.com/PrincetonUniversity/PsyNeuLink/actions/runs/7833247864/job/21373857551?pr=2906#step:12:99)[112](https://github.com/PrincetonUniversity/PsyNeuLink/actions/runs/7833247864/job/21373857551?pr=2906#step:12:113) = (<class 'NoneType'>, <class 'collections.abc.Callable'>)
__beartype_object_[140](https://github.com/PrincetonUniversity/PsyNeuLink/actions/runs/7833247864/job/21373857551?pr=2906#step:12:141)081867904768 = (<class 'NoneType'>, <class 'psyneulink.core.globals.preferences.basepreferenceset.BasePreferenceSet'>)

>   ???
E   beartype.roar.BeartypeCallHintParamViolation: Method psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.__init__() parameter combine_costs='<function sum at 0x7f681c362040>' violates type hint typing.Optional[collections.abc.Callable], as str '<function sum at 0x7f681c362040>' not <class "builtins.NoneType"> or <protocol ABC "collections.abc.Callable">.

<@beartype(psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.__init__) at 0x7f6757a90af0>:180: BeartypeCallHintParamViolation

jvesely avatar Feb 09 '24 00:02 jvesely

cc @kmantel

jvesely avatar Feb 09 '24 00:02 jvesely