STEllAR-GROUP / phylanx

An Asynchronous Distributed C++ Array Processing Toolkit
Boost Software License 1.0
75 stars 76 forks source link

`astype` does not work with `define` #1157

Closed taless474 closed 4 years ago

taless474 commented 4 years ago

Although astype([1, 0, 1], "bool") works properly, the following code (in physl) fails in an assertion:

define(a, [1, 0, 1])
astype(a, "bool")
{version}: V1.5.0-trunk (AGAS: V3.0), Git: 6df8ceca6a
{boost}: V1.72.0
{build-type}: debug
{date}: Apr 27 2020 22:02:32
{platform}: Win32
{compiler}: Microsoft Visual C++ version 14.1
{stdlib}: Dinkumware standard library version 650
{env}: 51 entries:
  ALLUSERSPROFILE=C:\ProgramData
  APPDATA=C:\Users\Bita\AppData\Roaming
  COMPUTERNAME=UNICK
  ComSpec=C:\Windows\system32\cmd.exe
  CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
  CommonProgramFiles=C:\Program Files\Common Files
  CommonProgramW6432=C:\Program Files\Common Files
  DriverData=C:\Windows\System32\Drivers\DriverData
  FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
  FPS_BROWSER_USER_PROFILE_STRING=Default
  HOMEDRIVE=C:
  HOMEPATH=\Users\Bita
  LOCALAPPDATA=C:\Users\Bita\AppData\Local
  LOGONSERVER=\\UNICK
  MSBuildLoadMicrosoftTargetsReadOnly=true
  MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\
  NUMBER_OF_PROCESSORS=48
  OS=Windows_NT
  OneDrive=C:\Users\Bita\OneDrive
  PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
  PROCESSOR_ARCHITECTURE=AMD64
  PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
  PROCESSOR_LEVEL=6
  PROCESSOR_REVISION=5504
  PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
  PUBLIC=C:\Users\Public
  PYTHONPATH=C:/Repos/phylanx/cmake-build-debug/python/build/lib.win-amd64-3.6
  Path=C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Git\cmd;C:\Repos\vcpkg\downloads\tools\cmake-3.14.0-windows\cmake-3.14.0-win32-x86\bin;C:\local\SysinternalsSuite;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts;C:\Program Files\LLVM\bin;C:\Program Files\TortoiseGit\bin;C:\Users\Bita\AppData\Local\Microsoft\WindowsApps;
  PkgDefApplicationConfigFile=C:\Users\Bita\AppData\Local\Microsoft\VisualStudio\15.0_e0d0c2e3\devenv.exe.config
  ProgramData=C:\ProgramData
  ProgramFiles(x86)=C:\Program Files (x86)
  ProgramFiles=C:\Program Files
  ProgramW6432=C:\Program Files
  SESSIONNAME=Console
  SystemDrive=C:
  SystemRoot=C:\Windows
  TEMP=C:\Users\Bita\AppData\Local\Temp
  TMP=C:\Users\Bita\AppData\Local\Temp
  USERDOMAIN=UNICK
  USERDOMAIN_ROAMINGPROFILE=UNICK
  USERNAME=Bita
  USERPROFILE=C:\Users\Bita
  VSAPPIDDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\
  VSAPPIDNAME=devenv.exe
  VSLANG=1033
  VSSKUEDITION=Community
  VisualStudioDir=C:\Users\Bita\Documents\Visual Studio 2017
  VisualStudioEdition=Microsoft Visual Studio Community 2017
  VisualStudioVersion=15.0
  _PTVS_PID=14436
  windir=C:\Windows
{stack-trace}: 20 frames:
00007FFA3CEFBA17: hpx::util::stack_trace::trace +0x37
00007FFA3C3D9599: hpx::util::backtrace::backtrace +0x99
00007FFA3C3B9D38: hpx::util::trace_on_new_stack +0x88
00007FFA3C3B7F4F: hpx::detail::custom_exception_info +0x7f
00007FFA3C42C789: std::_Invoker_functor::_Call<hpx::exception_info (__cdecl*&)(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &),std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &> +0xb9
00007FFA3C44EE78: std::invoke<hpx::exception_info (__cdecl*&)(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &),std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &> +0xb8
00007FFA3C42C678: std::_Invoker_ret<hpx::exception_info,0>::_Call<hpx::exception_info (__cdecl*&)(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &),std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &> +0xb8
00007FFA3C47C797: std::_Func_impl_no_alloc<hpx::exception_info (__cdecl*)(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &),hpx::exception_info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &>::_Do_call +0xa7
00007FFA3CF094FB: std::_Func_class<hpx::exception_info,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,long,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &>::operator() +0xdb
00007FFA3CF025F6: hpx::detail::construct_custom_exception<hpx::exception> +0xf6
00007FFA3CF06ED4: hpx::detail::get_exception<hpx::exception> +0xa4
00007FFA3CD4C779: hpx::detail::assertion_handler +0x1c9
00007FFA3CE3FBD4: hpx::assertion::detail::handle_assert +0xf4
00007FFA3E7CE71B: phylanx::execution_tree::eval_context::get_var +0xab
00007FFA3E7CFC7B: phylanx::execution_tree::primitives::access_variable::eval +0x7b
00007FFA3F3E8719: phylanx::execution_tree::primitives::primitive_component_base::do_eval +0x159
00007FFA3F3B59FD: phylanx::execution_tree::primitives::primitive_component::eval +0x1ed
00007FFA3E94D150: hpx::actions::detail::component_invoke<phylanx::execution_tree::primitives::primitive_component const ,hpx::lcos::future<phylanx::execution_tree::primitive_argument_type>,hpx::lcos::future<phylanx::execution_tree::primitive_argument_type> __cdecl(std::vector<phylanx::execution_tree::primitive_argument_type,std::allocator<phylanx::execution_tree::primitive_argument_type> > const &,phylanx::execution_tree::eval_context)const ,std::vector<phylanx::execution_tree::primitive_argument_type,std::allocator<phylanx::execution_tree::primitive_argument_type> > const &,phylanx::execution_tree::eval_context> +0xf0
00007FFA3E98F5BD: hpx::actions::action<hpx::lcos::future<phylanx::execution_tree::primitive_argument_type> (__cdecl phylanx::execution_tree::primitives::primitive_component::*)(std::vector<phylanx::execution_tree::primitive_argument_type,std::allocator<phylanx::execution_tree::primitive_argument_type> > const &,phylanx::execution_tree::eval_context)const ,&phylanx::execution_tree::primitives::primitive_component::eval,phylanx::execution_tree::primitives::primitive_component::eval_action>::invoke<std::vector<phylanx::execution_tree::primitive_argument_type,std::allocator<phylanx::execution_tree::primitive_argument_type> > const &,phylanx::execution_tree::eval_context> +0xbd
00007FFA3E9A27FB: hpx::actions::basic_action<phylanx::execution_tree::primitives::primitive_component const ,hpx::lcos::future<phylanx::execution_tree::primitive_argument_type> __cdecl(std::vector<phylanx::execution_tree::primitive_argument_type,std::allocator<phylanx::execution_tree::primitive_argument_type> > const &,phylanx::execution_tree::eval_context),phylanx::execution_tree::primitives::primitive_component::eval_action>::invoker_impl<std::vector<phylanx::execution_tree::primitive_argument_type,std::allocator<phylanx::execution_tree::primitive_argument_type> > const &,phylanx::execution_tree::eval_context> +0x7b
{locality-id}: 0
{hostname}: [ ]
{process-id}: 7220
{os-thread}: 0, worker-thread#0
{thread-id}: 000000004ba7b350
{thread-description}: hpx_main
{state}: state_running
{auxinfo}:
{file}: c:\repos\phylanx\phylanx\execution_tree\primitives\primitive_argument_type.hpp
{line}: 172
{function}: struct phylanx::execution_tree::primitive_argument_type *__cdecl phylanx::execution_tree::eval_context::get_var(const struct phylanx::util::hashed_string &) noexcept
{what}: Assertion 'bool(variables_)' failed: HPX(assertion_failure)
taless474 commented 4 years ago

Related to types, statistics primitives produce different dtypes for different result dimensions. E.g. in all operation tests, we can have:

test_operation(R"(all([[1, 0, -1],[1, 2, 0]]))", R"(astype(0 ,"bool"))");
test_operation(R"(all([[1, 0, -1],[1, 2, 0]], 0))", R"(astype([1, 0, 0] ,"bool"))");

the first test passes while the second one fails:

c:\repos\phylanx\tests\unit\plugins\statistics\all_operation.cpp(569): test 'compile_and_run(code) == compile_and_run(expected_str)' failed in function 'void __cdecl test_operation(const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)': '[1, 0, 0]' != '[true, false, false]'
0 sanity checks and 1 test failed.