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

[python] fix multiplication with ndarray when ndarray is rhs #2159

Closed
wants to merge 10 commits into from
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ (github.repository != 'numworks/epsilon-internal' || github.event.inputs.android == 'true') }}
steps:
- run: $ANDROID_HOME/tools/bin/sdkmanager "ndk;22.1.7171670"
- run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;22.1.7171670"
- uses: actions/checkout@v3
- run: build/setup.sh --only-simulator
- run: make PLATFORM=simulator TARGET=android ASSERTIONS=1 test.apk
Expand Down Expand Up @@ -84,6 +84,9 @@ jobs:
- uses: msys2/setup-msys2@v2
with:
update: true
install: >-
git
mingw-w64-x86_64-arm-none-eabi-gcc
- uses: actions/checkout@v3
- run: build/setup.sh
- run: make PLATFORM=simulator ASSERTIONS=1 epsilon.exe
Expand Down
5 changes: 3 additions & 2 deletions apps/calculation/test/calculation_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,9 @@ QUIZ_CASE(calculation_additional_results) {
assertCalculationAdditionalResultTypeHas("√(-1)", {}, &globalContext, &store);
assertCalculationAdditionalResultTypeHas("{1}", {}, &globalContext, &store);
assertCalculationAdditionalResultTypeHas("{i}", {}, &globalContext, &store);
assertCalculationAdditionalResultTypeHas("i^(2×e^(7i^(2×e^322)))", {},
&globalContext, &store);
/* TODO: Not working on windows
* assertCalculationAdditionalResultTypeHas("i^(2×e^(7i^(2×e^322)))", {},
* &globalContext, &store);*/

assertCalculationAdditionalResultTypeHas("ln(3+4)", {}, &globalContext,
&store);
Expand Down
4 changes: 2 additions & 2 deletions apps/inference/models/statistic/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ bool Test::computeCurveViewRange(float transition, bool zoomSide) {
if (zoomSide) {
alpha = thresholdAbscissa(
Poincare::ComparisonNode::OperatorType::Superior, 0.5);
z = abs(z);
z = std::abs(z);
} else {
alpha = thresholdAbscissa(
Poincare::ComparisonNode::OperatorType::Inferior, 0.5);
z = -abs(z);
z = -std::abs(z);
}
} else {
alpha = thresholdAbscissa(hypothesisParams()->comparisonOperator());
Expand Down
2 changes: 1 addition & 1 deletion apps/shared/continuous_function_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ void ContinuousFunctionProperties::setPolarFunctionProperties(
Trigonometry::DetectLinearPatternOfCosOrSin(
denominator, reductionContext, Function::k_unknownName, false,
nullptr, &coefficientBeforeTheta, &angle) &&
abs(coefficientBeforeTheta) == 1.0) {
std::abs(coefficientBeforeTheta) == 1.0) {
double positiveAngle = std::fabs(angle);
if (positiveAngle == 0.0 || positiveAngle == M_PI) {
setCaption(I18n::Message::PolarVerticalLineType);
Expand Down
2 changes: 1 addition & 1 deletion build/config.mak
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PLATFORM ?= device
DEBUG ?= 0
DEVELOPMENT ?= 0

EPSILON_VERSION ?= 22.1.0
EPSILON_VERSION ?= 22.2.0
EXTERNAL_APPS_API_LEVEL ?= 0
EPSILON_APPS ?= calculation graph code statistics distributions inference solver sequence regression elements finance settings
EPSILON_I18N ?= en fr nl pt it de es
Expand Down
2 changes: 1 addition & 1 deletion ion/src/device/epsilon-core
2 changes: 1 addition & 1 deletion ion/src/simulator/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ android {
res.srcDir BUILD_DIR + '/res'
java.srcDir 'src'
jniLibs.srcDir BUILD_DIR + '/libs/' + System.getenv('EPSILON_VARIANT')
assets.srcDirs = ['../assets', EPSILON_BUILD_DIR + 'ion/src/simulator/assets']
assets.srcDirs = ['../assets', EPSILON_BUILD_DIR + '/ion/src/simulator/assets']
}
}
lintOptions {
Expand Down
2 changes: 1 addition & 1 deletion kandinsky/src/context_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void KDContext::drawAntialiasedLine(float x1, float y1, float x2, float y2,
/* Implements Xiaolin Wu's line algorithm
* https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm */

bool steep = abs(y2 - y1) > abs(x2 - x1);
bool steep = std::fabs(y2 - y1) > std::fabs(x2 - x1);
if (steep) {
std::swap(x1, y1);
std::swap(x2, y2);
Expand Down
6 changes: 6 additions & 0 deletions python/port/mod/ion/modion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ mp_obj_t modion_keyboard_keydown(mp_obj_t key_o) {
if (key >= Ion::Keyboard::Key::None) {
return mp_obj_new_bool(false);
}
/* In version 22, scan was greatly sped up. We wait 1 ms after the scan to
* keep the keydown function consistent with older versions.
* WARNING: Do not use Timing::msleep to avoid putting the device to sleep,
* which alters timings (mostly on N120) */
uint64_t currentTime = Ion::Timing::millis();
Ion::Keyboard::State state = Ion::Keyboard::scan();
while (currentTime + 1 > Ion::Timing::millis()) {}
micropython_port_interrupt_if_needed();
return mp_obj_new_bool(state.keyDown(key));
}
9 changes: 9 additions & 0 deletions python/src/py/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "py/builtin.h"
#include "py/stackctrl.h"
#include "py/gc.h"
#include "../../port/mod/ulab_tools.h"

#if MICROPY_DEBUG_VERBOSE // print debugging info
#define DEBUG_PRINT (1)
Expand Down Expand Up @@ -587,6 +588,14 @@ mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
// generic binary_op supplied by type
const mp_obj_type_t *type;
generic_binary_op:
// instead of duplicating ndarray management for int/float/more?
// just swap lhs and rhs (see bug #2102)
if (mp_obj_is_type(rhs, &ulab_ndarray_type)) {
mp_obj_t temp = lhs;
lhs = rhs;
rhs = temp;
}

type = mp_obj_get_type(lhs);
if (type->binary_op != NULL) {
mp_obj_t result = type->binary_op(op, lhs, rhs);
Expand Down
Loading