Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:30:35+00:00 2026-06-17T08:30:35+00:00

First I’d like to apologize for my english. It’s not my first language. This

  • 0

First I’d like to apologize for my english. It’s not my first language.

This is for a program I’m developing to sort data resulting from a repeated load triaxial test. The first column is a segment. Three segment form a cycle. Load, unload, pause. Approx 50 data points for the load, the same for the unload and 100 for the pause. I start with a load at 121. For this section I need the maximum value of the load and unload phases of the fouth column (index 3).

There’s g my array:

[[  1.21000000e+02   1.00313720e+02   2.00015190e-02 ...,   2.25933480e-01
2.95645450e-01  -3.33373370e-01]
[  1.21000000e+02   1.00318600e+02   2.00071220e-02 ...,   2.25933600e-01
2.95629110e-01  -3.33358880e-01]
[  1.21000000e+02   1.00323490e+02   2.00045150e-02 ...,   2.25932690e-01
2.95642500e-01  -3.33374260e-01]
..., 
[  1.50000000e+02   1.10347900e+02   2.00072340e-02 ...,   2.24460500e-01
2.94727620e-01  -3.38975370e-01]
[  1.50000000e+02   1.10352780e+02   1.99971700e-02 ...,   2.24458930e-01
2.94705120e-01  -3.38966550e-01]
[  1.50000000e+02   1.10357670e+02   2.00063640e-02 ...,   2.24455860e-01
2.94704710e-01  -3.38963510e-01]]

after I ran it through that loop:

g = np.loadtxt('test.txt')

Sigmad = []


DataCol = np.hsplit(g, g.shape[1])
DataCharge = DataCol[3] #Charge mean load
DataCycle = DataCol[0]


ld = 0 #ligne de début, start line of the load segment
fc = 0 #Fin de chargement, end line of the unload segment
seg1 = DataCycle[0] #Segment initial, numerical value of the first segment

chargemax = []
i = 0


while i < len(DataCycle):

    if DataCycle[i] == seg1 and DataCycle[i+1] == seg1 and DataCycle[i-1] == seg1 - 1:
        ld = i        

    elif DataCycle[i] == seg1 + 2 and DataCycle[i+1] ==  seg1 + 2 and DataCycle[i-1] == seg1 + 1 :

        fc = i
        print seg1
        chargemax.append(np.max(DataCharge[ld:fc]))
        ld = i + 1
        seg1 += 3

    i+=1

Sigmad.append(1000*np.mean(chargemax[:])/aire)

g is modified and I don’t know why, g is now equal to :

[[  1.51000000e+02,   1.00313720e+02,   2.00020000e-02, ...,
      2.25933000e-01,   2.95645000e-01,  -3.33373000e-01],
   [  1.21000000e+02,   1.00318600e+02,   2.00070000e-02, ...,
      2.25934000e-01,   2.95629000e-01,  -3.33359000e-01],
   [  1.21000000e+02,   1.00323490e+02,   2.00050000e-02, ...,
      2.25933000e-01,   2.95642000e-01,  -3.33374000e-01],
   ..., 
   [  1.50000000e+02,   1.10347900e+02,   2.00070000e-02, ...,
      2.24460000e-01,   2.94728000e-01,  -3.38975000e-01],
   [  1.50000000e+02,   1.10352780e+02,   1.99970000e-02, ...,
      2.24459000e-01,   2.94705000e-01,  -3.38967000e-01],
   [  1.50000000e+02,   1.10357670e+02,   2.00060000e-02, ...,
      2.24456000e-01,   2.94705000e-01,  -3.38964000e-01]]

Can someone please explain to me why it does this. Some values in the 4th column also get modified.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:30:35+00:00Added an answer on June 17, 2026 at 8:30 am

    In this section:

    DataCol = np.hsplit(g, g.shape[1])
    DataCharge = DataCol[3] #Charge mean load
    DataCycle = DataCol[0]
    
    [...]
    
    seg1 = DataCycle[0]
    

    You’re not making copies, you’re only giving new names to views of the original array. So when you do

    seg1 += 3
    

    inside the loop, you’re modifying g itself. For example:

    >>> a = np.array([[1,2,3], [4,5,6]])
    >>> b = a[0]
    >>> b
    array([1, 2, 3])
    >>> b += 100
    >>> b
    array([101, 102, 103])
    >>> a
    array([[101, 102, 103],
           [  4,   5,   6]])
    

    If you want a copy, you can call .copy() explicitly:

    >>> a = np.array([[1,2,3], [4,5,6]])
    >>> b = a[0].copy()
    >>> b
    array([1, 2, 3])
    >>> b += 1000
    >>> b
    array([1001, 1002, 1003])
    >>> a
    array([[1, 2, 3],
           [4, 5, 6]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, excuse me for my English. It is not my native language. I'm working
First things first, I'm aware of this question: Gearman: Sending data from a background
first take a look on this picture from localScope app : i have 2
First I want to do a query like select count(*) from Post p where
First, this has never worked before, so it is not specifically related to VS
First, let me apologize if this is a repeat question. I did a search
First, please tell me if I'm not allowed to ask about this protocol here...
First off, this question is ripped out from this question. I did it because
First off i want to apologize in case this is a known and answered
First of all, this isn't for a keylogger, it's for an input in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.