From 63dd47a5ec32d9de32891ceefd9950bc345da556 Mon Sep 17 00:00:00 2001 From: lucaferranti Date: Wed, 18 Sep 2024 21:18:52 +0300 Subject: [PATCH] fix bug in zshape and sshape FMs code generation --- Project.toml | 2 +- docs/src/changelog.md | 1 + src/tojulia.jl | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index ee1a5ba..3ab2cb7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FuzzyLogic" uuid = "271df9f8-4390-4196-9d4f-bdd0b67035b3" authors = ["Luca Ferranti"] -version = "0.1.2" +version = "0.1.3" [deps] Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" diff --git a/docs/src/changelog.md b/docs/src/changelog.md index 710bbfd..38a1b7a 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +- ![](https://img.shields.io/badge/bugfix-purple.svg) fix bug in Julia code generation of ZShape and SShape mf - ![](https://img.shields.io/badge/bugfix-purple.svg) disallow implicit conversion from interval to float - ![](https://img.shields.io/badge/new%20feature-green.svg) added semi-elliptic and singleton membership functions - ![](https://img.shields.io/badge/new%20feature-green.svg) added `gensurf` to plot generating surface diff --git a/src/tojulia.jl b/src/tojulia.jl index 7ee436f..0b46706 100644 --- a/src/tojulia.jl +++ b/src/tojulia.jl @@ -160,7 +160,7 @@ end function to_expr(s::SShapeMF, x = :x) :(if $x <= $(s.a) - zero(float($(typeof(x)))) + zero(float(typeof($x))) elseif $x >= $(s.b) one(float(typeof($x))) elseif $x >= $((s.a + s.b) / 2) @@ -172,7 +172,7 @@ end function to_expr(mf::ZShapeMF, x = :x) :(if $x <= $(mf.a) - one(float($(typeof(x)))) + one(float(typeof($x))) elseif $x >= $(mf.b) zero(float(typeof($x))) elseif $x >= $((mf.a + mf.b) / 2)