For Task 1.2, I believe the intended code for scalar.Scalar.__sub__is return Add.apply(self, -b), which passes the tests. Interestingly, if return Add.apply(self, Neg.apply(b)) is used, the tests that involve subtracting constants fail. Excerpt of the failed test cases below:
===============================short test summary info==============================
FAILED tests/test_scalar.py::test_one_args[fn4] - AssertionError: Expected return typ <class 'float'> got <class 'int'>: -200
FAILED tests/test_scalar.py::test_one_args[fn5] - AssertionError: Expected return typ <class 'float'> got <class 'int'>: -200
FAILED tests/test_scalar.py::test_one_args[fn13] - AssertionError: Expected return typ <class 'float'> got <class 'int'>: -5
I've slightly modified the error message in autodiff.FunctionBase to print the offending value in question, and they are all ints. The root cause is due to scalar.ScalarFunction.data_type being hard-coded as float. I assume data_type is fixed for a reason, and there probably isn't an easy fix to allow the alternate solution to pass the tests. Just thought y'all should know.
For Task 1.2, I believe the intended code for
scalar.Scalar.__sub__isreturn Add.apply(self, -b), which passes the tests. Interestingly, ifreturn Add.apply(self, Neg.apply(b))is used, the tests that involve subtracting constants fail. Excerpt of the failed test cases below:I've slightly modified the error message in
autodiff.FunctionBaseto print the offending value in question, and they are all ints. The root cause is due toscalar.ScalarFunction.data_typebeing hard-coded asfloat. I assumedata_typeis fixed for a reason, and there probably isn't an easy fix to allow the alternate solution to pass the tests. Just thought y'all should know.