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

Fix/table rows #884

Merged
merged 16 commits into from
Feb 17, 2022
Merged

Fix/table rows #884

merged 16 commits into from
Feb 17, 2022

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Feb 11, 2022

Close #883.

@germa89 germa89 added the Bug label Feb 11, 2022
@germa89 germa89 self-assigned this Feb 11, 2022
@codecov
Copy link

codecov bot commented Feb 14, 2022

Codecov Report

Merging #884 (3d2f534) into main (ebc75ac) will increase coverage by 0.07%.
The diff coverage is 94.11%.

@@            Coverage Diff             @@
##             main     #884      +/-   ##
==========================================
+ Coverage   59.23%   59.30%   +0.07%     
==========================================
  Files         172      172              
  Lines       10641    10641              
==========================================
+ Hits         6303     6311       +8     
+ Misses       4338     4330       -8     

@germa89
Copy link
Collaborator Author

germa89 commented Feb 14, 2022

I have realized that this fails:

>>> dimx = 10
>>> dimy = 1
>>> my_conv = np.random.rand(dimx, dimy)
>>> mapdl.load_array("my_conv", my_conv)
>>> assert np.allclose(mapdl.parameters["my_conv"], my_conv) #Fail
AssertionError                            Traceback (most recent call last)
<ipython-input-13-0db9fb3fa50d> in <module>
>>> mapdl.parameters["my_conv"].shape
(10,)
>>> my_conv.shape
(1, 10)

But this works

>>> dimx = 1
>>> dimy = 10
>>> my_conv = np.random.rand(dimx, dimy)
>>> mapdl.load_array("my_conv", my_conv)
>>> assert np.allclose(mapdl.parameters["my_conv"], my_conv) #Works
True
>>> mapdl.parameters["my_conv"].shape
(10,)
>>> my_conv.shape
(10, 1)

I could remove the squeeze of this line:

https://github.com/pyansys/pymapdl/blob/88624d499807f81f707372f9e71c9a42de0e7a80/ansys/mapdl/core/parameters.py#L368

However, then checking against a list will fail because:

>>> my_conv = [1,2,3]
>>> mapdl.load_array("my_conv", my_conv)
>>> assert np.allclose(mapdl.parameters["my_conv"], my_conv) #Works
False
>>> mapdl.parameters["my_conv"].shape
(3,1)
>>> my_conv.shape
(3,)

I guess we need to choose between the right assertions:
Either we return by default arrays of (X,1) or (X,).

If the former, list assertions will fail because they are initialized as (X,).
If the later, then the arrays assertion will fail because they are shaped as (X,1).

I feel we should go for the later, return always the second dimension even if it is 1.

@akaszynski
Copy link
Collaborator

akaszynski commented Feb 16, 2022

I guess we need to choose between the right assertions:
Either we return by default arrays of (X,1) or (X,).

I remember writing this thinking that we might have this issue. Agree that we should be consistent, pick one and go with it (and I'm leaning (X,1).

I feel we should go for the later, return always the second dimension even if it is 1.

Implement and remind me to review.

@germa89
Copy link
Collaborator Author

germa89 commented Feb 16, 2022

@akaszynski ... feel free to review again.

Copy link
Collaborator

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load_table results in table with one fewer rows than expected
2 participants