From 327638c04874b83fa6dca84929a957893ac33f47 Mon Sep 17 00:00:00 2001 From: Sami Chaaban <36083637+sami-chaaban@users.noreply.github.com> Date: Sat, 26 Aug 2023 19:31:28 +0100 Subject: [PATCH] Update v1.47 --- starparser/__init__.py | 2 +- starparser/columnplay.py | 8 ++++---- starparser/particleplay.py | 18 +++++++++--------- starparser/specialparticles.py | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/starparser/__init__.py b/starparser/__init__.py index ee5b73d..f5f1cc6 100644 --- a/starparser/__init__.py +++ b/starparser/__init__.py @@ -1,4 +1,4 @@ import os -__version__ = '1.45' +__version__ = '1.47' _ROOT = os.path.abspath(os.path.dirname(__file__)) \ No newline at end of file diff --git a/starparser/columnplay.py b/starparser/columnplay.py index 8c21b0c..44e483b 100644 --- a/starparser/columnplay.py +++ b/starparser/columnplay.py @@ -27,7 +27,7 @@ def delcolumn(particles, columns, metadata): The "1" tells .drop that it is the column axis that we want to drop inplace means we want the dataframe to be modified instead of creating an assignment """ - nocolparticles.drop(c, 1, inplace=True) + nocolparticles.drop(c, axis=1, inplace=True) #We nead to remove that column header too. The heads are the third #metadata (i.e. metadata[3]) @@ -77,7 +77,7 @@ def swapcolumns(original_particles, swapfrom_particles, columns): The "1" means the column axis and inplace means the dataframe should be modified instead of creating an assignment """ - swappedparticles.drop(c,1,inplace=True) + swappedparticles.drop(c,axis=1,inplace=True) """ Insert the new column in the right index using .insert() @@ -140,7 +140,7 @@ def importmicvalues(importedparticles, importfrom_particles, column): The "1" tells .drop that it is the column axis that we want to drop inplace means we want the dataframe to be modified instead of creating an assignment """ - importedparticles.drop("_rlnMicrographNameSimple", 1, inplace=True) + importedparticles.drop("_rlnMicrographNameSimple", axis=1, inplace=True) return(importedparticles) @@ -293,7 +293,7 @@ def replacecolumn(particles,replacecol,newcol): The "1" means the column axis and inplace means the dataframe should be modified instead of creating an assignment """ - particles.drop(replacecol, 1, inplace=True) + particles.drop(replacecol, axis=1, inplace=True) #Insert the new column in the right index using .insert() #Since newcol comes in as a list, we don't have to modify it diff --git a/starparser/particleplay.py b/starparser/particleplay.py index 3f39f1b..003b5ec 100644 --- a/starparser/particleplay.py +++ b/starparser/particleplay.py @@ -41,8 +41,8 @@ def limitparticles(particles, column, limit, operator): elif operator == "le": limitedparticles = limitedparticles[limitedparticles[tempcolumnname]<=limit] - particles.drop(tempcolumnname,1, inplace=True) - limitedparticles.drop(tempcolumnname,1, inplace=True) + particles.drop(tempcolumnname, axis=1, inplace=True) + limitedparticles.drop(tempcolumnname, axis=1, inplace=True) if len(limitedparticles.index) == 0: print("\n>> Error: there are no particles that match the criterion.\n") @@ -74,10 +74,10 @@ def delparticles(particles, columns, query, queryexact): if not queryexact: q = "|".join(query) - purgedparticles.drop(purgedparticles[purgedparticles[columns[0]].str.contains(q)].index , 0,inplace=True) + purgedparticles.drop(purgedparticles[purgedparticles[columns[0]].str.contains(q)].index , axis=0,inplace=True) else: for q in query: - purgedparticles.drop(purgedparticles[purgedparticles[columns[0]]==q].index , 0,inplace=True) + purgedparticles.drop(purgedparticles[purgedparticles[columns[0]]==q].index , axis=0,inplace=True) return(purgedparticles) @@ -94,7 +94,7 @@ def delduplicates(particles, column): def delmics(particles, micstodelete): purgedparticles = particles.copy() m = "|".join(micstodelete) - purgedparticles.drop(purgedparticles[purgedparticles["_rlnMicrographName"].str.contains(m)].index , 0,inplace=True) + purgedparticles.drop(purgedparticles[purgedparticles["_rlnMicrographName"].str.contains(m)].index , axis=0,inplace=True) return(purgedparticles) """ @@ -122,7 +122,7 @@ def extractparticles(particles, columns, query, queryexact): if not queryexact: extractedparticles = particles.copy() q = "|".join(query) - extractedparticles.drop(extractedparticles[~extractedparticles[columns[0]].str.contains(q)].index, 0,inplace=True) + extractedparticles.drop(extractedparticles[~extractedparticles[columns[0]].str.contains(q)].index, axis=0,inplace=True) else: toconcat = [particles[particles[columns[0]] == q] for q in query] extractedparticles = pd.concat(toconcat) @@ -212,11 +212,11 @@ def regroup(particles, numpergroup): regroupedparticles.sort_values("_rlnDefocusU", inplace=True) if "_rlnGroupNumber" in regroupedparticles.columns: - regroupedparticles.drop("_rlnGroupNumber", 1, inplace=True) + regroupedparticles.drop("_rlnGroupNumber", axis=1, inplace=True) regroupedparticles["_rlnGroupNumber"] = newgroups if "_rlnGroupName" in regroupedparticles.columns: - regroupedparticles.drop("_rlnGroupName", 1, inplace=True) + regroupedparticles.drop("_rlnGroupName", axis=1, inplace=True) newgroups = [("group_"+str(i).zfill(4)) for i in newgroups] regroupedparticles["_rlnGroupName"] = newgroups @@ -331,7 +331,7 @@ def expandoptics(original_particles, original_metadata, newdata, newdata_metadat newoptics=newoptics.loc[newoptics.index.repeat(newoptics.times)].reset_index(drop=True) newoptics["_rlnOpticsGroup"] = range(1,totalimportoptics+len(opticsgrouplist)) - newoptics.drop("times",1, inplace=True) + newoptics.drop("times",axis=1, inplace=True) newopticsnames = newoptics["_rlnOpticsGroupName"].tolist() diff --git a/starparser/specialparticles.py b/starparser/specialparticles.py index 38bde96..0c1bb06 100644 --- a/starparser/specialparticles.py +++ b/starparser/specialparticles.py @@ -138,8 +138,8 @@ def findnearby(coreparticles,nearparticles,threshdist): print("\n>> Out of " + str(len(coreparticles.index)) + ", the subsets have:\n-FAR: " + str(len(farparticles.index)) + " particles\n-CLOSE: " + str(len(closeparticles.index)) + " particles\n-NO-MATCH: " + str(len(noparts)) + " particles\n") #We can remove the new column we made above before returning the dataframes - closeparticles.drop("_rlnMicrographNameSimple", 1, inplace=True) - farparticles.drop("_rlnMicrographNameSimple", 1, inplace=True) + closeparticles.drop("_rlnMicrographNameSimple", axis=1, inplace=True) + farparticles.drop("_rlnMicrographNameSimple", axis=1, inplace=True) return(farparticles, closeparticles, alldistances) @@ -253,10 +253,10 @@ def getcluster(particles,threshold,minimum): keep.append(names[i]) if len(keep) == 0: - print("\n>> Error: no particles were retained based on the criteria.\n") + print(">> Error: no particles were retained based on the criteria.\n") sys.exit() elif len(keep) == len(particles.index): - print("\n>> Error: all particles were retained. No star file will be output.\n") + print(">> Error: all particles were retained. No star file will be output.\n") sys.exit() """