Skip to content

Load_table() has problems with first row and first value being negative #1355

Closed
@CesarRodriguezPereira

Description

@CesarRodriguezPereira

Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

Description of the bug

Relates to (could even say reopens) #883 and #884. Adds new detail. (IDK if I maybe should've commented on those or if this can be merged and the old issue re-opened).

Loading tables that have two columns causes load_table to miss the first row. Also, if this first row contains a negative value, load_table fails at the TREAD stage, saying it should be in ascending order. I found this error while trying to run a transient model, in which I tried to impose a negative rotation acceleration, which raised the error.

0-padding the array (adding a [0,0] at the beggining) seems to fix the issue regardless of the following values. However, I'm sure there's some edge cases (or not so edge) in which this will mess up a table. Also, it seems counterintuitive that the first value of a column can't be negative, even if in its current state, it doesn't even make it to the final table, I don't think it should fail the check.

Steps To Reproduce

I ran the following tests, to see if I could understand it a bit better:

my_conv = np.array([[0, 0.001],
                        [120, 0.001],
                        [130, 0.005],
                        [700, 0.005],
                        [710, 0.002],
                        [1000, 0.002]])
mapdl.load_table('MY_conv', my_conv, 'TIME')
print(mapdl.parameters['MY_conv'])
my_conv2 = np.array([[0, 0.0001], #check if ascennding order fixes
                        [120, 0.001],
                        [130, 0.005],
                        [700, 0.005],
                        [710, 0.002],
                        [1000, 0.002]])

mapdl.load_table('my_conv2',my_conv2,'TIME')
print('\nmy_conv2')
print(mapdl.parameters['my_conv2'])

test1 = np.array([[0,0], #0 padding and increasing from 1st to 2nd
                    [0,-0.1],
                    [5, 0.1],
                    [10,0],])
mapdl.load_table('test1',test1,'TIME')
print('\ntest1')
print(mapdl.parameters['test1'])

test2 = np.array([  [0,0], #0 padding with decreasing from 1st to 2nd
                    [0,0.1],
                    [5, -0.1],
                    [10,0]]
                    )
mapdl.load_table('test2',test2,'TIME')
print('\ntest2')
print(mapdl.parameters['test2'])

test3 = np.array([  [0,-0.2], #padding with a negative value
                    [0,-0.1],
                    [10,0]]
                    )
mapdl.load_table('test3',test3,'TIME')
print('\ntest3')
print(mapdl.parameters['test3'])

And got the following output:

[[0.001]
 [0.005]
 [0.005]
 [0.002]
 [0.002]]

my_conv2
[[0.001]
 [0.005]
 [0.005]
 [0.002]
 [0.002]]

test1
[[-0.1]
 [ 0.1]
 [ 0. ]]

test2
[[ 0.1]
 [-0.1]
 [ 0. ]]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last) # shortened to not show my entire filesystem, basically points to mapdl.load_table('test3'...
File c:\Users\Cesar\anaconda3\envs\testenv\lib\site-packages\ansys\mapdl\core\mapdl.py:2855, in _MapdlCore.load_table(self, name, array, var1, var2, var3, csysid)
   2850     raise ValueError(
   2851         f"Expecting only a 2D table, but input contains\n{array.ndim} dimensions"
   2852     )
   2854 if not np.all(array[0, :-1] <= array[0, 1:]):
-> 2855     raise ValueError(
   2856         "The underlying ``TREAD`` command requires that the axis 0 is in ascending order."
   2857     )
   2858 if not np.all(array[:-1, 0] <= array[1:, 0]):
   2859     raise ValueError(
   2860         "The underlying ``TREAD`` command requires that the axis 1 is in ascending order."
   2861     )

ValueError: The underlying ``TREAD`` command requires that the axis 0 is in ascending order.

Which Operating System are you using?

Windows

Which Python version are you using?

3.8

PyMAPDL Report

PyMAPDL Software and Environment Report


Packages Requirements
*********************

Core packages
-------------
ansys.mapdl.core    : 0.63.1
numpy               : 1.23.1
appdirs             : 1.4.4
scipy               : 1.7.3
grpc                : Package not found
ansys.api.mapdl.v0  : 0.4.1
ansys.mapdl.reader  : 0.51.14
google.protobuf     : Package not found

Optional packages
-----------------
matplotlib          : 3.5.1
pyvista             : 0.33.2
pyiges              : 0.1.5
tqdm                : 4.64.0
ansys_corba         : 0.1.1


Ansys Installation
******************
Version   Location
------------------
211       C:\Program Files\ANSYS Inc\v211


Ansys Environment Variables
***************************
ANSYS211_DIR                   C:\Program Files\ANSYS Inc\v211\ANSYS
ANSYS_SYSDIR                   winx64
AWP_LOCALE211                  en-us
AWP_ROOT211                    C:\Program Files\ANSYS Inc\v211
CADOE_LIBDIR211                C:\Program Files\ANSYS Inc\v211\CommonFiles\Language\en-us

Installed packages

ansys-api-mapdl==0.5.1
ansys-api-mapdl-v0==0.4.1
ansys-api-platform-instancemanagement==1.0.0b3
ansys-corba==0.1.1
ansys-grpc-mapdl==0.4.0
ansys-mapdl-core==0.63.1
ansys-mapdl-reader==0.51.14
ansys-platform-instancemanagement==1.0.2
anyio @ file:///C:/ci/anyio_1644463701441/work/dist
appdirs==1.4.4
argon2-cffi @ file:///opt/conda/conda-bld/argon2-cffi_1645000214183/work
argon2-cffi-bindings @ file:///C:/ci/argon2-cffi-bindings_1644569878360/work
astroid @ file:///C:/ci/astroid_1639044403229/work
astropy @ file:///C:/ci/astropy_1650634250657/work
asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
Babel @ file:///tmp/build/80754af9/babel_1620871417480/work
backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work
beautifulsoup4 @ file:///C:/ci/beautifulsoup4_1650274792587/work
black==19.10b0
bleach @ file:///opt/conda/conda-bld/bleach_1641577558959/work
bokeh @ file:///C:/Windows/TEMP/abs_4a259bc2-ed05-4a1f-808e-ac712cc0900cddqp8sp7/croots/recipe/bokeh_1658136660686/work
Bottleneck @ file:///C:/Windows/Temp/abs_3198ca53-903d-42fd-87b4-03e6d03a8381yfwsuve8/croots/recipe/bottleneck_1657175565403/work
brotlipy==0.7.0
cachetools==4.2.2
certifi @ file:///C:/Windows/TEMP/abs_e9b7158a-aa56-4a5b-87b6-c00d295b01fanefpc8_o/croots/recipe/certifi_1655968940823/work/certifi
cffi @ file:///C:/Windows/Temp/abs_6808y9x40v/croots/recipe/cffi_1659598653989/work
charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work
click @ file:///C:/ci/click_1646056799533/work
colorama @ file:///C:/Windows/TEMP/abs_9439aeb1-0254-449a-96f7-33ab5eb17fc8apleb4yn/croots/recipe/colorama_1657009099097/work
colorcet @ file:///C:/ci/colorcet_1651833469505/work
cryptography @ file:///C:/ci/cryptography_1652101772384/work
cycler @ file:///tmp/build/80754af9/cycler_1637851556182/work
debugpy @ file:///C:/ci/debugpy_1637073815078/work
decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work
defusedxml @ file:///tmp/build/80754af9/defusedxml_1615228127516/work
entrypoints @ file:///C:/ci/entrypoints_1649926621247/work
executing @ file:///opt/conda/conda-bld/executing_1646925071911/work
fastjsonschema @ file:///tmp/build/80754af9/python-fastjsonschema_1620414857593/work/dist
fonttools==4.25.0
geomdl==5.3.1
google-api-core==1.26.3
google-api-python-client==2.3.0
google-auth==1.30.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.53.0
grpcio==1.37.1
h5py @ file:///C:/ci/h5py_1659071640187/work
hickle==3.4.5
holoviews @ file:///opt/conda/conda-bld/holoviews_1645454331194/work
httplib2==0.19.1
idna @ file:///tmp/build/80754af9/idna_1637925883363/work
imageio==2.19.3
importlib-metadata @ file:///C:/ci/importlib-metadata_1648544472910/work
importlib-resources @ file:///tmp/build/80754af9/importlib_resources_1625135880749/work
ipycanvas @ file:///home/conda/feedstock_root/build_artifacts/ipycanvas_1611165216917/work
ipyevents @ file:///home/conda/feedstock_root/build_artifacts/ipyevents_1613656497764/work
ipykernel @ file:///C:/ci/ipykernel_1647000978151/work/dist/ipykernel-6.9.1-py3-none-any.whl
ipython @ file:///C:/ci/ipython_1657652657542/work
ipython-genutils @ file:///tmp/build/80754af9/ipython_genutils_1606773439826/work
ipyvtk-simple==0.1.4
ipyvtklink @ file:///home/conda/feedstock_root/build_artifacts/ipyvtklink_1618422373741/work
ipywidgets @ file:///tmp/build/80754af9/ipywidgets_1634143127070/work
isort @ file:///tmp/build/80754af9/isort_1628603791788/work
jedi @ file:///C:/ci/jedi_1644315425835/work
Jinja2 @ file:///opt/conda/conda-bld/jinja2_1647436528585/work
json5 @ file:///tmp/build/80754af9/json5_1624432770122/work
jsonschema @ file:///C:/ci/jsonschema_1650026220037/work
jupyter==1.0.0
jupyter-client @ file:///C:/ci/jupyter_client_1650534470695/work
jupyter-console @ file:///opt/conda/conda-bld/jupyter_console_1647002188872/work
jupyter-core @ file:///C:/ci/jupyter_core_1651656285178/work
jupyter-server @ file:///C:/Windows/TEMP/abs_d3c42c59-765d-4f9b-9fa3-ad5b1369485611i_yual/croots/recipe/jupyter_server_1658754493238/work
jupyterlab @ file:///opt/conda/conda-bld/jupyterlab_1647445413472/work
jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work
jupyterlab-server @ file:///C:/ci/jupyterlab_server_1650271783893/work
jupyterlab-widgets @ file:///tmp/build/80754af9/jupyterlab_widgets_1609884341231/work
kiwisolver @ file:///C:/ci/kiwisolver_1653292408254/work
lazy-object-proxy @ file:///C:/ci/lazy-object-proxy_1616529307648/work
loguru @ file:///C:/ci/loguru_1643634821690/work
Markdown @ file:///C:/ci/markdown_1614364121613/work
MarkupSafe @ file:///C:/ci/markupsafe_1654489871526/work
matplotlib @ file:///C:/ci/matplotlib-suite_1647423638658/work
matplotlib-inline @ file:///tmp/build/80754af9/matplotlib-inline_1628242447089/work
mccabe @ file:///opt/conda/conda-bld/mccabe_1644221741721/work
mistune==0.8.4
mkl-fft==1.3.1
mkl-random @ file:///C:/ci/mkl_random_1626186184278/work
mkl-service==2.4.0
munkres==1.1.4
mypy-extensions==0.4.3
nb-conda-kernels @ file:///C:/ci/nb_conda_kernels_1606757941167/work
nbclassic @ file:///opt/conda/conda-bld/nbclassic_1644943264176/work
nbclient @ file:///C:/ci/nbclient_1650290386732/work
nbconvert @ file:///C:/ci/nbconvert_1649741005454/work
nbformat @ file:///C:/ci/nbformat_1649845101866/work
nest-asyncio @ file:///C:/ci/nest-asyncio_1649829929372/work
notebook @ file:///C:/Windows/TEMP/abs_79abr1_60s/croots/recipe/notebook_1659083661851/work
numexpr @ file:///C:/Windows/Temp/abs_e2036a32-9fe9-47f3-a04c-dbb1c232ba4b334exiur/croots/recipe/numexpr_1656940304835/work
numpy @ file:///C:/Windows/Temp/abs_2a1e1vbeag/croots/recipe/numpy_and_numpy_base_1659432712056/work
orjson @ file:///D:/bld/orjson_1618506693629/work/target/wheels/orjson-3.5.2-cp38-none-win_amd64.whl
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pandas @ file:///C:/ci/pandas_1657513811041/work
pandocfilters @ file:///opt/conda/conda-bld/pandocfilters_1643405455980/work
panel @ file:///C:/ci/panel_1657899703556/work
param @ file:///tmp/build/80754af9/param_1636647414893/work
parso @ file:///opt/conda/conda-bld/parso_1641458642106/work
pathspec @ file:///C:/Windows/TEMP/abs_581d0u45mh/croots/recipe/pathspec_1659627132171/work
pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work
Pillow==9.2.0
platformdirs @ file:///tmp/build/80754af9/platformdirs_1638968569495/work
ply==3.11
prometheus-client @ file:///C:/Windows/TEMP/abs_ab9nx8qb08/croots/recipe/prometheus_client_1659455104602/work
prompt-toolkit @ file:///tmp/build/80754af9/prompt-toolkit_1633440160888/work
protobuf==3.20.1
protoc-gen-swagger==0.1.0
pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work
pyct @ file:///C:/ci/pyct_1658488043758/work
pyerfa @ file:///C:/ci/pyerfa_1621561004681/work
Pygments @ file:///opt/conda/conda-bld/pygments_1644249106324/work
pyiges==0.1.5
pylint @ file:///C:/ci/pylint_1647960096242/work
pyOpenSSL @ file:///opt/conda/conda-bld/pyopenssl_1643788558760/work
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
PyQt5==5.15.7
PyQt5-sip @ file:///C:/Windows/Temp/abs_d7gmd2jg8i/croots/recipe/pyqt-split_1659273064801/work/pyqt_sip
pyrsistent @ file:///C:/ci/pyrsistent_1636111468851/work
PySocks @ file:///C:/ci/pysocks_1605287845585/work
python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work
pytz @ file:///C:/Windows/TEMP/abs_90eacd4e-8eff-491e-b26e-f707eba2cbe1ujvbhqz1/croots/recipe/pytz_1654762631027/work
pyvista==0.33.2
pyviz-comms @ file:///tmp/build/80754af9/pyviz_comms_1623747165329/work
pywin32==302
pywinpty @ file:///C:/ci_310/pywinpty_1644230983541/work/target/wheels/pywinpty-2.0.2-cp38-none-win_amd64.whl
PyYAML==6.0
pyzmq @ file:///C:/ci/pyzmq_1657616005830/work
qtconsole @ file:///C:/Windows/TEMP/abs_1bzv7pia1g/croots/recipe/qtconsole_1659510302359/work
QtPy @ file:///opt/conda/conda-bld/qtpy_1649073884068/work
regex @ file:///C:/ci/regex_1658258240596/work
requests @ file:///C:/ci/requests_1657717096906/work
rsa==4.7.2
scipy @ file:///C:/ci/scipy_1641555198988/work
scooby==0.5.12
selenium @ file:///C:/ci/selenium_1614268348533/work
Send2Trash @ file:///tmp/build/80754af9/send2trash_1632406701022/work
sip @ file:///C:/Windows/Temp/abs_b8fxd17m2u/croots/recipe/sip_1659012372737/work
six @ file:///tmp/build/80754af9/six_1644875935023/work
sniffio @ file:///C:/ci/sniffio_1614030707456/work
soupsieve @ file:///tmp/build/80754af9/soupsieve_1636706018808/work
stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work
terminado @ file:///C:/ci/terminado_1644322757089/work
testpath @ file:///C:/Windows/TEMP/abs_23c7fa33-cbb9-46dc-b7c5-590c38e2de3d4bmbngal/croots/recipe/testpath_1655908553202/work
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tornado @ file:///C:/ci/tornado_1606942392901/work
tqdm @ file:///C:/ci/tqdm_1650618053064/work
traitlets @ file:///tmp/build/80754af9/traitlets_1636710298902/work
typed-ast @ file:///C:/ci/typed-ast_1624953785070/work
typing_extensions @ file:///C:/Windows/TEMP/abs_dd2d0moa85/croots/recipe/typing_extensions_1659638831135/work
uritemplate==3.0.1
urllib3 @ file:///C:/Windows/TEMP/abs_65ynz4fdmi/croots/recipe/urllib3_1659110473919/work
vtk===-PKG-VERSION
wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work
webencodings==0.5.1
websocket-client @ file:///C:/ci/websocket-client_1614804473297/work
widgetsnbextension @ file:///C:/ci/widgetsnbextension_1645009558218/work
win-inet-pton @ file:///C:/ci/win_inet_pton_1605306167264/work
win32-setctime @ file:///home/tkoch/Workspace/win32_setctime/win32_setctime_1643630045199/work
wincertstore==0.2
wrapt @ file:///C:/ci/wrapt_1638434029846/work
zipp @ file:///C:/ci/zipp_1652274073489/work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions